summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/settings/AppUpgrader.java
diff options
context:
space:
mode:
authorAlan Newberger <alann@google.com>2014-10-06 11:10:18 -0700
committerAlan Newberger <alann@google.com>2014-10-06 11:25:09 -0700
commit5381549fe58cd3c5a28dc18e2416c37d3c2d300b (patch)
treead8796f63f6df6d526fd52a86a31656f780236c3 /src/com/android/camera/settings/AppUpgrader.java
parent90672aa08379e598426c12b529a86afd4b61011e (diff)
downloadandroid_packages_apps_Camera2-5381549fe58cd3c5a28dc18e2416c37d3c2d300b.tar.gz
android_packages_apps_Camera2-5381549fe58cd3c5a28dc18e2416c37d3c2d300b.tar.bz2
android_packages_apps_Camera2-5381549fe58cd3c5a28dc18e2416c37d3c2d300b.zip
Re-run settings files migrations
Increment version number for upgrade and re-run copying. This will be a no-op for a first time glacier upgrader, copying runs in the same sequence for this case. For alpha users who hit crashes, this will re-run the copy, potentially overwriting some values but ensuring all values are valid. Tested both N4 and N5 upgrade scenarios that had previously seen issues, this addresses issues without the need to clear data. Bug: 17875895 Change-Id: I37c469c1b03151d03ee0d32ce0ba62983af32a36
Diffstat (limited to 'src/com/android/camera/settings/AppUpgrader.java')
-rw-r--r--src/com/android/camera/settings/AppUpgrader.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/com/android/camera/settings/AppUpgrader.java b/src/com/android/camera/settings/AppUpgrader.java
index 64dad6449..b3bb0db6d 100644
--- a/src/com/android/camera/settings/AppUpgrader.java
+++ b/src/com/android/camera/settings/AppUpgrader.java
@@ -60,8 +60,13 @@ public class AppUpgrader extends SettingsUpgrader {
/**
* With this version, the names of the files storing camera specific and
* module specific settings changed.
+ * <p>
+ * NOTE: changed this from 4 to 6 to re-run on latest Glacier upgrade.
+ * Initial upgraders to Glacier will run conversion once as of the change.
+ * When re-run for early dogfooders, values will get overwritten but will
+ * all work.
*/
- private static final int CAMERA_MODULE_SETTINGS_FILES_RENAMED_VERSION = 4;
+ private static final int CAMERA_MODULE_SETTINGS_FILES_RENAMED_VERSION = 6;
/**
* With this version, timelapse mode was removed and mode indices need to be
@@ -72,7 +77,7 @@ public class AppUpgrader extends SettingsUpgrader {
/**
* Increment this value whenever new AOSP UpgradeSteps need to be executed.
*/
- public static final int APP_UPGRADE_VERSION = 5;
+ public static final int APP_UPGRADE_VERSION = 6;
private final AppController mAppController;
@@ -322,6 +327,11 @@ public class AppUpgrader extends SettingsUpgrader {
* SharedPreferences file to another SharedPreferences file, as Strings.
* Settings that are not a known supported format (int/boolean/String)
* are dropped with warning.
+ *
+ * This will normally be run only once but was used both for upgrade version
+ * 4 and 6 -- in 6 we repair issues with previous runs of the upgrader. So
+ * we make sure to remove entries from destination if the source isn't valid
+ * like a null or unsupported type.
*/
private void copyPreferences(SharedPreferences oldPrefs,
SharedPreferences newPrefs) {
@@ -330,7 +340,8 @@ public class AppUpgrader extends SettingsUpgrader {
String key = entry.getKey();
Object value = entry.getValue();
if (value == null) {
- Log.w(TAG, "skipped upgrade for null key " + key);
+ Log.w(TAG, "skipped upgrade and removing entry for null key " + key);
+ newPrefs.edit().remove(key).apply();
} else if (value instanceof Boolean) {
String boolValue = SettingsManager.convert((Boolean) value);
newPrefs.edit().putString(key, boolValue).apply();
@@ -352,8 +363,9 @@ public class AppUpgrader extends SettingsUpgrader {
} else if (value instanceof String){
newPrefs.edit().putString(key, (String) value).apply();
} else {
- Log.w(TAG,"skipped upgrade for unrecognized key type " +
- key + " : " + value.getClass());
+ Log.w(TAG,"skipped upgrade and removing entry for unrecognized "
+ + "key type " + key + " : " + value.getClass());
+ newPrefs.edit().remove(key).apply();
}
}
}