OSDN Git Service

Development Settings: fix setting reset on disable
authorThiago Vinícius Freire de Araújo Ribeiro <thiagovfar@gmail.com>
Sun, 5 May 2013 16:58:59 +0000 (13:58 -0300)
committerGerrit Code Review <gerrit@cyanogenmod.org>
Wed, 23 Dec 2015 21:13:03 +0000 (13:13 -0800)
When Development Settings are disabled, some settings are
reset to values other than the default. This fixes it.

 - Adb notify should reset to enabled

 - Verify apps over usb should reset to enabled

Change-Id: Ifa1ee25cfab32b7a236e02055006f0d2a4b07f37

src/com/android/settings/DevelopmentSettings.java

index 0d8b6a4..24fe2bb 100644 (file)
@@ -335,7 +335,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
                 findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
         mEnableAdb = findAndInitSwitchPref(ENABLE_ADB);
 
-        mAdbNotify = findAndInitSwitchPref(ADB_NOTIFY);
+        mAdbNotify = (SwitchPreference) findPreference(ADB_NOTIFY);
         mAllPrefs.add(mAdbNotify);
         mAdbOverNetwork = findAndInitSwitchPref(ADB_TCPIP);
 
@@ -387,7 +387,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         mMockLocationAppPref = findPreference(MOCK_LOCATION_APP_KEY);
         mAllPrefs.add(mMockLocationAppPref);
 
-        mVerifyAppsOverUsb = findAndInitSwitchPref(VERIFY_APPS_OVER_USB_KEY);
+        mVerifyAppsOverUsb = (SwitchPreference) findPreference(VERIFY_APPS_OVER_USB_KEY);
+        mAllPrefs.add(mVerifyAppsOverUsb);
         if (!showVerifierSetting()) {
             if (debugDebuggingCategory != null) {
                 debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
@@ -774,6 +775,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         resetDebuggerOptions();
         writeLogdSizeOption(null);
         resetRootAccessOptions();
+        resetAdbNotifyOptions();
+        resetVerifyAppsOverUsbOptions();
         resetDevelopmentShortcutOptions();
         resetUpdateRecoveryOptions();
         writeAnimationScaleOption(0, mWindowAnimationScale, null);
@@ -832,6 +835,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         updateRootAccessOptions();
     }
 
+    private void resetAdbNotifyOptions() {
+        CMSettings.Secure.putInt(getActivity().getContentResolver(),
+                CMSettings.Secure.ADB_NOTIFY, 1);
+    }
+
     private void updateStayAwakeOptions() {
         int index = Settings.Global.getInt(getActivity().getContentResolver(),
                 Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
@@ -1018,6 +1026,11 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
               Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, mVerifyAppsOverUsb.isChecked() ? 1 : 0);
     }
 
+    private void resetVerifyAppsOverUsbOptions() {
+        Settings.Global.putInt(getActivity().getContentResolver(),
+              Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1);
+    }
+
     private boolean enableVerifierSetting() {
         final ContentResolver cr = getActivity().getContentResolver();
         if (Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 0) {