• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/apps/Settings


Commit MetaInfo

Revisión66bd87c63909d3bc5ae78c1a01add32f5cbc79ee (tree)
Tiempo2019-11-13 20:13:30
AutorKoushik Dutta <koushd@gmai...>
CommiterChih-Wei Huang

Log Message

Settings: Add Superuser entry

Amended for oreo-x86 porting by cwhuang.

Squashed commit of the following:

Author: Koushik Dutta <koushd@gmail.com>
Switch to new Superuser
Change-Id: I9d91392ad6fbc9953d19059ab59b91d214c00e0c

Author: Danny Baumann <dannybaumann@web.de>
Hide Superuser entry if root access for apps is disabled.
Change-Id: Ibb77ba5a0fccf22564a26b8b1e13f7762c65718e

Author: Ricardo Cerqueira <cyanogenmod@cerqueira.org>
Development: Root for apps is unavailable if the su daemon isn't running

The superuser options are tied to the Superuser app variant we use,
which in turn is tied to the su daemon. No daemon, no menu options.
Change-Id: I41d58e62986759336ab38e67f26a558c2eed5aa3

Change-Id: I9d91392ad6fbc9953d19059ab59b91d214c00e0c

Cambiar Resumen

Diferencia incremental

--- a/Android.mk
+++ b/Android.mk
@@ -18,7 +18,9 @@ LOCAL_PRIVILEGED_MODULE := true
1818 LOCAL_MODULE_TAGS := optional
1919 LOCAL_USE_AAPT2 := true
2020
21-LOCAL_SRC_FILES := $(call all-java-files-under, src)
21+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
22+ $(call all-java-files-under,../../../external/koush/Widgets/Widgets/src) \
23+ $(call all-java-files-under,../../../external/koush/Superuser/Superuser/src)
2224
2325 LOCAL_STATIC_ANDROID_LIBRARIES := \
2426 android-slices-builders \
@@ -47,6 +49,15 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
4749
4850 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
4951
52+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
53+ external/koush/Widgets/Widgets/res \
54+ external/koush/Superuser/Superuser/res
55+
56+LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
57+
58+LOCAL_AAPT_FLAGS := --auto-add-overlay \
59+ --extra-packages com.koushikdutta.superuser:com.koushikdutta.widgets
60+
5061 ifneq ($(INCREMENTAL_BUILDS),)
5162 LOCAL_PROGUARD_ENABLED := disabled
5263 LOCAL_JACK_ENABLED := incremental
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -95,6 +95,30 @@
9595 <uses-permission android:name="android.permission.USE_RESERVED_DISK" />
9696 <uses-permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" />
9797
98+ <permission
99+ android:name="android.permission.REQUEST_SUPERUSER"
100+ android:protectionLevel="signature" />
101+
102+ <permission
103+ android:name="android.permission.REPORT_SUPERUSER"
104+ android:protectionLevel="signature" />
105+
106+ <permission-group
107+ android:name="android.permission-group.SUPERUSER"
108+ android:description="@string/superuser_description_more"
109+ android:icon="@drawable/ic_action_permission"
110+ android:label="@string/superuser"
111+ android:priority="10000" />
112+
113+ <permission
114+ android:name="android.permission.ACCESS_SUPERUSER"
115+ android:description="@string/superuser_description_more"
116+ android:icon="@drawable/ic_action_permission"
117+ android:label="@string/superuser_description"
118+ android:logo="@drawable/ic_action_permission"
119+ android:permissionGroup="android.permission-group.SUPERUSER"
120+ android:protectionLevel="dangerous" />
121+
98122 <application android:label="@string/settings_label"
99123 android:icon="@drawable/ic_launcher_settings"
100124 android:taskAffinity=""
@@ -109,6 +133,48 @@
109133 android:appComponentFactory="android.support.v4.app.CoreComponentFactory">
110134
111135 <uses-library android:name="org.apache.http.legacy" />
136+
137+ <!-- Only system/su can open this activity -->
138+ <!-- This activity will then call the MultitaskSuRequestActivity to create a new task stack -->
139+ <activity
140+ android:name=".cyanogenmod.superuser.RequestActivity"
141+ android:configChanges="keyboardHidden|orientation|screenSize"
142+ android:label="@string/superuser"
143+ android:launchMode="singleTask"
144+ android:excludeFromRecents="true"
145+ android:permission="android.permission.REQUEST_SUPERUSER"
146+ android:process=":superuser"
147+ android:taskAffinity="com.android.settings.superuser"
148+ android:theme="@style/RequestThemeDark" />
149+ <!-- Only system/su can open this activity -->
150+ <!-- This is activity is started in multiuser mode when the user invoking su -->
151+ <!-- is not the device owner (user id 0). -->
152+ <activity
153+ android:name=".cyanogenmod.superuser.NotifyActivity"
154+ android:configChanges="keyboardHidden|orientation|screenSize"
155+ android:label="@string/superuser"
156+ android:launchMode="singleTask"
157+ android:excludeFromRecents="true"
158+ android:permission="android.permission.REQUEST_SUPERUSER"
159+ android:process=":superuser"
160+ android:taskAffinity="com.android.settings.superuser"
161+ android:theme="@style/RequestThemeDark" />
162+
163+ <!-- Multiple instances of this activity can be running for multiple su requests -->
164+ <activity
165+ android:name=".cyanogenmod.superuser.MultitaskSuRequestActivity"
166+ android:configChanges="keyboardHidden|orientation|screenSize"
167+ android:excludeFromRecents="true"
168+ android:exported="false"
169+ android:label="@string/request"
170+ android:process=":superuser"
171+ android:taskAffinity="com.android.settings.superuser"
172+ android:theme="@style/RequestThemeDark" />
173+
174+ <receiver
175+ android:name=".cyanogenmod.superuser.SuReceiver"
176+ android:permission="android.permission.REPORT_SUPERUSER" />
177+
112178 <!-- Settings -->
113179
114180 <activity android:name="Settings"
@@ -2000,6 +2066,28 @@
20002066 android:value="com.android.settings.print.PrintJobSettingsFragment" />
20012067 </activity>
20022068
2069+ <activity android:name="Settings$SuperuserActivity"
2070+ android:label="@string/superuser"
2071+ android:icon="@drawable/ic_action_permission"
2072+ android:taskAffinity="com.android.settings"
2073+ android:parentActivityName="Settings$UserAndAccountDashboardActivity">
2074+ <intent-filter>
2075+ <action android:name="android.intent.action.MAIN" />
2076+ <category android:name="android.intent.category.DEFAULT" />
2077+ </intent-filter>
2078+ <intent-filter android:priority="3">
2079+ <action android:name="com.android.settings.action.SETTINGS" />
2080+ </intent-filter>
2081+ <meta-data android:name="com.android.settings.summary"
2082+ android:resource="@string/superuser_description"/>
2083+ <meta-data android:name="com.android.settings.category"
2084+ android:value="com.android.settings.category.ia.accounts" />
2085+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
2086+ android:value="com.android.settings.cyanogenmod.superuser.PolicyNativeFragment" />
2087+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
2088+ android:value="true" />
2089+ </activity>
2090+
20032091 <activity android:name=".development.AppPicker"
20042092 android:label="@string/select_application"
20052093 android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
--- a/proguard.flags
+++ b/proguard.flags
@@ -3,6 +3,8 @@
33
44 # Keep all Fragments in this package, which are used by reflection.
55 -keep public class com.android.settings.** extends android.app.Fragment
6+-keep public class com.android.settings.cyanogenmod.superuser.**
7+-keep public class com.koushikdutta.**
68
79 # Keep all preference controllers needed by slice and DashboardFragment.
810 -keep class * extends com.android.settings.core.BasePreferenceController {
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -99,6 +99,7 @@ public class Settings extends SettingsActivity {
9999 public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
100100 public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
101101 public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
102+ public static class SuperuserActivity extends SettingsActivity { /* empty */ }
102103 public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
103104 public static class ZenModeBehaviorSettingsActivity extends SettingsActivity { /* empty */ }
104105 public static class ZenModeBlockedEffectsSettingsActivity extends SettingsActivity { /* empty */ }
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -63,6 +63,7 @@ import com.android.settings.core.SubSettingLauncher;
6363 import com.android.settings.core.gateway.SettingsGateway;
6464 import com.android.settings.dashboard.DashboardFeatureProvider;
6565 import com.android.settings.dashboard.DashboardSummary;
66+import com.android.settings.development.RootAccessPreferenceController;
6667 import com.android.settings.overlay.FeatureFactory;
6768 import com.android.settings.search.DeviceIndexFeatureProvider;
6869 import com.android.settings.wfd.WifiDisplaySettings;
@@ -694,6 +695,11 @@ public class SettingsActivity extends SettingsDrawerActivity
694695 !UserManager.isDeviceInDemoMode(this), isAdmin)
695696 || somethingChanged;
696697
698+ somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
699+ Settings.SuperuserActivity.class.getName()),
700+ RootAccessPreferenceController.isRootForAppsEnabled(), isAdmin)
701+ || somethingChanged;
702+
697703 final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
698704 && !Utils.isMonkeyRunning();
699705 final boolean isAdminOrDemo = um.isAdminUser() || um.isDemoUser();
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -57,6 +57,7 @@ import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFrag
5757 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
5858 import com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment;
5959 import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
60+import com.android.settings.cyanogenmod.superuser.PolicyNativeFragment;
6061 import com.android.settings.datausage.DataUsageList;
6162 import com.android.settings.datausage.DataUsageSummary;
6263 import com.android.settings.datausage.DataUsageSummaryLegacy;
@@ -202,6 +203,7 @@ public class SettingsGateway {
202203 NotificationAccessSettings.class.getName(),
203204 ZenAccessSettings.class.getName(),
204205 ZenModeAutomationSettings.class.getName(),
206+ PolicyNativeFragment.class.getName(),
205207 PrintSettingsFragment.class.getName(),
206208 PrintJobSettingsFragment.class.getName(),
207209 TrustedCredentialsSettings.class.getName(),
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/superuser/MultitaskSuRequestActivity.java
@@ -0,0 +1,4 @@
1+package com.android.settings.cyanogenmod.superuser;
2+
3+public class MultitaskSuRequestActivity extends com.koushikdutta.superuser.MultitaskSuRequestActivity {
4+}
\ No newline at end of file
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/superuser/NotifyActivity.java
@@ -0,0 +1,4 @@
1+package com.android.settings.cyanogenmod.superuser;
2+
3+public class NotifyActivity extends com.koushikdutta.superuser.NotifyActivity {
4+}
\ No newline at end of file
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/superuser/PolicyNativeFragment.java
@@ -0,0 +1,4 @@
1+package com.android.settings.cyanogenmod.superuser;
2+
3+public class PolicyNativeFragment extends com.koushikdutta.superuser.PolicyNativeFragment {
4+}
\ No newline at end of file
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/superuser/RequestActivity.java
@@ -0,0 +1,4 @@
1+package com.android.settings.cyanogenmod.superuser;
2+
3+public class RequestActivity extends com.koushikdutta.superuser.RequestActivity {
4+}
\ No newline at end of file
--- /dev/null
+++ b/src/com/android/settings/cyanogenmod/superuser/SuReceiver.java
@@ -0,0 +1,4 @@
1+package com.android.settings.cyanogenmod.superuser;
2+
3+public class SuReceiver extends com.koushikdutta.superuser.SuReceiver {
4+}
\ No newline at end of file
--- a/src/com/android/settings/development/RootAccessPreferenceController.java
+++ b/src/com/android/settings/development/RootAccessPreferenceController.java
@@ -109,6 +109,13 @@ public class RootAccessPreferenceController extends DeveloperOptionsPreferenceCo
109109 updatePreference();
110110 }
111111
112+ public static boolean isRootForAppsEnabled() {
113+ int value = SystemProperties.getInt(ROOT_ACCESS_PROPERTY, 0);
114+ boolean daemonState =
115+ SystemProperties.get("init.svc.su_daemon", "absent").equals("running");
116+ return daemonState && (value == 1 || value == 3);
117+ }
118+
112119 private void writeRootAccessOptions(Object newValue) {
113120 String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
114121 SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString());