Skip to content

Commit 1ad5974

Browse files
AdrianDCmikeNG
authored andcommitted
Settings: Root appops access in developer settings
* Allow users to directly access the root app settings, as the feature is mostly unknown and often a reason for users to try using alternatives to CM root * Use the appops extra intent to link the su tab, introduced in I79d963ecbadc624dc45a398387a348691318b6be * Implements the PreferenceClickListener from 126013 Change-Id: Ia5bc9d56fb11700b19d73336fad13c0a936091ff Signed-off-by: Adrian DC <radian.dc@gmail.com>
1 parent 7c912a5 commit 1ad5974

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

res/values/cm_strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
<string name="root_access_adb">ADB only</string>
3333
<string name="root_access_all">Apps and ADB</string>
3434

35+
<!-- Preference link for root appops -->
36+
<string name="root_appops_title">Manage root accesses</string>
37+
<string name="root_appops_summary">View and control the root rules</string>
38+
3539
<!-- Double tap to sleep on status bar or lockscreen -->
3640
<string name="status_bar_double_tap_to_sleep_title">Tap to sleep</string>
3741
<string name="status_bar_double_tap_to_sleep_summary">Double-tap on the status bar or lockscreen to turn off the display</string>

res/xml/development_prefs.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@
128128
android:entries="@array/root_access_entries"
129129
android:entryValues="@array/root_access_values" />
130130

131+
<Preference
132+
android:key="root_appops"
133+
android:title="@string/root_appops_title"
134+
android:summary="@string/root_appops_summary" />
135+
131136
<PreferenceCategory android:key="debug_debugging_category"
132137
android:title="@string/debug_debugging_category">
133138

src/com/android/settings/development/DevelopmentSettings.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
import android.support.v7.preference.ListPreference;
7070
import android.support.v7.preference.Preference;
7171
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
72+
import android.support.v7.preference.Preference.OnPreferenceClickListener;
7273
import android.support.v7.preference.PreferenceGroup;
7374
import android.support.v7.preference.PreferenceScreen;
7475
import android.telephony.TelephonyManager;
@@ -89,6 +90,7 @@
8990
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
9091
import com.android.settings.R;
9192
import com.android.settings.RestrictedSettingsFragment;
93+
import com.android.settings.Settings.AppOpsSummaryActivity;
9294
import com.android.settings.SettingsActivity;
9395
import com.android.settings.Utils;
9496
import com.android.settings.dashboard.DashboardFeatureProvider;
@@ -116,7 +118,8 @@
116118
*/
117119
public class DevelopmentSettings extends RestrictedSettingsFragment
118120
implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
119-
OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable {
121+
OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable,
122+
OnPreferenceClickListener {
120123
private static final String TAG = "DevelopmentSettings";
121124

122125
/**
@@ -234,6 +237,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
234237
private static final String ROOT_ACCESS_KEY = "root_access";
235238
private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access";
236239

240+
private static final String ROOT_APPOPS_KEY = "root_appops";
241+
237242
private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY
238243
= "immediately_destroy_activities";
239244
private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit";
@@ -352,6 +357,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
352357

353358
private ColorModePreference mColorModePreference;
354359

360+
private Preference mRootAppops;
361+
355362
private SwitchPreference mForceResizable;
356363

357364
private SwitchPreference mColorTemperaturePreference;
@@ -616,8 +623,13 @@ public void onCreate(Bundle icicle) {
616623

617624
mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY);
618625
mRootAccess.setOnPreferenceChangeListener(this);
626+
627+
mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY);
628+
mRootAppops.setOnPreferenceClickListener(this);
629+
619630
if (!removeRootOptionsIfRequired()) {
620631
mAllPrefs.add(mRootAccess);
632+
mAllPrefs.add(mRootAppops);
621633
}
622634
addDashboardCategoryPreferences();
623635
}
@@ -973,6 +985,10 @@ private void updateRootAccessOptions() {
973985
mRootAccess.setValue(value);
974986
mRootAccess.setSummary(getResources()
975987
.getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]);
988+
989+
if (mRootAppops != null) {
990+
mRootAppops.setEnabled(isRootForAppsEnabled());
991+
}
976992
}
977993

978994
public static boolean isRootForAppsEnabled() {
@@ -2566,6 +2582,19 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
25662582
}
25672583
}
25682584

2585+
@Override
2586+
public boolean onPreferenceClick(Preference preference) {
2587+
if (preference == mRootAppops) {
2588+
Activity mActivity = getActivity();
2589+
Intent intent = new Intent(Intent.ACTION_MAIN);
2590+
intent.putExtra("appops_tab", getString(R.string.app_ops_categories_su));
2591+
intent.setClass(mActivity, AppOpsSummaryActivity.class);
2592+
mActivity.startActivity(intent);
2593+
return true;
2594+
}
2595+
return false;
2596+
}
2597+
25692598
@Override
25702599
public boolean onPreferenceTreeClick(Preference preference) {
25712600
if (Utils.isMonkeyRunning()) {

0 commit comments

Comments
 (0)