Merge "Disable disconnect/separate for connections which were ever IMS." into lmp-mr1-dev
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 498b632..1383a62 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -191,7 +191,7 @@
         <item name="android:colorPrimaryDark">@color/network_operators_color_primary_dark</item>
     </style>
 
-    <style name="Empty" parent="@android:style/Theme.Holo">
+    <style name="Empty" parent="@android:style/Theme.Material.Light">
         <item name="android:windowIsTranslucent">true</item>
         <item name="android:windowBackground">@android:color/transparent</item>
         <item name="android:windowContentOverlay">@null</item>
@@ -227,16 +227,6 @@
         <item name="*android:taskOpenExitAnimation">@*android:anim/activity_open_exit</item>
     </style>
 
-    <!-- Theme for the InCallScreen activity.  This gives us a totally black
-         window background instead of the default dark grey.  (We don't just use
-         Theme.Black.NoTitleBar directly, since we want any popups or dialogs
-         from the InCallScreen to have the correct holo style. -->
-    <style name="Theme.InCallScreen" parent="@android:style/Theme.Holo.NoActionBar">
-        <item name="android:windowBackground">@android:color/black</item>
-
-        <item name="*android:windowAnimationStyle">@style/InCallAnimationStyle</item>
-    </style>
-
     <!-- Style for the call settings action bar.  Should be kept in sync with Dialer. -->
     <style name="DialtactsActionBarStyle" parent="@style/TelephonyActionBarStyle">
         <!-- Shift the title text to the right -->
diff --git a/sip/src/com/android/services/telephony/sip/SipEditor.java b/sip/src/com/android/services/telephony/sip/SipEditor.java
index 5a21fe8..ba06711 100644
--- a/sip/src/com/android/services/telephony/sip/SipEditor.java
+++ b/sip/src/com/android/services/telephony/sip/SipEditor.java
@@ -221,6 +221,10 @@
                 setRemovedProfileAndFinish();
                 return true;
             }
+            case android.R.id.home: {
+                finish();
+                return true;
+            }
         }
         return super.onOptionsItemSelected(item);
     }
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index c38df5c..6fae770 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1547,12 +1547,10 @@
 
         // get buttons
         PreferenceScreen prefSet = getPreferenceScreen();
-        mSubMenuVoicemailSettings = (EditPhoneNumberPreference)findPreference(BUTTON_VOICEMAIL_KEY);
-        if (mSubMenuVoicemailSettings != null) {
-            mSubMenuVoicemailSettings.setParentActivity(this, VOICEMAIL_PREF_ID, this);
-            mSubMenuVoicemailSettings.setDialogOnClosedListener(this);
-            mSubMenuVoicemailSettings.setDialogTitle(R.string.voicemail_settings_number_label);
-        }
+        mSubMenuVoicemailSettings = (EditPhoneNumberPreference) findPreference(BUTTON_VOICEMAIL_KEY);
+        mSubMenuVoicemailSettings.setParentActivity(this, VOICEMAIL_PREF_ID, this);
+        mSubMenuVoicemailSettings.setDialogOnClosedListener(this);
+        mSubMenuVoicemailSettings.setDialogTitle(R.string.voicemail_settings_number_label);
 
         mButtonDTMF = (ListPreference) findPreference(BUTTON_DTMF_KEY);
         mButtonAutoRetry = (CheckBoxPreference) findPreference(BUTTON_RETRY_KEY);
@@ -1573,42 +1571,46 @@
         }
 
 
