summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Mok <kmok@cyngn.com>2016-06-16 09:42:06 -0700
committerSteve Kondik <steve@cyngn.com>2016-11-20 02:09:24 -0800
commit99e47e69a6976091b3938993468fd65b9816ab01 (patch)
treee75757659bbdd2b04752e8bd6bcbfe0ef7ae8090
parent60d4b8189f6beead65ffd4974e444062664919d5 (diff)
downloadandroid_packages_apps_Snap-99e47e69a6976091b3938993468fd65b9816ab01.tar.gz
android_packages_apps_Snap-99e47e69a6976091b3938993468fd65b9816ab01.tar.bz2
android_packages_apps_Snap-99e47e69a6976091b3938993468fd65b9816ab01.zip
CameraNext: don't crash when pref is not boolean
In some situation, a portion of pref (enableRecordingLocation) is created without first calling upgradeGlobalPreference first. Leaving the pref without the version field and makes the application thinks that the pref is in old version. When it tries to do an upgrade on the pref later, it tries to getBoolean for that location field, but that location field is already in string format, making getBoolean throws an exception. The best is to call upgradeGlobalPreference and upgradeLocalPreference when the application starts. However it should be no harm just add a simple guard in getBoolean to avoid that sitation. FEIJ-1258 Change-Id: Ic73078556b1a198a58968806091f8b0afd1ad6cc
-rw-r--r--src/com/android/camera/CameraSettings.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index af8e6fee1..b85ffd363 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1313,10 +1313,14 @@ public class CameraSettings {
version = 2;
}
if (version == 2) {
- editor.putString(KEY_RECORD_LOCATION,
- pref.getBoolean(KEY_RECORD_LOCATION, false)
- ? RecordLocationPreference.VALUE_ON
- : RecordLocationPreference.VALUE_NONE);
+ try {
+ boolean value = pref.getBoolean(KEY_RECORD_LOCATION, false);
+ editor.putString(KEY_RECORD_LOCATION,
+ value ? RecordLocationPreference.VALUE_ON
+ : RecordLocationPreference.VALUE_NONE);
+ } catch (ClassCastException e) {
+ Log.e(TAG, "error convert record location", e);
+ }
version = 3;
}
if (version == 3) {