Handle out of index sip call options.
If the sip call option reported by sip shared preferences is not
found, force it to be SIP_ADDRESS_ONLY as a default.
I'm inferring that the trace in this bug happened because of an
invalid value set for the sip call option, so that it isn't
found as one of the possible values.
I'm supposing this could happen if a phone had the deprecated
SIP_ASK_ME_EACH_TIME value set (which is no longer a valid option).
Not positive if it's what's happening in this bug, but it seemed
like a reasonable case to safeguard against.
Bug: 17885832
Change-Id: I6d66ae3c4de7ccea38de3959a1f84cdfe2e114e1
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 97430b0..c48812c 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -105,8 +105,17 @@
? R.array.sip_call_options_wifi_only_entries
: R.array.sip_call_options_entries);
mUseSipCalling.setOnPreferenceChangeListener(this);
- mUseSipCalling.setValueIndex(
- mUseSipCalling.findIndexOfValue(mSipSharedPreferences.getSipCallOption()));
+
+ int optionsValueIndex =
+ mUseSipCalling.findIndexOfValue(mSipSharedPreferences.getSipCallOption());
+ if (optionsValueIndex == -1) {
+ // If the option is invalid (eg. deprecated value), default to SIP_ADDRESS_ONLY.
+ mSipSharedPreferences.setSipCallOption(
+ getResources().getString(R.string.sip_address_only));
+ optionsValueIndex =
+ mUseSipCalling.findIndexOfValue(mSipSharedPreferences.getSipCallOption());
+ }
+ mUseSipCalling.setValueIndex(optionsValueIndex);
mUseSipCalling.setSummary(mUseSipCalling.getEntry());
mSipReceiveCallsPreference = (CheckBoxPreference)