summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/camera/settings/AppUpgrader.java37
-rw-r--r--src/com/android/camera/settings/SettingsManager.java26
-rw-r--r--src/com/android/camera/widget/IndicatorIconController.java2
3 files changed, 51 insertions, 14 deletions
diff --git a/src/com/android/camera/settings/AppUpgrader.java b/src/com/android/camera/settings/AppUpgrader.java
index bb15d38dd..64dad6449 100644
--- a/src/com/android/camera/settings/AppUpgrader.java
+++ b/src/com/android/camera/settings/AppUpgrader.java
@@ -209,14 +209,6 @@ public class AppUpgrader extends SettingsUpgrader {
}
}
- // Request return to HDR+: boolean -> String, from module.
- if (defaultPreferences.contains(Keys.KEY_REQUEST_RETURN_HDR_PLUS)) {
- boolean requestReturnHdrPlus = removeBoolean(defaultPreferences,
- Keys.KEY_REQUEST_RETURN_HDR_PLUS);
- settingsManager.set(SettingsManager.SCOPE_GLOBAL, Keys.KEY_REQUEST_RETURN_HDR_PLUS,
- requestReturnHdrPlus);
- }
-
// Should show refocus viewer cling: boolean -> String, from default.
if (defaultPreferences.contains(Keys.KEY_SHOULD_SHOW_REFOCUS_VIEWER_CLING)) {
boolean shouldShowRefocusViewer = removeBoolean(defaultPreferences,
@@ -328,6 +320,8 @@ public class AppUpgrader extends SettingsUpgrader {
/**
* Part of the AOSP upgrade path, copies all of the keys and values in a
* SharedPreferences file to another SharedPreferences file, as Strings.
+ * Settings that are not a known supported format (int/boolean/String)
+ * are dropped with warning.
*/
private void copyPreferences(SharedPreferences oldPrefs,
SharedPreferences newPrefs) {
@@ -335,10 +329,31 @@ public class AppUpgrader extends SettingsUpgrader {
for (Map.Entry<String, ?> entry : entries.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
- if (value != null) {
- newPrefs.edit().putString(key, String.valueOf(value)).apply();
- } else {
+ if (value == null) {
Log.w(TAG, "skipped upgrade for null key " + key);
+ } else if (value instanceof Boolean) {
+ String boolValue = SettingsManager.convert((Boolean) value);
+ newPrefs.edit().putString(key, boolValue).apply();
+ } else if (value instanceof Integer) {
+ String intValue = SettingsManager.convert((Integer) value);
+ newPrefs.edit().putString(key, intValue).apply();
+ } else if (value instanceof Long){
+ // New SettingsManager only supports int values. Attempt to
+ // recover any longs which happen to be present if they are
+ // within int range.
+ long longValue = (Long) value;
+ if (longValue <= Integer.MAX_VALUE && longValue >= Integer.MIN_VALUE) {
+ String intValue = SettingsManager.convert((int) longValue);
+ newPrefs.edit().putString(key, intValue).apply();
+ } else {
+ Log.w(TAG, "skipped upgrade for out of bounds long key " +
+ key + " : " + longValue);
+ }
+ } 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());
}
}
}
diff --git a/src/com/android/camera/settings/SettingsManager.java b/src/com/android/camera/settings/SettingsManager.java
index 2418882d6..297bacbae 100644
--- a/src/com/android/camera/settings/SettingsManager.java
+++ b/src/com/android/camera/settings/SettingsManager.java
@@ -433,7 +433,7 @@ public class SettingsManager {
* to String occurs before this value is stored in SharedPreferences.
*/
public void set(String scope, String key, int value) {
- set(scope, key, Integer.toString(value));
+ set(scope, key, convert(value));
}
/**
@@ -442,7 +442,7 @@ public class SettingsManager {
* stored in SharedPreferences.
*/
public void set(String scope, String key, boolean value) {
- set(scope, key, value ? "1" : "0");
+ set(scope, key, convert(value));
}
/**
@@ -504,4 +504,26 @@ public class SettingsManager {
SharedPreferences preferences = getPreferencesFromScope(scope);
preferences.edit().remove(key).apply();
}
+
+ /**
+ * Package private conversion method to turn ints into preferred
+ * String storage format.
+ *
+ * @param value int to be stored in Settings
+ * @return String which represents the int
+ */
+ static String convert(int value) {
+ return Integer.toString(value);
+ }
+
+ /**
+ * Package private conversion method to turn booleans into preferred
+ * String storage format.
+ *
+ * @param value boolean to be stored in Settings
+ * @return String which represents the boolean
+ */
+ static String convert(boolean value) {
+ return value ? "1" : "0";
+ }
}
diff --git a/src/com/android/camera/widget/IndicatorIconController.java b/src/com/android/camera/widget/IndicatorIconController.java
index e99bfe438..2ba1398ae 100644
--- a/src/com/android/camera/widget/IndicatorIconController.java
+++ b/src/com/android/camera/widget/IndicatorIconController.java
@@ -206,7 +206,7 @@ public class IndicatorIconController
} else if (buttonManager.isEnabled(ButtonManager.BUTTON_HDR)
&& buttonManager.isVisible(ButtonManager.BUTTON_HDR)) {
setIndicatorState(SettingsManager.SCOPE_GLOBAL,
- Keys.KEY_CAMERA_HDR_PLUS, mHdrIndicator,
+ Keys.KEY_CAMERA_HDR, mHdrIndicator,
mHdrIndicatorIcons, false);
} else {
changeVisibility(mHdrIndicator, View.GONE);