packages/apps/Settings
修訂 | 06374202f8ead911890a0fbd5360aefcf813126a (tree) |
---|---|
時間 | 2017-05-05 02:17:36 |
作者 | Koushik Dutta <koushd@gmai...> |
Commiter | Chih-Wei Huang |
Settings: Add Superuser entry
Amended for nougat-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
@@ -25,13 +25,17 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ | ||
25 | 25 | LOCAL_MODULE_TAGS := optional |
26 | 26 | |
27 | 27 | LOCAL_SRC_FILES := \ |
28 | - $(call all-java-files-under, src) | |
28 | + $(call all-java-files-under, src) \ | |
29 | + $(call all-java-files-under,../../../external/koush/Widgets/Widgets/src) \ | |
30 | + $(call all-java-files-under,../../../external/koush/Superuser/Superuser/src) \ | |
29 | 31 | |
30 | 32 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \ |
31 | 33 | frameworks/support/v7/preference/res \ |
32 | 34 | frameworks/support/v14/preference/res \ |
33 | 35 | frameworks/support/v7/appcompat/res \ |
34 | - frameworks/support/v7/recyclerview/res | |
36 | + frameworks/support/v7/recyclerview/res \ | |
37 | + external/koush/Widgets/Widgets/res \ | |
38 | + external/koush/Superuser/Superuser/res \ | |
35 | 39 | |
36 | 40 | LOCAL_PACKAGE_NAME := Settings |
37 | 41 | LOCAL_CERTIFICATE := platform |
@@ -39,8 +43,10 @@ LOCAL_PRIVILEGED_MODULE := true | ||
39 | 43 | |
40 | 44 | LOCAL_PROGUARD_FLAG_FILES := proguard.flags |
41 | 45 | |
46 | +LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true | |
47 | + | |
42 | 48 | LOCAL_AAPT_FLAGS := --auto-add-overlay \ |
43 | - --extra-packages android.support.v7.preference:android.support.v14.preference:android.support.v17.preference:android.support.v7.appcompat:android.support.v7.recyclerview | |
49 | + --extra-packages android.support.v7.preference:android.support.v14.preference:android.support.v17.preference:android.support.v7.appcompat:android.support.v7.recyclerview:com.koushikdutta.superuser:com.koushikdutta.widgets | |
44 | 50 | |
45 | 51 | ifneq ($(INCREMENTAL_BUILDS),) |
46 | 52 | LOCAL_PROGUARD_ENABLED := disabled |
@@ -87,6 +87,30 @@ | ||
87 | 87 | <uses-permission android:name="android.permission.MANAGE_NOTIFICATIONS"/> |
88 | 88 | <uses-permission android:name="android.permission.DELETE_PACKAGES"/> |
89 | 89 | |
90 | + <permission | |
91 | + android:name="android.permission.REQUEST_SUPERUSER" | |
92 | + android:protectionLevel="signature" /> | |
93 | + | |
94 | + <permission | |
95 | + android:name="android.permission.REPORT_SUPERUSER" | |
96 | + android:protectionLevel="signature" /> | |
97 | + | |
98 | + <permission-group | |
99 | + android:name="android.permission-group.SUPERUSER" | |
100 | + android:description="@string/superuser_description_more" | |
101 | + android:icon="@drawable/ic_action_permission" | |
102 | + android:label="@string/superuser" | |
103 | + android:priority="10000" /> | |
104 | + | |
105 | + <permission | |
106 | + android:name="android.permission.ACCESS_SUPERUSER" | |
107 | + android:description="@string/superuser_description_more" | |
108 | + android:icon="@drawable/ic_action_permission" | |
109 | + android:label="@string/superuser_description" | |
110 | + android:logo="@drawable/ic_action_permission" | |
111 | + android:permissionGroup="android.permission-group.SUPERUSER" | |
112 | + android:protectionLevel="dangerous" /> | |
113 | + | |
90 | 114 | <application android:label="@string/settings_label" |
91 | 115 | android:icon="@mipmap/ic_launcher_settings" |
92 | 116 | android:taskAffinity="" |
@@ -99,6 +123,47 @@ | ||
99 | 123 | android:defaultToDeviceProtectedStorage="true" |
100 | 124 | android:directBootAware="true"> |
101 | 125 | |
126 | + <!-- Only system/su can open this activity --> | |
127 | + <!-- This activity will then call the MultitaskSuRequestActivity to create a new task stack --> | |
128 | + <activity | |
129 | + android:name=".cyanogenmod.superuser.RequestActivity" | |
130 | + android:configChanges="keyboardHidden|orientation|screenSize" | |
131 | + android:label="@string/superuser" | |
132 | + android:launchMode="singleTask" | |
133 | + android:excludeFromRecents="true" | |
134 | + android:permission="android.permission.REQUEST_SUPERUSER" | |
135 | + android:process=":superuser" | |
136 | + android:taskAffinity="com.android.settings.superuser" | |
137 | + android:theme="@style/RequestThemeDark" /> | |
138 | + <!-- Only system/su can open this activity --> | |
139 | + <!-- This is activity is started in multiuser mode when the user invoking su --> | |
140 | + <!-- is not the device owner (user id 0). --> | |
141 | + <activity | |
142 | + android:name=".cyanogenmod.superuser.NotifyActivity" | |
143 | + android:configChanges="keyboardHidden|orientation|screenSize" | |
144 | + android:label="@string/superuser" | |
145 | + android:launchMode="singleTask" | |
146 | + android:excludeFromRecents="true" | |
147 | + android:permission="android.permission.REQUEST_SUPERUSER" | |
148 | + android:process=":superuser" | |
149 | + android:taskAffinity="com.android.settings.superuser" | |
150 | + android:theme="@style/RequestThemeDark" /> | |
151 | + | |
152 | + <!-- Multiple instances of this activity can be running for multiple su requests --> | |
153 | + <activity | |
154 | + android:name=".cyanogenmod.superuser.MultitaskSuRequestActivity" | |
155 | + android:configChanges="keyboardHidden|orientation|screenSize" | |
156 | + android:excludeFromRecents="true" | |
157 | + android:exported="false" | |
158 | + android:label="@string/request" | |
159 | + android:process=":superuser" | |
160 | + android:taskAffinity="com.android.settings.superuser" | |
161 | + android:theme="@style/RequestThemeDark" /> | |
162 | + | |
163 | + <receiver | |
164 | + android:name=".cyanogenmod.superuser.SuReceiver" | |
165 | + android:permission="android.permission.REPORT_SUPERUSER" /> | |
166 | + | |
102 | 167 | <!-- Settings --> |
103 | 168 | |
104 | 169 | <activity android:name="Settings" |
@@ -2012,6 +2077,25 @@ | ||
2012 | 2077 | android:value="com.android.settings.print.PrintJobSettingsFragment" /> |
2013 | 2078 | </activity> |
2014 | 2079 | |
2080 | + <activity android:name="Settings$SuperuserActivity" | |
2081 | + android:label="@string/superuser" | |
2082 | + android:icon="@drawable/ic_action_permission" | |
2083 | + android:taskAffinity=""> | |
2084 | + <intent-filter> | |
2085 | + <action android:name="android.intent.action.MAIN" /> | |
2086 | + <category android:name="android.intent.category.DEFAULT" /> | |
2087 | + </intent-filter> | |
2088 | + <intent-filter android:priority="3"> | |
2089 | + <action android:name="com.android.settings.action.SETTINGS" /> | |
2090 | + </intent-filter> | |
2091 | + <meta-data android:name="com.android.settings.category" | |
2092 | + android:value="com.android.settings.category.system" /> | |
2093 | + <meta-data android:name="com.android.settings.FRAGMENT_CLASS" | |
2094 | + android:value="com.android.settings.cyanogenmod.superuser.PolicyNativeFragment" /> | |
2095 | + <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED" | |
2096 | + android:value="true" /> | |
2097 | + </activity> | |
2098 | + | |
2015 | 2099 | <!-- Keep compatibility with old shortcuts. --> |
2016 | 2100 | <activity-alias android:name="DevelopmentSettings" |
2017 | 2101 | android:exported="true" |
@@ -21,6 +21,8 @@ | ||
21 | 21 | -keep class com.android.settings.accessibility.*FragmentForSetupWizard |
22 | 22 | -keep class com.android.settings.display.*FragmentForSetupWizard |
23 | 23 | -keep class com.android.settings.display.NightDisplaySettings |
24 | +-keep class com.android.settings.cyanogenmod.superuser.** | |
25 | +-keep class com.koushikdutta.** | |
24 | 26 | |
25 | 27 | # Keep click responders |
26 | 28 | -keepclassmembers class com.android.settings.inputmethod.UserDictionaryAddWordActivity { |
@@ -843,6 +843,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment | ||
843 | 843 | .getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]); |
844 | 844 | } |
845 | 845 | |
846 | + /* package */ static boolean isRootForAppsEnabled() { | |
847 | + int value = SystemProperties.getInt(ROOT_ACCESS_PROPERTY, 1); | |
848 | + boolean daemonState = | |
849 | + SystemProperties.get("init.svc.su_daemon", "absent").equals("running"); | |
850 | + return daemonState && (value == 1 || value == 3); | |
851 | + } | |
852 | + | |
846 | 853 | private void writeRootAccessOptions(Object newValue) { |
847 | 854 | String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); |
848 | 855 | SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString()); |
@@ -107,6 +107,7 @@ public class Settings extends SettingsActivity { | ||
107 | 107 | public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ } |
108 | 108 | public static class PrintSettingsActivity extends SettingsActivity { /* empty */ } |
109 | 109 | public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ } |
110 | + public static class SuperuserActivity extends SettingsActivity { /* empty */ } | |
110 | 111 | public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ } |
111 | 112 | public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ } |
112 | 113 | public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ } |
@@ -74,6 +74,7 @@ import com.android.settings.applications.VrListenerSettings; | ||
74 | 74 | import com.android.settings.applications.WriteSettingsDetails; |
75 | 75 | import com.android.settings.bluetooth.BluetoothSettings; |
76 | 76 | import com.android.settings.dashboard.DashboardContainerFragment; |
77 | +import com.android.settings.cyanogenmod.superuser.PolicyNativeFragment; | |
77 | 78 | import com.android.settings.dashboard.SearchResultsSummary; |
78 | 79 | import com.android.settings.datausage.DataUsageSummary; |
79 | 80 | import com.android.settings.deletionhelper.AutomaticStorageManagerSettings; |
@@ -313,6 +314,7 @@ public class SettingsActivity extends SettingsDrawerActivity | ||
313 | 314 | UserSettings.class.getName(), |
314 | 315 | NotificationAccessSettings.class.getName(), |
315 | 316 | ZenAccessSettings.class.getName(), |
317 | + PolicyNativeFragment.class.getName(), | |
316 | 318 | PrintSettingsFragment.class.getName(), |
317 | 319 | PrintJobSettingsFragment.class.getName(), |
318 | 320 | TrustedCredentialsSettings.class.getName(), |
@@ -1096,6 +1098,10 @@ public class SettingsActivity extends SettingsDrawerActivity | ||
1096 | 1098 | Settings.PrintSettingsActivity.class.getName()), |
1097 | 1099 | pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm); |
1098 | 1100 | |
1101 | + setTileEnabled(new ComponentName(packageName, | |
1102 | + Settings.SuperuserActivity.class.getName()), | |
1103 | + DevelopmentSettings.isRootForAppsEnabled(), isAdmin, pm); | |
1104 | + | |
1099 | 1105 | final boolean showDev = mDevelopmentPreferences.getBoolean( |
1100 | 1106 | DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng")) |
1101 | 1107 | && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES); |
@@ -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 |