summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2015-04-07 14:19:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-07 14:19:51 +0000
commitc701a20aedf33c7246b37aa1c0b8a12dc2193c7f (patch)
tree761616e4c39df586433d9ae27907dc8d90e17af8
parenta79c449515c160061d554642bc6a6fca8070c910 (diff)
parente06c34464e151ee0feddb9762319dc38909dcaa5 (diff)
downloadpackages_apps_Settings-c701a20aedf33c7246b37aa1c0b8a12dc2193c7f.zip
packages_apps_Settings-c701a20aedf33c7246b37aa1c0b8a12dc2193c7f.tar.gz
packages_apps_Settings-c701a20aedf33c7246b37aa1c0b8a12dc2193c7f.tar.bz2
Merge "Fix crash on rotation while ICE dialog is open"
-rw-r--r--src/com/android/settings/applications/DefaultEmergencyPreference.java68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/com/android/settings/applications/DefaultEmergencyPreference.java b/src/com/android/settings/applications/DefaultEmergencyPreference.java
index 08e6e94..1470f64 100644
--- a/src/com/android/settings/applications/DefaultEmergencyPreference.java
+++ b/src/com/android/settings/applications/DefaultEmergencyPreference.java
@@ -16,8 +16,6 @@
package com.android.settings.applications;
-import com.android.internal.util.ArrayUtils;
-
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -26,6 +24,8 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.AsyncTask;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.preference.ListPreference;
import android.provider.Settings;
import android.telephony.TelephonyManager;
@@ -50,6 +50,25 @@ public class DefaultEmergencyPreference extends ListPreference {
}
@Override
+ protected Parcelable onSaveInstanceState() {
+ Parcelable superState = super.onSaveInstanceState();
+ return new SavedState(getEntries(), getEntryValues(), getSummary(), superState);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Parcelable state) {
+ if (state instanceof SavedState) {
+ SavedState savedState = (SavedState) state;
+ setEntries(savedState.entries);
+ setEntryValues(savedState.entryValues);
+ setSummary(savedState.summary);
+ super.onRestoreInstanceState(savedState.superState);
+ } else {
+ super.onRestoreInstanceState(state);
+ }
+ }
+
+ @Override
protected boolean persistString(String value) {
String previousValue = Settings.Secure.getString(mContentResolver,
Settings.Secure.EMERGENCY_ASSISTANCE_APPLICATION);
@@ -134,4 +153,49 @@ public class DefaultEmergencyPreference extends ListPreference {
return info.applicationInfo != null
&& (info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
}
+
+ private static class SavedState implements Parcelable {
+
+ public final CharSequence[] entries;
+ public final CharSequence[] entryValues;
+ public final CharSequence summary;
+ public final Parcelable superState;
+
+ public SavedState(CharSequence[] entries, CharSequence[] entryValues,
+ CharSequence summary, Parcelable superState) {
+ this.entries = entries;
+ this.entryValues = entryValues;
+ this.summary = summary;
+ this.superState = superState;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeCharSequenceArray(entries);
+ dest.writeCharSequenceArray(entryValues);
+ dest.writeCharSequence(summary);
+ dest.writeParcelable(superState, flags);
+ }
+
+ public Creator<SavedState> CREATOR = new Creator<SavedState>() {
+ @Override
+ public SavedState createFromParcel(Parcel source) {
+ CharSequence[] entries = source.readCharSequenceArray();
+ CharSequence[] entryValues = source.readCharSequenceArray();
+ CharSequence summary = source.readCharSequence();
+ Parcelable superState = source.readParcelable(getClass().getClassLoader());
+ return new SavedState(entries, entryValues, summary, superState);
+ }
+
+ @Override
+ public SavedState[] newArray(int size) {
+ return new SavedState[size];
+ }
+ };
+ }
}