OSDN Git Service

DevelopmentSettings: Add an opt-out for recovery updater
authorAdrian DC <radian.dc@gmail.com>
Tue, 10 Jun 2014 02:16:24 +0000 (21:16 -0500)
committerAdrian DC <radian.dc@gmail.com>
Thu, 15 Sep 2016 17:26:56 +0000 (10:26 -0700)
 * Some devices should not have this option,
    for instance all Sony devices supported on CyanogenMod
    already include the ROM's recovery inside the ramdisk
    and provide their own init_sony boot selection

 * Makes sure a user did not enable the option
    on old installations by disabling it if needed

 * Disable the recovery updater through the new overlay

 * Prevent recovery updater related features to run, and
    pass an additional context argument from BootReceiver
    to initializeUpdateRecoveryOption to access resources

 * Similar to the original CM 11.0 commit by Dan Pasanen

Change-Id: I1963e27e59353e1a7e26a4edf905bee6c9da0571

res/values/config.xml
src/com/android/settings/DevelopmentSettings.java
src/com/android/settings/cyanogenmod/BootReceiver.java

index 69707e3..aa97d3c 100755 (executable)
     <!-- Does the device allow for manual subscription provisioning? Only works for multi-sim devices,
          and currently depends on QC's proprietary telephony stack -->
     <bool name="config_enableManualSubProvisioning">true</bool>
+
+    <!-- Does the device allow updating the recovery. -->
+    <bool name="config_enableRecoveryUpdater">true</bool>
 </resources>
index a30dba2..b5b89cb 100644 (file)
@@ -519,6 +519,15 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
             removePreference(COLOR_TEMPERATURE_KEY);
             mColorTemperaturePreference = null;
         }
+
+        if (!getResources().getBoolean(R.bool.config_enableRecoveryUpdater)) {
+            removePreference(mUpdateRecovery);
+            mUpdateRecovery = null;
+            if (SystemProperties.getBoolean(UPDATE_RECOVERY_PROPERTY, false)) {
+                SystemProperties.set(UPDATE_RECOVERY_PROPERTY, "false");
+                pokeSystemProperties();
+            }
+        }
     }
 
     private ListPreference addListPreference(String prefKey) {
@@ -754,7 +763,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         updateRootAccessOptions();
         updateAdvancedRebootOptions();
         updateDevelopmentShortcutOptions();
-        updateUpdateRecoveryOptions();
+        if (mUpdateRecovery != null) {
+            updateUpdateRecoveryOptions();
+        }
         if (mColorTemperaturePreference != null) {
             updateColorTemperature();
         }
@@ -830,7 +841,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         resetAdbNotifyOptions();
         resetVerifyAppsOverUsbOptions();
         resetDevelopmentShortcutOptions();
-        resetUpdateRecoveryOptions();
+        if (mUpdateRecovery != null) {
+            resetUpdateRecoveryOptions();
+        }
         writeAnimationScaleOption(0, mWindowAnimationScale, null);
         writeAnimationScaleOption(1, mTransitionAnimationScale, null);
         writeAnimationScaleOption(2, mAnimatorDurationScale, null);
@@ -1855,8 +1868,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
         }
     }
 
-    public static void initializeUpdateRecoveryOption() {
-        if (TextUtils.isEmpty(SystemProperties.get(UPDATE_RECOVERY_PROPERTY))) {
+    public static void initializeUpdateRecoveryOption(Context context) {
+        if (TextUtils.isEmpty(SystemProperties.get(UPDATE_RECOVERY_PROPERTY)) &&
+                context.getResources().getBoolean(R.bool.config_enableRecoveryUpdater)) {
             resetUpdateRecoveryOptions();
         }
     }
index 20190e6..406ccb1 100644 (file)
@@ -53,7 +53,7 @@ public class BootReceiver extends BroadcastReceiver {
         // Extract the contributors database
         ContributorsCloudFragment.extractContributorsCloudDatabase(ctx);
 
-        DevelopmentSettings.initializeUpdateRecoveryOption();
+        DevelopmentSettings.initializeUpdateRecoveryOption(ctx);
     }
 
     private boolean hasRestoredTunable(Context context) {