summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Mok <kmok@cyngn.com>2016-06-16 09:42:06 -0700
committerMichael Bestas <mikeioannina@gmail.com>2017-01-04 22:00:43 +0200
commit6264a59334a262a59038466a9d6ab083dabd89da (patch)
tree086d688e261c8823487e99899386def83cacec59
parent1d91e536761468aa753c7be0d16313d5ff10da5e (diff)
downloadandroid_packages_apps_Snap-6264a59334a262a59038466a9d6ab083dabd89da.zip
android_packages_apps_Snap-6264a59334a262a59038466a9d6ab083dabd89da.tar.gz
android_packages_apps_Snap-6264a59334a262a59038466a9d6ab083dabd89da.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 ccf374e..29c5530 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -1317,10 +1317,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) {