diff options
author | DvTonder <david.vantonder@gmail.com> | 2012-11-27 17:15:01 -0500 |
---|---|---|
committer | DvTonder <david.vantonder@gmail.com> | 2012-11-27 17:15:01 -0500 |
commit | 952bdbda1e14a8e2cb83572a676e73960d1fb4e6 (patch) | |
tree | 1d5a49611fbe929f4cce44427b94da1c576a7aa4 /src/com/android/settings/DevelopmentSettings.java | |
parent | ce33fea1919e5b8d4a2d2c4bd9a270ace469904b (diff) | |
download | packages_apps_settings-952bdbda1e14a8e2cb83572a676e73960d1fb4e6.zip packages_apps_settings-952bdbda1e14a8e2cb83572a676e73960d1fb4e6.tar.gz packages_apps_settings-952bdbda1e14a8e2cb83572a676e73960d1fb4e6.tar.bz2 |
Settings: Make CM developer options additions respect the on/off toggle
This commit fixes the problem where, when dev options are turned off, our
CM customizations don't turn off with the rest of the options and the
dangerous option (root access) does not reset to a safe setting.
Change-Id: I879756ea353ce2940c05b224998fc1a945f2ceff
Diffstat (limited to 'src/com/android/settings/DevelopmentSettings.java')
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index e1d29b5..cfc1b7f 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -295,7 +295,9 @@ public class DevelopmentSettings extends PreferenceFragment mRootAccess = (ListPreference) findPreference(ROOT_ACCESS_KEY); mRootAccess.setOnPreferenceChangeListener(this); - removeRootOptionsIfRequired(); + if (!removeRootOptionsIfRequired()) { + mAllPrefs.add(mRootAccess); + } } private CheckBoxPreference findAndInitCheckboxPref(String key) { @@ -308,13 +310,16 @@ public class DevelopmentSettings extends PreferenceFragment return pref; } - private void removeRootOptionsIfRequired() { + private boolean removeRootOptionsIfRequired() { // user builds don't get root, and eng always gets root if (!Build.IS_DEBUGGABLE || "eng".equals(Build.TYPE)) { if (mRootAccess != null) { getPreferenceScreen().removePreference(mRootAccess); + return true; } } + + return false; } @Override @@ -459,6 +464,7 @@ public class DevelopmentSettings extends PreferenceFragment } } resetDebuggerOptions(); + resetRootAccessOptions(); writeAnimationScaleOption(0, mWindowAnimationScale, null); writeAnimationScaleOption(1, mTransitionAnimationScale, null); writeAnimationScaleOption(2, mAnimatorDurationScale, null); @@ -492,6 +498,19 @@ public class DevelopmentSettings extends PreferenceFragment updateRootAccessOptions(); } + private void resetRootAccessOptions() { + String oldValue = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); + SystemProperties.set(ROOT_ACCESS_PROPERTY, "1"); + if (!oldValue.equals("1") && "1".equals(SystemProperties.get("service.adb.root", "0"))) { + SystemProperties.set("service.adb.root", "0"); + Settings.Secure.putInt(getActivity().getContentResolver(), + Settings.Secure.ADB_ENABLED, 0); + Settings.Secure.putInt(getActivity().getContentResolver(), + Settings.Secure.ADB_ENABLED, 1); + } + updateRootAccessOptions(); + } + private void updateHdcpValues() { int index = 1; // Defaults to drm-only. Needs to match with R.array.hdcp_checking_values ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY); |