Merge changes I6d66ae3c,Iacf2814b into lmp-dev

* changes:
  Handle out of index sip call options.
  Add back pressed behavior for emergency dialer.
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index e29d4c8..a8de874 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -38,6 +38,7 @@
 import android.text.method.DialerKeyListener;
 import android.util.Log;
 import android.view.KeyEvent;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityManager;
@@ -606,6 +607,16 @@
         }
     }
 
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        final int itemId = item.getItemId();
+        if (itemId == android.R.id.home) {
+            onBackPressed();
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
     /**
      * Update the enabledness of the "Dial" and "Backspace" buttons if applicable.
      */
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)