summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriele M <moto.falcon.git@gmail.com>2016-02-17 10:03:37 +0100
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-02-17 12:55:53 -0800
commite7098d8412d6a8c59449b231240f36c6d8047af1 (patch)
treed17244fb646093c0955b66c994b0822967f60e45
parent2fbbd8cea84a49bedba77a90b75b65fd72423689 (diff)
downloadandroid_packages_apps_Snap-e7098d8412d6a8c59449b231240f36c6d8047af1.zip
android_packages_apps_Snap-e7098d8412d6a8c59449b231240f36c6d8047af1.tar.gz
android_packages_apps_Snap-e7098d8412d6a8c59449b231240f36c6d8047af1.tar.bz2
Snap: Don't crash if user saved preference is not valid
If the user sets some preference value that is later removed, Snap will crash because of on an ArrayIndexOutOfBoundsException. Make sure this doesn't happen. Change-Id: I629acebaf762f49f05dc1bfa0542f11979ae269d
-rw-r--r--src/com/android/camera/ListPreference.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java
index b856d46..1abda7c 100644
--- a/src/com/android/camera/ListPreference.java
+++ b/src/com/android/camera/ListPreference.java
@@ -151,11 +151,19 @@ public class ListPreference extends CameraPreference {
}
public String getEntry() {
- return mEntries[findIndexOfValue(getValue())].toString();
+ int index = findIndexOfValue(getValue());
+ if (index < 0) {
+ index = findIndexOfValue(findSupportedDefaultValue());
+ }
+ return mEntries[index].toString();
}
public String getLabel() {
- return mLabels[findIndexOfValue(getValue())].toString();
+ int index = findIndexOfValue(getValue());
+ if (index < 0) {
+ index = findIndexOfValue(findSupportedDefaultValue());
+ }
+ return mLabels[index].toString();
}
protected void persistStringValue(String value) {