packages/apps/Settings
Revisión | 66bd87c63909d3bc5ae78c1a01add32f5cbc79ee (tree) |
---|---|
Tiempo | 2019-11-13 20:13:30 |
Autor | Koushik Dutta <koushd@gmai...> |
Commiter | Chih-Wei Huang |
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
@@ -18,7 +18,9 @@ LOCAL_PRIVILEGED_MODULE := true | ||
18 | 18 | LOCAL_MODULE_TAGS := optional |
19 | 19 | LOCAL_USE_AAPT2 := true |
20 | 20 | |
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) | |
22 | 24 | |
23 | 25 | LOCAL_STATIC_ANDROID_LIBRARIES := \ |
24 | 26 | android-slices-builders \ |
@@ -47,6 +49,15 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ | ||
47 | 49 | |
48 | 50 | LOCAL_PROGUARD_FLAG_FILES := proguard.flags |
49 | 51 | |
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 | + | |
50 | 61 | ifneq ($(INCREMENTAL_BUILDS),) |
51 | 62 | LOCAL_PROGUARD_ENABLED := disabled |
52 | 63 | LOCAL_JACK_ENABLED := incremental |
@@ -95,6 +95,30 @@ | ||
95 | 95 | <uses-permission android:name="android.permission.USE_RESERVED_DISK" /> |
96 | 96 | <uses-permission android:name="android.permission.MANAGE_SCOPED_ACCESS_DIRECTORY_PERMISSIONS" /> |
97 | 97 | |
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 | + | |
98 | 122 | <application android:label="@string/settings_label" |
99 | 123 | android:icon="@drawable/ic_launcher_settings" |
100 | 124 | android:taskAffinity="" |
@@ -109,6 +133,48 @@ | ||
109 | 133 | android:appComponentFactory="android.support.v4.app.CoreComponentFactory"> |
110 | 134 | |
111 | 135 | <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 | + | |
112 | 178 | <!-- Settings --> |
113 | 179 | |
114 | 180 | <activity android:name="Settings" |
@@ -2000,6 +2066,28 @@ | ||
2000 | 2066 | android:value="com.android.settings.print.PrintJobSettingsFragment" /> |
2001 | 2067 | </activity> |
2002 | 2068 | |
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 | + | |
2003 | 2091 | <activity android:name=".development.AppPicker" |
2004 | 2092 | android:label="@string/select_application" |
2005 | 2093 | android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" /> |
@@ -3,6 +3,8 @@ | ||
3 | 3 | |
4 | 4 | # Keep all Fragments in this package, which are used by reflection. |
5 | 5 | -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.** | |
6 | 8 | |
7 | 9 | # Keep all preference controllers needed by slice and DashboardFragment. |
8 | 10 | -keep class * extends com.android.settings.core.BasePreferenceController { |
@@ -99,6 +99,7 @@ public class Settings extends SettingsActivity { | ||
99 | 99 | public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ } |
100 | 100 | public static class PrintSettingsActivity extends SettingsActivity { /* empty */ } |
101 | 101 | public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ } |
102 | + public static class SuperuserActivity extends SettingsActivity { /* empty */ } | |
102 | 103 | public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ } |
103 | 104 | public static class ZenModeBehaviorSettingsActivity extends SettingsActivity { /* empty */ } |
104 | 105 | public static class ZenModeBlockedEffectsSettingsActivity extends SettingsActivity { /* empty */ } |
@@ -63,6 +63,7 @@ import com.android.settings.core.SubSettingLauncher; | ||
63 | 63 | import com.android.settings.core.gateway.SettingsGateway; |
64 | 64 | import com.android.settings.dashboard.DashboardFeatureProvider; |
65 | 65 | import com.android.settings.dashboard.DashboardSummary; |
66 | +import com.android.settings.development.RootAccessPreferenceController; | |
66 | 67 | import com.android.settings.overlay.FeatureFactory; |
67 | 68 | import com.android.settings.search.DeviceIndexFeatureProvider; |
68 | 69 | import com.android.settings.wfd.WifiDisplaySettings; |
@@ -694,6 +695,11 @@ public class SettingsActivity extends SettingsDrawerActivity | ||
694 | 695 | !UserManager.isDeviceInDemoMode(this), isAdmin) |
695 | 696 | || somethingChanged; |
696 | 697 | |
698 | + somethingChanged = setTileEnabled(changedList, new ComponentName(packageName, | |
699 | + Settings.SuperuserActivity.class.getName()), | |
700 | + RootAccessPreferenceController.isRootForAppsEnabled(), isAdmin) | |
701 | + || somethingChanged; | |
702 | + | |
697 | 703 | final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this) |
698 | 704 | && !Utils.isMonkeyRunning(); |
699 | 705 | final boolean isAdminOrDemo = um.isAdminUser() || um.isDemoUser(); |
@@ -57,6 +57,7 @@ import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFrag | ||
57 | 57 | import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment; |
58 | 58 | import com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment; |
59 | 59 | import com.android.settings.connecteddevice.usb.UsbDetailsFragment; |
60 | +import com.android.settings.cyanogenmod.superuser.PolicyNativeFragment; | |
60 | 61 | import com.android.settings.datausage.DataUsageList; |
61 | 62 | import com.android.settings.datausage.DataUsageSummary; |
62 | 63 | import com.android.settings.datausage.DataUsageSummaryLegacy; |
@@ -202,6 +203,7 @@ public class SettingsGateway { | ||
202 | 203 | NotificationAccessSettings.class.getName(), |
203 | 204 | ZenAccessSettings.class.getName(), |
204 | 205 | ZenModeAutomationSettings.class.getName(), |
206 | + PolicyNativeFragment.class.getName(), | |
205 | 207 | PrintSettingsFragment.class.getName(), |
206 | 208 | PrintJobSettingsFragment.class.getName(), |
207 | 209 | TrustedCredentialsSettings.class.getName(), |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -109,6 +109,13 @@ public class RootAccessPreferenceController extends DeveloperOptionsPreferenceCo | ||
109 | 109 | updatePreference(); |
110 | 110 | } |
111 | 111 | |
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 | + | |
112 | 119 | private void writeRootAccessOptions(Object newValue) { |
113 | 120 | String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0"); |
114 | 121 | SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString()); |