• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

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

packages/apps/Settings


コミットメタ情報

リビジョンf26d84b00053c32f8c4c97682819f93cf9a5f29c (tree)
日時2020-04-14 23:49:48
作者Koushik Dutta <koushd@gmai...>
コミッター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

変更サマリ

差分

--- a/Android.mk
+++ b/Android.mk
@@ -20,7 +20,9 @@ LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.settings
2020 LOCAL_MODULE_TAGS := optional
2121 LOCAL_USE_AAPT2 := true
2222
23-LOCAL_SRC_FILES := $(call all-java-files-under, src)
23+LOCAL_SRC_FILES := $(call all-java-files-under, src) \
24+ $(call all-java-files-under,../../../external/koush/Widgets/Widgets/src) \
25+ $(call all-java-files-under,../../../external/koush/Superuser/Superuser/src)
2426
2527 LOCAL_STATIC_ANDROID_LIBRARIES := \
2628 androidx-constraintlayout_constraintlayout \
@@ -54,6 +56,15 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
5456
5557 LOCAL_PROGUARD_FLAG_FILES := proguard.flags
5658
59+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
60+ external/koush/Widgets/Widgets/res \
61+ external/koush/Superuser/Superuser/res
62+
63+LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
64+
65+LOCAL_AAPT_FLAGS := --auto-add-overlay \
66+ --extra-packages com.koushikdutta.superuser:com.koushikdutta.widgets
67+
5768 ifneq ($(INCREMENTAL_BUILDS),)
5869 LOCAL_PROGUARD_ENABLED := disabled
5970 LOCAL_JACK_ENABLED := incremental
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -102,6 +102,30 @@
102102 <uses-permission android:name="android.permission.CAMERA" />
103103 <uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
104104
105+ <permission
106+ android:name="android.permission.REQUEST_SUPERUSER"
107+ android:protectionLevel="signature" />
108+
109+ <permission
110+ android:name="android.permission.REPORT_SUPERUSER"
111+ android:protectionLevel="signature" />
112+
113+ <permission-group
114+ android:name="android.permission-group.SUPERUSER"
115+ android:description="@string/superuser_description_more"
116+ android:icon="@drawable/ic_action_permission"
117+ android:label="@string/superuser"
118+ android:priority="10000" />
119+
120+ <permission
121+ android:name="android.permission.ACCESS_SUPERUSER"
122+ android:description="@string/superuser_description_more"
123+ android:icon="@drawable/ic_action_permission"
124+ android:label="@string/superuser_description"
125+ android:logo="@drawable/ic_action_permission"
126+ android:permissionGroup="android.permission-group.SUPERUSER"
127+ android:protectionLevel="dangerous" />
128+
105129 <application android:label="@string/settings_label"
106130 android:icon="@drawable/ic_launcher_settings"
107131 android:theme="@style/Theme.Settings"
@@ -115,6 +139,48 @@
115139 android:appComponentFactory="androidx.core.app.CoreComponentFactory">
116140
117141 <uses-library android:name="org.apache.http.legacy" />
142+
143+ <!-- Only system/su can open this activity -->
144+ <!-- This activity will then call the MultitaskSuRequestActivity to create a new task stack -->
145+ <activity
146+ android:name=".cyanogenmod.superuser.RequestActivity"
147+ android:configChanges="keyboardHidden|orientation|screenSize"
148+ android:label="@string/superuser"
149+ android:launchMode="singleTask"
150+ android:excludeFromRecents="true"
151+ android:permission="android.permission.REQUEST_SUPERUSER"
152+ android:process=":superuser"
153+ android:taskAffinity="com.android.settings.superuser"
154+ android:theme="@style/RequestThemeDark" />
155+ <!-- Only system/su can open this activity -->
156+ <!-- This is activity is started in multiuser mode when the user invoking su -->
157+ <!-- is not the device owner (user id 0). -->
158+ <activity
159+ android:name=".cyanogenmod.superuser.NotifyActivity"
160+ android:configChanges="keyboardHidden|orientation|screenSize"
161+ android:label="@string/superuser"
162+ android:launchMode="singleTask"
163+ android:excludeFromRecents="true"
164+ android:permission="android.permission.REQUEST_SUPERUSER"
165+ android:process=":superuser"
166+ android:taskAffinity="com.android.settings.superuser"
167+ android:theme="@style/RequestThemeDark" />
168+
169+ <!-- Multiple instances of this activity can be running for multiple su requests -->
170+ <activity
171+ android:name=".cyanogenmod.superuser.MultitaskSuRequestActivity"
172+ android:configChanges="keyboardHidden|orientation|screenSize"
173+ android:excludeFromRecents="true"
174+ android:exported="false"
175+ android:label="@string/request"
176+ android:process=":superuser"
177+ android:taskAffinity="com.android.settings.superuser"
178+ android:theme="@style/RequestThemeDark" />
179+
180+ <receiver
181+ android:name=".cyanogenmod.superuser.SuReceiver"
182+ android:permission="android.permission.REPORT_SUPERUSER" />
183+
118184 <!-- Settings -->
119185
120186 <activity android:name=".homepage.SettingsHomepageActivity"
@@ -1990,6 +2056,28 @@
19902056 android:value="com.android.settings.print.PrintJobSettingsFragment" />
19912057 </activity>
19922058
2059+ <activity android:name="Settings$SuperuserActivity"
2060+ android:label="@string/superuser"
2061+ android:icon="@drawable/ic_action_permission"
2062+ android:taskAffinity="com.android.settings"
2063+ android:parentActivityName="Settings$AccountDashboardActivity">
2064+ <intent-filter>
2065+ <action android:name="android.intent.action.MAIN" />
2066+ <category android:name="android.intent.category.DEFAULT" />
2067+ </intent-filter>
2068+ <intent-filter android:priority="3">
2069+ <action android:name="com.android.settings.action.SETTINGS" />
2070+ </intent-filter>
2071+ <meta-data android:name="com.android.settings.summary"
2072+ android:resource="@string/superuser_description"/>
2073+ <meta-data android:name="com.android.settings.category"
2074+ android:value="com.android.settings.category.ia.accounts" />
2075+ <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
2076+ android:value="com.android.settings.cyanogenmod.superuser.PolicyNativeFragment" />
2077+ <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
2078+ android:value="true" />
2079+ </activity>
2080+
19932081 <activity android:name=".development.AppPicker"
19942082 android:label="@string/select_application"
19952083 android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
--- a/proguard.flags
+++ b/proguard.flags
@@ -7,6 +7,8 @@
77
88 # Keep all Fragments in this package, which are used by reflection.
99 -keep public class com.android.settings.** extends androidx.fragment.app.Fragment
10+-keep public class com.android.settings.cyanogenmod.superuser.**
11+-keep public class com.koushikdutta.**
1012
1113 # Keep all preference controllers needed by slice and DashboardFragment.
1214 -keep class * extends com.android.settings.core.BasePreferenceController {
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -109,6 +109,7 @@ public class Settings extends SettingsActivity {
109109 public static class PaymentSettingsActivity extends SettingsActivity { /* empty */ }
110110 public static class PrintSettingsActivity extends SettingsActivity { /* empty */ }
111111 public static class PrintJobSettingsActivity extends SettingsActivity { /* empty */ }
112+ public static class SuperuserActivity extends SettingsActivity { /* empty */ }
112113 public static class ZenModeSettingsActivity extends SettingsActivity { /* empty */ }
113114 public static class ZenModeBehaviorSettingsActivity extends SettingsActivity { /* empty */ }
114115 public static class ZenModeBlockedEffectsSettingsActivity extends SettingsActivity { /* empty */ }
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -56,6 +56,7 @@ import com.android.settings.core.SettingsBaseActivity;
5656 import com.android.settings.core.SubSettingLauncher;
5757 import com.android.settings.core.gateway.SettingsGateway;
5858 import com.android.settings.dashboard.DashboardFeatureProvider;
59+import com.android.settings.development.RootAccessPreferenceController;
5960 import com.android.settings.homepage.TopLevelSettings;
6061 import com.android.settings.overlay.FeatureFactory;
6162 import com.android.settings.wfd.WifiDisplaySettings;
@@ -625,6 +626,11 @@ public class SettingsActivity extends SettingsBaseActivity
625626 && !Utils.isMonkeyRunning(), isAdmin)
626627 || somethingChanged;
627628
629+ somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
630+ Settings.SuperuserActivity.class.getName()),
631+ RootAccessPreferenceController.isRootForAppsEnabled(), isAdmin)
632+ || somethingChanged;
633+
628634 final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
629635 && !Utils.isMonkeyRunning();
630636 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
--- a/src/com/android/settings/core/gateway/SettingsGateway.java
+++ b/src/com/android/settings/core/gateway/SettingsGateway.java
@@ -60,6 +60,7 @@ import com.android.settings.connecteddevice.AdvancedConnectedDeviceDashboardFrag
6060 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
6161 import com.android.settings.connecteddevice.PreviouslyConnectedDeviceDashboardFragment;
6262 import com.android.settings.connecteddevice.usb.UsbDetailsFragment;
63+import com.android.settings.cyanogenmod.superuser.PolicyNativeFragment;
6364 import com.android.settings.datausage.DataSaverSummary;
6465 import com.android.settings.datausage.DataUsageList;
6566 import com.android.settings.datausage.DataUsageSummary;
@@ -222,6 +223,7 @@ public class SettingsGateway {
222223 ZenAccessSettings.class.getName(),
223224 ZenAccessDetails.class.getName(),
224225 ZenModeAutomationSettings.class.getName(),
226+ PolicyNativeFragment.class.getName(),
225227 PrintSettingsFragment.class.getName(),
226228 PrintJobSettingsFragment.class.getName(),
227229 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
@@ -108,6 +108,13 @@ public class RootAccessPreferenceController extends DeveloperOptionsPreferenceCo
108108 updatePreference();
109109 }
110110
111+ public static boolean isRootForAppsEnabled() {
112+ int value = SystemProperties.getInt(ROOT_ACCESS_PROPERTY, 0);
113+ boolean daemonState =
114+ SystemProperties.get("init.svc.su_daemon", "absent").equals("running");
115+ return daemonState && (value == 1 || value == 3);
116+ }
117+
111118 private void writeRootAccessOptions(Object newValue) {
112119 String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "0");
113120 SystemProperties.set(ROOT_ACCESS_PROPERTY, newValue.toString());