summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/DevelopmentSettings.java
diff options
context:
space:
mode:
authorBrint E. Kriebel <bekit@cyngn.com>2014-05-21 14:39:45 -0700
committerMichael Bestas <mikeioannina@gmail.com>2015-12-12 07:21:50 -0800
commitc5a412635a1101c6c4f97e07f97209c650edbd7d (patch)
tree9b4ed29a970f13a56f18573f299e5480484fe7ed /src/com/android/settings/DevelopmentSettings.java
parent7591850311f9a5cc2d29a81b80f3ddc38ec4ca56 (diff)
downloadpackages_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
Diffstat (limited to 'src/com/android/settings/DevelopmentSettings.java')
-rw-r--r--src/com/android/settings/DevelopmentSettings.java62
1 files changed, 61 insertions, 1 deletions
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;
}
}