• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

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

packages/apps/Settings


Commit MetaInfo

修訂06374202f8ead911890a0fbd5360aefcf813126a (tree)
時間2017-05-05 02:17:36
作者Koushik Dutta <koushd@gmai...>
CommiterChih-Wei Huang

Log Message

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

Change Summary

差異

--- a/Android.mk
+++ b/Android.mk
@@ -25,13 +25,17 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
2525 LOCAL_MODULE_TAGS := optional
2626
2727 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) \
2931
3032 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
3133 frameworks/support/v7/preference/res \
3234 frameworks/support/v14/preference/res \
3335 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 \
3539
3640 LOCAL_PACKAGE_NAME := Settings
3741 LOCAL_CERTIFICATE := platform
@@ -39,8 +43,10 @@ LOCAL_PRIVILEGED_MODULE := true
3943
4044 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
4145
46+LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
47+
4248 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
4450
4551 ifneq ($(INCREMENTAL_BUILDS),)
4652 LOCAL_PROGUARD_ENABLED := disabled
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -87,6 +87,30 @@
8787 <uses-permission android:name="android.permission.MANAGE_NOTIFICATIONS"/>
8888 <uses-permission android:name="android.permission.DELETE_PACKAGES"/>
8989
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+
90114 <application android:label="@string/settings_label"
91115 android:icon="@mipmap/ic_launcher_settings"
92116 android:taskAffinity=""
@@ -99,6 +123,47 @@
99123 android:defaultToDeviceProtectedStorage="true"
100124 android:directBootAware="true">
101125
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+
102167 <!-- Settings -->
103168
104169 <activity android:name="Settings"
@@ -2012,6 +2077,25 @@
20122077 android:value="com.android.settings.print.PrintJobSettingsFragment" />
20132078 </activity>
20142079
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+
20152099 <!-- Keep compatibility with old shortcuts. -->
20162100 <activity-alias android:name="DevelopmentSettings"
20172101 android:exported="true"
--- a/proguard.flags
+++ b/proguard.flags
@@ -21,6 +21,8 @@
2121 -keep class com.android.settings.accessibility.*FragmentForSetupWizard
2222 -keep class com.android.settings.display.*FragmentForSetupWizard
2323 -keep class com.android.settings.display.NightDisplaySettings
24+-keep class com.android.settings.cyanogenmod.superuser.**
25+-keep class com.koushikdutta.**
2426
2527 # Keep click responders
2628 -keepclassmembers class com.android.settings.inputmethod.UserDictionaryAddWordActivity {
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -843,6 +843,13 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
843843 .getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]);
844844 }
845845
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+
846853 private void writeRootAccessOptions(Object newValue) {
847854 String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1");
848855 SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString());
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -107,6 +107,7 @@ public class Settings extends SettingsActivity {
107107 public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
108108 public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
109109 public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
110+ public static class SuperuserActivity extends SettingsActivity { /* empty */ }
110111 public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
111112 public static class ZenModePrioritySettingsActivity extends SettingsActivity { /* empty */ }
112113 public static class ZenModeAutomationSettingsActivity extends SettingsActivity { /* empty */ }
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -74,6 +74,7 @@ import com.android.settings.applications.VrListenerSettings;
7474 import com.android.settings.applications.WriteSettingsDetails;
7575 import com.android.settings.bluetooth.BluetoothSettings;
7676 import com.android.settings.dashboard.DashboardContainerFragment;
77+import com.android.settings.cyanogenmod.superuser.PolicyNativeFragment;
7778 import com.android.settings.dashboard.SearchResultsSummary;
7879 import com.android.settings.datausage.DataUsageSummary;
7980 import com.android.settings.deletionhelper.AutomaticStorageManagerSettings;
@@ -313,6 +314,7 @@ public class SettingsActivity extends SettingsDrawerActivity
313314 UserSettings.class.getName(),
314315 NotificationAccessSettings.class.getName(),
315316 ZenAccessSettings.class.getName(),
317+ PolicyNativeFragment.class.getName(),
316318 PrintSettingsFragment.class.getName(),
317319 PrintJobSettingsFragment.class.getName(),
318320 TrustedCredentialsSettings.class.getName(),
@@ -1096,6 +1098,10 @@ public class SettingsActivity extends SettingsDrawerActivity
10961098 Settings.PrintSettingsActivity.class.getName()),
10971099 pm.hasSystemFeature(PackageManager.FEATURE_PRINTING), isAdmin, pm);
10981100
1101+ setTileEnabled(new ComponentName(packageName,
1102+ Settings.SuperuserActivity.class.getName()),
1103+ DevelopmentSettings.isRootForAppsEnabled(), isAdmin, pm);
1104+
10991105 final boolean showDev = mDevelopmentPreferences.getBoolean(
11001106 DevelopmentSettings.PREF_SHOW, android.os.Build.TYPE.equals("eng"))
11011107 && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES);
--- /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