|
69 | 69 | import android.support.v7.preference.ListPreference; |
70 | 70 | import android.support.v7.preference.Preference; |
71 | 71 | import android.support.v7.preference.Preference.OnPreferenceChangeListener; |
| 72 | +import android.support.v7.preference.Preference.OnPreferenceClickListener; |
72 | 73 | import android.support.v7.preference.PreferenceGroup; |
73 | 74 | import android.support.v7.preference.PreferenceScreen; |
74 | 75 | import android.telephony.TelephonyManager; |
|
89 | 90 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
90 | 91 | import com.android.settings.R; |
91 | 92 | import com.android.settings.RestrictedSettingsFragment; |
| 93 | +import com.android.settings.Settings.AppOpsSummaryActivity; |
92 | 94 | import com.android.settings.SettingsActivity; |
93 | 95 | import com.android.settings.Utils; |
94 | 96 | import com.android.settings.dashboard.DashboardFeatureProvider; |
|
116 | 118 | */ |
117 | 119 | public class DevelopmentSettings extends RestrictedSettingsFragment |
118 | 120 | implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener, |
119 | | - OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable { |
| 121 | + OnPreferenceChangeListener, SwitchBar.OnSwitchChangeListener, Indexable, |
| 122 | + OnPreferenceClickListener { |
120 | 123 | private static final String TAG = "DevelopmentSettings"; |
121 | 124 |
|
122 | 125 | /** |
@@ -234,6 +237,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment |
234 | 237 | private static final String ROOT_ACCESS_KEY = "root_access"; |
235 | 238 | private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access"; |
236 | 239 |
|
| 240 | + private static final String ROOT_APPOPS_KEY = "root_appops"; |
| 241 | + |
237 | 242 | private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY |
238 | 243 | = "immediately_destroy_activities"; |
239 | 244 | private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit"; |
@@ -352,6 +357,8 @@ public class DevelopmentSettings extends RestrictedSettingsFragment |
352 | 357 |
|
353 | 358 | private ColorModePreference mColorModePreference; |
354 | 359 |
|
| 360 | + private Preference mRootAppops; |
| 361 | + |
355 | 362 | private SwitchPreference mForceResizable; |
356 | 363 |
|
357 | 364 | private SwitchPreference mColorTemperaturePreference; |
@@ -616,8 +623,13 @@ public void onCreate(Bundle icicle) { |
616 | 623 |
|
617 | 624 | mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY); |
618 | 625 | mRootAccess.setOnPreferenceChangeListener(this); |
| 626 | + |
| 627 | + mRootAppops = (Preference) findPreference(ROOT_APPOPS_KEY); |
| 628 | + mRootAppops.setOnPreferenceClickListener(this); |
| 629 | + |
619 | 630 | if (!removeRootOptionsIfRequired()) { |
620 | 631 | mAllPrefs.add(mRootAccess); |
| 632 | + mAllPrefs.add(mRootAppops); |
621 | 633 | } |
622 | 634 | addDashboardCategoryPreferences(); |
623 | 635 | } |
@@ -973,6 +985,10 @@ private void updateRootAccessOptions() { |
973 | 985 | mRootAccess.setValue(value); |
974 | 986 | mRootAccess.setSummary(getResources() |
975 | 987 | .getStringArray(R.array.root_access_entries)[Integer.valueOf(value)]); |
| 988 | + |
| 989 | + if (mRootAppops != null) { |
| 990 | + mRootAppops.setEnabled(isRootForAppsEnabled()); |
| 991 | + } |
976 | 992 | } |
977 | 993 |
|
978 | 994 | public static boolean isRootForAppsEnabled() { |
@@ -2566,6 +2582,19 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { |
2566 | 2582 | } |
2567 | 2583 | } |
2568 | 2584 |
|
| 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 | + |
2569 | 2598 | @Override |
2570 | 2599 | public boolean onPreferenceTreeClick(Preference preference) { |
2571 | 2600 | if (Utils.isMonkeyRunning()) { |
|
0 commit comments