summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Mok <kmok@cyngn.com>2016-06-16 09:42:06 -0700
committerArne Coucheron <arco68@gmail.com>2018-01-26 01:09:01 +0100
commit13f44103a4122c67280929735172bb2173b899c5 (patch)
tree8cf06cf7c5b997db2362a9b87e86ed581a91ec3e
parent2f6cd94e4170fe6f297c87f7aa8823da326b3f10 (diff)
downloadandroid_packages_apps_Snap-13f44103a4122c67280929735172bb2173b899c5.zip
android_packages_apps_Snap-13f44103a4122c67280929735172bb2173b899c5.tar.gz
android_packages_apps_Snap-13f44103a4122c67280929735172bb2173b899c5.tar.bz2
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 ebab3fb..95baf3e 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1414,10 +1414,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) {