-        if (mButtonDTMF != null) {
-            if (getResources().getBoolean(R.bool.dtmf_type_enabled)) {
-                mButtonDTMF.setOnPreferenceChangeListener(this);
-            } else {
-                prefSet.removePreference(mButtonDTMF);
-                mButtonDTMF = null;
-            }
+        if (getResources().getBoolean(R.bool.dtmf_type_enabled)) {
+            mButtonDTMF.setOnPreferenceChangeListener(this);
+            int dtmf = Settings.System.getInt(getContentResolver(),
+                    Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, Constants.DTMF_TONE_TYPE_NORMAL);
+            mButtonDTMF.setValueIndex(dtmf);
+        } else {
+            prefSet.removePreference(mButtonDTMF);
+            mButtonDTMF = null;
         }
 
-        if (mButtonAutoRetry != null) {
-            if (getResources().getBoolean(R.bool.auto_retry_enabled)) {
-                mButtonAutoRetry.setOnPreferenceChangeListener(this);
-            } else {
-                prefSet.removePreference(mButtonAutoRetry);
-                mButtonAutoRetry = null;
-            }
+        if (getResources().getBoolean(R.bool.auto_retry_enabled)) {
+            mButtonAutoRetry.setOnPreferenceChangeListener(this);
+            int autoretry = Settings.Global.getInt(
+                    getContentResolver(), Settings.Global.CALL_AUTO_RETRY, 0);
+            mButtonAutoRetry.setChecked(autoretry != 0);
+        } else {
+            prefSet.removePreference(mButtonAutoRetry);
+            mButtonAutoRetry = null;
         }
 
-        if (mButtonHAC != null) {
-            if (getResources().getBoolean(R.bool.hac_enabled)) {
-
-                mButtonHAC.setOnPreferenceChangeListener(this);
-            } else {
-                prefSet.removePreference(mButtonHAC);
-                mButtonHAC = null;
-            }
+        if (getResources().getBoolean(R.bool.hac_enabled)) {
+            mButtonHAC.setOnPreferenceChangeListener(this);
+            int hac = Settings.System.getInt(getContentResolver(), Settings.System.HEARING_AID, 0);
+            mButtonHAC.setChecked(hac != 0);
+        } else {
+            prefSet.removePreference(mButtonHAC);
+            mButtonHAC = null;
         }
 
-        if (mButtonTTY != null) {
-            TelecomManager telecomManager = TelecomManager.from(this);
-            if (telecomManager != null && telecomManager.isTtySupported()) {
-                mButtonTTY.setOnPreferenceChangeListener(this);
-            } else {
-                prefSet.removePreference(mButtonTTY);
-                mButtonTTY = null;
-            }
+        TelecomManager telecomManager = TelecomManager.from(this);
+        if (telecomManager != null && telecomManager.isTtySupported()) {
+            mButtonTTY.setOnPreferenceChangeListener(this);
+            int settingsTtyMode = Settings.Secure.getInt(getContentResolver(),
+                    Settings.Secure.PREFERRED_TTY_MODE,
+                    TelecomManager.TTY_MODE_OFF);
+            mButtonTTY.setValue(Integer.toString(settingsTtyMode));
+            updatePreferredTtyModeSummary(settingsTtyMode);
+        } else {
+            prefSet.removePreference(mButtonTTY);
+            mButtonTTY = null;
         }
 
         if (!getResources().getBoolean(R.bool.world_phone)) {
@@ -1661,31 +1663,6 @@
         updateVoiceNumberField();
         mVMProviderSettingsForced = false;
 
-        if (mButtonDTMF != null) {
-            int dtmf = Settings.System.getInt(getContentResolver(),
-                    Settings.System.DTMF_TONE_TYPE_WHEN_DIALING, Constants.DTMF_TONE_TYPE_NORMAL);
-            mButtonDTMF.setValueIndex(dtmf);
-        }
-
-        if (mButtonAutoRetry != null) {
-            int autoretry = Settings.Global.getInt(getContentResolver(),
-                    Settings.Global.CALL_AUTO_RETRY, 0);
-            mButtonAutoRetry.setChecked(autoretry != 0);
-        }
-
-        if (mButtonHAC != null) {
-            int hac = Settings.System.getInt(getContentResolver(), Settings.System.HEARING_AID, 0);
-            mButtonHAC.setChecked(hac != 0);
-        }
-
-        if (mButtonTTY != null) {
-            int settingsTtyMode = Settings.Secure.getInt(getContentResolver(),
-                    Settings.Secure.PREFERRED_TTY_MODE,
-                    TelecomManager.TTY_MODE_OFF);
-            mButtonTTY.setValue(Integer.toString(settingsTtyMode));
-            updatePreferredTtyModeSummary(settingsTtyMode);
-        }
-
         SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(
                 mPhone.getContext());
         if (migrateVoicemailVibrationSettingsIfNeeded(prefs)) {
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index a8de874..eb74956 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -524,14 +524,12 @@
             intent.setData(Uri.fromParts(PhoneAccount.SCHEME_TEL, mLastNumber, null));
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             startActivity(intent);
-            finish();
         } else {
             if (DBG) Log.d(LOG_TAG, "rejecting bad requested number " + mLastNumber);
 
-            // erase the number and throw up an alert dialog.
-            mDigits.getText().delete(0, mDigits.getText().length());
             showDialog(BAD_EMERGENCY_NUMBER_DIALOG);
         }
+        mDigits.getText().delete(0, mDigits.getText().length());
     }
 
     /**
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 20134ba..07c9d73 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -196,10 +196,10 @@
     }
 
     private void setIMS(boolean turnOn) {
-        SharedPreferences imsPref =
-            getSharedPreferences(ImsManager.IMS_SHARED_PREFERENCES, Context.MODE_WORLD_READABLE);
-
-        imsPref.edit().putBoolean(ImsManager.KEY_IMS_ON, turnOn).commit();
+        int value = (turnOn) ? 1:0;
+        android.provider.Settings.Global.putInt(
+                  mPhone.getContext().getContentResolver(),
+                  android.provider.Settings.Global.VOLTE_VT_ENABLED, value);
     }
 
     @Override
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 56d26c9..b3d64db 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -117,6 +117,13 @@
     /** Noise suppression status as selected by user */
     private static boolean sIsNoiseSuppressionEnabled = true;
 
+    /**
+     * Theme to use for dialogs displayed by utility methods in this class. This is needed
+     * because these dialogs are displayed using the application context, which does not resolve
+     * the dialog theme correctly.
+     */
+    private static final int THEME = AlertDialog.THEME_DEVICE_DEFAULT_LIGHT;
+
     private static class FgRingCalls {
         private Call fgCall;
         private Call ringing;
@@ -955,7 +962,7 @@
                 // places the message at the forefront of the UI.
 
                 if (sUssdDialog == null) {
-                    sUssdDialog = new AlertDialog.Builder(context)
+                    sUssdDialog = new AlertDialog.Builder(context, THEME)
                             .setPositiveButton(R.string.ok, null)
                             .setCancelable(true)
                             .setOnDismissListener(new DialogInterface.OnDismissListener() {
@@ -1045,7 +1052,7 @@
                     };
 
                 // build the dialog
-                final AlertDialog newDialog = new AlertDialog.Builder(context)
+                final AlertDialog newDialog = new AlertDialog.Builder(context, THEME)
                         .setMessage(text)
                         .setView(dialogView)
                         .setPositiveButton(R.string.send_button, mUSSDDialogListener)
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index bbd65cc..b337622 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -256,9 +256,7 @@
                 new ComponentName(phone.getContext(), TelephonyConnectionService.class);
         // TODO: Should use some sort of special hidden flag to decorate this account as
         // an emergency-only account
-        TelecomManager telecomManager = TelecomManager.from(phone.getContext());
-        String id = isEmergency ?
-            "E" : prefix + telecomManager.getPhoneAccountIdForSubscriptionId(phone.getSubId());
+        String id = isEmergency ? "E" : prefix + String.valueOf(phone.getSubId());
         return new PhoneAccountHandle(pstnConnectionServiceName, id);
     }