diff options
author | Brint E. Kriebel <bekit@cyngn.com> | 2014-05-21 14:39:45 -0700 |
---|---|---|
committer | Michael Bestas <mikeioannina@gmail.com> | 2015-12-12 07:21:50 -0800 |
commit | c5a412635a1101c6c4f97e07f97209c650edbd7d (patch) | |
tree | 9b4ed29a970f13a56f18573f299e5480484fe7ed | |
parent | 7591850311f9a5cc2d29a81b80f3ddc38ec4ca56 (diff) | |
download | packages_apps_Settings-c5a412635a1101c6c4f97e07f97209c650edbd7d.zip packages_apps_Settings-c5a412635a1101c6c4f97e07f97209c650edbd7d.tar.gz packages_apps_Settings-c5a412635a1101c6c4f97e07f97209c650edbd7d.tar.bz2 |
development: Add setting for updating recovery
When enabled, the recovery of the device will be updated with the
version of the installed system.
Change-Id: I519905341b9cba9c2ab09f5d9c6e88f4025a73a7
-rw-r--r-- | res/values/cm_strings.xml | 6 | ||||
-rw-r--r-- | res/xml/development_prefs.xml | 5 | ||||
-rw-r--r-- | src/com/android/settings/DevelopmentSettings.java | 62 |
3 files changed, 72 insertions, 1 deletions
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index bc89a31..6485eb2 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -60,6 +60,12 @@ <!-- CM Updater --> <string name="cmupdate_settings_title">CyanogenMod updates</string> + <!-- Settings switch for updating Cyanogen recovery --> + <string name="update_recovery_title">Update Cyanogen recovery</string> + <string name="update_recovery_summary">Update recovery with system updates</string> + <string name="update_recovery_on_warning">NOTICE: When this feature is enabled, your installed recovery will be replaced by one included with the current version of the running OS.\n\nYour recovery will be updated along with upgrades to your system, helping to ensure compatibility with future versions.\n\nWould you like to enable this feature?</string> + <string name="update_recovery_off_warning">WARNING: When this feature is disabled, your installed recovery will not be updated with OS upgrades.\n\nFuture OS updates may not install with outdated or custom recovery versions.\n\nDo you really want to disable this feature?</string> + <!-- Themes Settings --> <!-- Settings main menu entry --> <string name="themes_settings_title">Themes</string> diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml index 9a3b95e..8069d08 100644 --- a/res/xml/development_prefs.xml +++ b/res/xml/development_prefs.xml @@ -86,6 +86,11 @@ android:entries="@array/root_access_entries" android:entryValues="@array/root_access_values" /> + <SwitchPreference + android:key="update_recovery" + android:title="@string/update_recovery_title" + android:summary="@string/update_recovery_summary" /> + <com.android.settings.ColorModePreference android:key="color_mode" android:title="@string/picture_color_mode" diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java index e47138b..0d8b6a4 100644 --- a/src/com/android/settings/DevelopmentSettings.java +++ b/src/com/android/settings/DevelopmentSettings.java @@ -172,6 +172,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private static final String ROOT_ACCESS_KEY = "root_access"; private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access"; + private static final String UPDATE_RECOVERY_KEY = "update_recovery"; + private static final String UPDATE_RECOVERY_PROPERTY = "persist.sys.recovery_update"; + private static final String IMMEDIATELY_DESTROY_ACTIVITIES_KEY = "immediately_destroy_activities"; private static final String APP_PROCESS_LIMIT_KEY = "app_process_limit"; @@ -282,6 +285,8 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private SwitchPreference mAdvancedReboot; + private SwitchPreference mUpdateRecovery; + private SwitchPreference mDevelopmentShortcut; private final ArrayList<Preference> mAllPrefs = new ArrayList<Preference>(); @@ -298,6 +303,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment private Dialog mAdbKeysDialog; private boolean mUnavailable; private Dialog mRootDialog; + private Dialog mUpdateRecoveryDialog; @Override protected int getMetricsCategory() { @@ -360,7 +366,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mPassword = (PreferenceScreen) findPreference(LOCAL_BACKUP_PASSWORD); mAllPrefs.add(mPassword); mAdvancedReboot = findAndInitSwitchPref(ADVANCED_REBOOT_KEY); - + mUpdateRecovery = findAndInitSwitchPref(UPDATE_RECOVERY_KEY); mDevelopmentShortcut = findAndInitSwitchPref(DEVELOPMENT_SHORTCUT_KEY); @@ -370,6 +376,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment disableForUser(mEnableTerminal); disableForUser(mPassword); disableForUser(mAdvancedReboot); + disableForUser(mUpdateRecovery); disableForUser(mDevelopmentShortcut); } @@ -697,6 +704,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment updateRootAccessOptions(); updateAdvancedRebootOptions(); updateDevelopmentShortcutOptions(); + updateUpdateRecoveryOptions(); } private void writeAdvancedRebootOptions() { @@ -767,6 +775,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment writeLogdSizeOption(null); resetRootAccessOptions(); resetDevelopmentShortcutOptions(); + resetUpdateRecoveryOptions(); writeAnimationScaleOption(0, mWindowAnimationScale, null); writeAnimationScaleOption(1, mTransitionAnimationScale, null); writeAnimationScaleOption(2, mAnimatorDurationScale, null); @@ -1735,6 +1744,24 @@ public class DevelopmentSettings extends SettingsPreferenceFragment .show(); } + private void updateUpdateRecoveryOptions() { + updateSwitchPreference(mUpdateRecovery, SystemProperties.getBoolean( + UPDATE_RECOVERY_PROPERTY, false)); + } + + private void writeUpdateRecoveryOptions() { + SystemProperties.set(UPDATE_RECOVERY_PROPERTY, + mUpdateRecovery.isChecked() ? "true" : "false"); + pokeSystemProperties(); + } + + private void resetUpdateRecoveryOptions() { + // User builds should update recovery by default + if ("user".equals(Build.TYPE)) { + SystemProperties.set(UPDATE_RECOVERY_PROPERTY, "true"); + } + } + @Override public void onSwitchChanged(Switch switchView, boolean isChecked) { if (switchView != mSwitchBar.getSwitch()) { @@ -1942,6 +1969,28 @@ public class DevelopmentSettings extends SettingsPreferenceFragment writeDevelopmentShortcutOptions(); } else if (preference == mKillAppLongpressBack) { writeKillAppLongpressBackOptions(); + } else if (preference == mUpdateRecovery) { + if (mSwitchBar.isChecked()) { + if (mUpdateRecoveryDialog != null) { + dismissDialogs(); + } + if (mUpdateRecovery.isChecked()) { + mUpdateRecoveryDialog = new AlertDialog.Builder(getActivity()).setMessage( + getResources().getString(R.string.update_recovery_on_warning)) + .setTitle(R.string.update_recovery_title) + .setPositiveButton(android.R.string.yes, this) + .setNegativeButton(android.R.string.no, this) + .show(); + } else { + mUpdateRecoveryDialog = new AlertDialog.Builder(getActivity()).setMessage( + getResources().getString(R.string.update_recovery_off_warning)) + .setTitle(R.string.update_recovery_title) + .setPositiveButton(android.R.string.yes, this) + .setNegativeButton(android.R.string.no, this) + .show(); + } + mUpdateRecoveryDialog.setOnDismissListener(this); + } } else { return super.onPreferenceTreeClick(preferenceScreen, preference); } @@ -2049,6 +2098,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment mRootDialog.dismiss(); mRootDialog = null; } + if (mUpdateRecoveryDialog != null) { + mUpdateRecoveryDialog.dismiss(); + mUpdateRecoveryDialog = null; + } } public void onClick(DialogInterface dialog, int which) { @@ -2098,6 +2151,10 @@ public class DevelopmentSettings extends SettingsPreferenceFragment // Reset the option writeRootAccessOptions("0"); } + } else if (dialog == mUpdateRecoveryDialog) { + if (which == DialogInterface.BUTTON_POSITIVE) { + writeUpdateRecoveryOptions(); + } } } @@ -2119,6 +2176,9 @@ public class DevelopmentSettings extends SettingsPreferenceFragment } else if (dialog == mRootDialog) { updateRootAccessOptions(); mRootDialog = null; + } else if (dialog == mUpdateRecoveryDialog) { + updateUpdateRecoveryOptions(); + mUpdateRecoveryDialog = null; } } |