Merge "pre-SLC indicators are incorrect for BT on during call" into lmp-dev
diff --git a/res/drawable-hdpi/ic_emergency_callback_mode.png b/res/drawable-hdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..1902e72
--- /dev/null
+++ b/res/drawable-hdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-hdpi/picture_emergency25x25.png b/res/drawable-hdpi/picture_emergency25x25.png
deleted file mode 100644
index 0a6d3c4..0000000
--- a/res/drawable-hdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-hdpi/picture_emergency32x32.png b/res/drawable-hdpi/picture_emergency32x32.png
deleted file mode 100644
index 89c05e3..0000000
--- a/res/drawable-hdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..0c796b5
--- /dev/null
+++ b/res/drawable-ldrtl-hdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/picture_emergency25x25.png b/res/drawable-ldrtl-hdpi/picture_emergency25x25.png
deleted file mode 100644
index 9a70b6d..0000000
--- a/res/drawable-ldrtl-hdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-hdpi/picture_emergency32x32.png b/res/drawable-ldrtl-hdpi/picture_emergency32x32.png
deleted file mode 100644
index 89e1b07..0000000
--- a/res/drawable-ldrtl-hdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..1507310
--- /dev/null
+++ b/res/drawable-ldrtl-mdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/picture_emergency25x25.png b/res/drawable-ldrtl-mdpi/picture_emergency25x25.png
deleted file mode 100644
index 9a70b6d..0000000
--- a/res/drawable-ldrtl-mdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-mdpi/picture_emergency32x32.png b/res/drawable-ldrtl-mdpi/picture_emergency32x32.png
deleted file mode 100644
index 89e1b07..0000000
--- a/res/drawable-ldrtl-mdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..7c2f9f1
--- /dev/null
+++ b/res/drawable-ldrtl-xhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png b/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png
deleted file mode 100644
index e4b9342..0000000
--- a/res/drawable-ldrtl-xhdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png b/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png
deleted file mode 100644
index ddc2642..0000000
--- a/res/drawable-ldrtl-xhdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..c08186b
--- /dev/null
+++ b/res/drawable-ldrtl-xxhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png b/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..9487cf4
--- /dev/null
+++ b/res/drawable-ldrtl-xxxhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_emergency_callback_mode.png b/res/drawable-mdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..d4e5f5d
--- /dev/null
+++ b/res/drawable-mdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-mdpi/picture_emergency25x25.png b/res/drawable-mdpi/picture_emergency25x25.png
deleted file mode 100644
index 0a6d3c4..0000000
--- a/res/drawable-mdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/picture_emergency32x32.png b/res/drawable-mdpi/picture_emergency32x32.png
deleted file mode 100644
index 89c05e3..0000000
--- a/res/drawable-mdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_emergency_callback_mode.png b/res/drawable-xhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..cde9cea
--- /dev/null
+++ b/res/drawable-xhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-xhdpi/picture_emergency25x25.png b/res/drawable-xhdpi/picture_emergency25x25.png
deleted file mode 100644
index 1284dcc..0000000
--- a/res/drawable-xhdpi/picture_emergency25x25.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/picture_emergency32x32.png b/res/drawable-xhdpi/picture_emergency32x32.png
deleted file mode 100644
index 75fdec2..0000000
--- a/res/drawable-xhdpi/picture_emergency32x32.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_emergency_callback_mode.png b/res/drawable-xxhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..b761bc4
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_emergency_callback_mode.png b/res/drawable-xxxhdpi/ic_emergency_callback_mode.png
new file mode 100644
index 0000000..0e71cf0
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_emergency_callback_mode.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_multi_sim.png b/res/drawable-xxxhdpi/ic_multi_sim.png
new file mode 100644
index 0000000..f888ed1
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_multi_sim.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_multi_sim1.png b/res/drawable-xxxhdpi/ic_multi_sim1.png
new file mode 100644
index 0000000..a4ebf5c
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_multi_sim1.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_multi_sim2.png b/res/drawable-xxxhdpi/ic_multi_sim2.png
new file mode 100644
index 0000000..5835784
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_multi_sim2.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_multi_sim3.png b/res/drawable-xxxhdpi/ic_multi_sim3.png
new file mode 100644
index 0000000..cc9ef41
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_multi_sim3.png
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_multi_sim4.png b/res/drawable-xxxhdpi/ic_multi_sim4.png
new file mode 100644
index 0000000..49f2c09
--- /dev/null
+++ b/res/drawable-xxxhdpi/ic_multi_sim4.png
Binary files differ
diff --git a/res/values/config.xml b/res/values/config.xml
index cfca00b..914add0 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -138,11 +138,6 @@
     <string name="carrier_settings" translatable="false"></string>
     <string name="carrier_settings_menu" translatable="false"></string>
 
-    <!-- Default connection service setting.
-         TODO: This is GSM specific. Need to define a generic "use the builtin SIMs" Connection
-         Service and use it as the default. -->
-    <string name="connection_service_default" translatable="false">com.android.phone/com.android.services.telephony.TelephonyConnectionService</string>
-
     <!-- Does not display additional call seting for IMS phone based on GSM Phone -->
     <bool name="config_additional_call_setting">true</bool>
 </resources>
diff --git a/sip/src/com/android/services/telephony/sip/SipUtil.java b/sip/src/com/android/services/telephony/sip/SipUtil.java
index 3d1be3d..5733a18 100644
--- a/sip/src/com/android/services/telephony/sip/SipUtil.java
+++ b/sip/src/com/android/services/telephony/sip/SipUtil.java
@@ -64,7 +64,7 @@
         TelecommManager manager = (TelecommManager) context.getSystemService(
                 Context.TELECOMM_SERVICE);
         if (manager != null) {
-            return !manager.isInAPhoneCall();
+            return !manager.isInCall();
         }
         return true;
     }
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 103606a..aa01862 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -160,7 +160,6 @@
 
     // String keys for preference lookup
     // TODO: Naming these "BUTTON_*" is confusing since they're not actually buttons(!)
-    private static final String BUTTON_DEFAULT_CONNECTION_SERVICE = "button_connection_service";
     private static final String BUTTON_VOICEMAIL_KEY = "button_voicemail_key";
     private static final String BUTTON_VOICEMAIL_PROVIDER_KEY = "button_voicemail_provider_key";
     private static final String BUTTON_VOICEMAIL_SETTING_KEY = "button_voicemail_setting_key";
@@ -261,14 +260,11 @@
     private ListPreference mButtonSipCallOptions;
     private Preference mWifiCallOptionsPreference;
     private Preference mWifiCallAccountPreference;
-    private ListPreference mConnectionService;
     private ListPreference mVoicemailProviders;
     private PreferenceScreen mVoicemailSettings;
     private Preference mVoicemailNotificationRingtone;
     private CheckBoxPreference mVoicemailNotificationVibrate;
     private SipSharedPreferences mSipSharedPreferences;
-    private final Map<String, CharSequence> mConnectionServiceLabelByComponentName =
-            new HashMap<>();
 
     private class VoiceMailProvider {
         public VoiceMailProvider(String name, Intent intent) {
@@ -576,8 +572,6 @@
             }
         } else if (preference == mButtonSipCallOptions) {
             handleSipCallOptionsChange(objValue);
-        } else if (preference == mConnectionService) {
-            updateConnectionServiceSummary((String) objValue);
         }
         // always let the preference setting proceed.
         return true;
@@ -1515,8 +1509,6 @@
         mButtonAutoRetry = (CheckBoxPreference) findPreference(BUTTON_RETRY_KEY);
         mButtonHAC = (CheckBoxPreference) findPreference(BUTTON_HAC_KEY);
         mButtonTTY = (ListPreference) findPreference(BUTTON_TTY_KEY);
-        mConnectionService = (ListPreference)
-                findPreference(BUTTON_DEFAULT_CONNECTION_SERVICE);
         mVoicemailProviders = (ListPreference) findPreference(BUTTON_VOICEMAIL_PROVIDER_KEY);
 
         if (mVoicemailProviders != null) {
@@ -1646,12 +1638,6 @@
             actionBar.setDisplayHomeAsUpEnabled(true);
             actionBar.setDisplayShowTitleEnabled(true);
         }
-
-        if (mConnectionService != null) {
-            mConnectionService.setOnPreferenceChangeListener(this);
-            setupConnectionServiceOptions();
-            updateConnectionServiceSummary(null);
-        }
     }
 
     private void createSipCallSettings() {
@@ -2106,66 +2092,6 @@
         return super.onOptionsItemSelected(item);
     }
 
-    private void setupConnectionServiceOptions() {
-        loadConnectionServiceEntries();
-        String[] entryValues = new String[mConnectionServiceLabelByComponentName.size()];
-        CharSequence[] entries = new CharSequence[mConnectionServiceLabelByComponentName.size()];
-        int i = 0;
-        for (String entryValue : mConnectionServiceLabelByComponentName.keySet()) {
-            entryValues[i] = entryValue;
-            entries[i] = mConnectionServiceLabelByComponentName.get(entryValue);
-            i++;
-        }
-        mConnectionService.setEntryValues(entryValues);
-        mConnectionService.setEntries(entries);
-
-        if (mConnectionService.getValue() == null) {
-            mConnectionService.setValue(getString(R.string.connection_service_default));
-        }
-    }
-
-    private void updateConnectionServiceSummary(String value) {
-        CharSequence label = mConnectionServiceLabelByComponentName.get(
-                value == null ? mConnectionService.getValue() : value);
-        if (label == null) {
-            Log.w(LOG_TAG, "Unknown default connection service entry " +
-                    mConnectionService.getValue());
-            mConnectionService.setSummary("");
-        }
-        mConnectionService.setSummary(label);
-    }
-
-    private void loadConnectionServiceEntries() {
-        Intent intent = new Intent(ConnectionService.SERVICE_INTERFACE);
-        for (ResolveInfo entry : getPackageManager().queryIntentServices(intent, 0)) {
-            ServiceInfo serviceInfo = entry.serviceInfo;
-            if (serviceInfo != null) {
-                // The entry resolves to a proper service, add it to the list of service names
-                ComponentName componentName =
-                        new ComponentName(serviceInfo.packageName, serviceInfo.name);
-                mConnectionServiceLabelByComponentName.put(
-                        componentName.flattenToString(),
-                        serviceInfo.loadLabel(getPackageManager()));
-            }
-        }
-
-        // If the default built-in ConnectionService is not installed, according to the package
-        // manager, then in a newly initialized system, Telecomm is going to read the preference
-        // and find the service to be nonexistent. Telecomm should have error checking for this
-        // case, but it is problematic and it's hard to program around it. Here we simply pretend
-        // like the built-in default is installed anyway (so the default value defined in the XML
-        // for the ListPreference points to something useful and does not throw an NPE) and proceed.
-        String connectionServiceDefault = getString(R.string.connection_service_default);
-        if (!mConnectionServiceLabelByComponentName.containsKey(connectionServiceDefault)) {
-            Log.w(LOG_TAG, "Package manager reports built-in ConnectionService not installed: "
-                    + connectionServiceDefault);
-        } else {
-            mConnectionServiceLabelByComponentName.put(
-                    connectionServiceDefault,
-                    getString(R.string.connection_service_default_label));
-        }
-    }
-
     /**
      * Finish current Activity and go up to the top level Settings ({@link CallFeaturesSetting}).
      * This is useful for implementing "HomeAsUp" capability for second-level Settings.
diff --git a/src/com/android/phone/EmergencyCallbackModeExitDialog.java b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
index 7758b23..921b7f7 100644
--- a/src/com/android/phone/EmergencyCallbackModeExitDialog.java
+++ b/src/com/android/phone/EmergencyCallbackModeExitDialog.java
@@ -205,7 +205,7 @@
         case EXIT_ECM_DIALOG:
             CharSequence text = getDialogText(mEcmTimeout);
             mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
-                    .setIcon(R.drawable.picture_emergency32x32)
+                    .setIcon(R.drawable.ic_emergency_callback_mode)
                     .setTitle(R.string.phone_in_ecm_notification_title)
                     .setMessage(text)
                     .setPositiveButton(R.string.alert_dialog_yes,
@@ -233,7 +233,7 @@
 
         case EXIT_ECM_IN_EMERGENCY_CALL_DIALOG:
             mAlertDialog = new AlertDialog.Builder(EmergencyCallbackModeExitDialog.this)
-                    .setIcon(R.drawable.picture_emergency32x32)
+                    .setIcon(R.drawable.ic_emergency_callback_mode)
                     .setTitle(R.string.phone_in_ecm_notification_title)
                     .setMessage(R.string.alert_dialog_in_ecm_call)
                     .setNeutralButton(R.string.alert_dialog_dismiss,
diff --git a/src/com/android/phone/EmergencyCallbackModeService.java b/src/com/android/phone/EmergencyCallbackModeService.java
index 5309eaf..e1f7fb3 100644
--- a/src/com/android/phone/EmergencyCallbackModeService.java
+++ b/src/com/android/phone/EmergencyCallbackModeService.java
@@ -25,6 +25,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Resources;
+import android.graphics.BitmapFactory;
 import android.os.AsyncResult;
 import android.os.Binder;
 import android.os.CountDownTimer;
@@ -163,16 +164,19 @@
      * Shows notification for Emergency Callback Mode
      */
     private void showNotification(long millisUntilFinished) {
-
-        // Set the icon and text
-        Notification notification = new Notification(
-                R.drawable.picture_emergency25x25,
-                getText(R.string.phone_entered_ecm_text), 0);
+        final Notification.Builder builder = new Notification.Builder(getApplicationContext());
+        builder.setOngoing(true);
+        builder.setPriority(Notification.PRIORITY_HIGH);
+        builder.setSmallIcon(R.drawable.ic_emergency_callback_mode);
+        builder.setTicker(getText(R.string.phone_entered_ecm_text));
+        builder.setContentTitle(getText(R.string.phone_in_ecm_notification_title));
+        builder.setColor(getResources().getColor(R.color.dialer_theme_color));
 
         // PendingIntent to launch Emergency Callback Mode Exit activity if the user selects
         // this notification
         PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                 new Intent(EmergencyCallbackModeExitDialog.ACTION_SHOW_ECM_EXIT_DIALOG), 0);
+        builder.setContentIntent(contentIntent);
 
         // Format notification string
         String text = null;
@@ -184,14 +188,10 @@
             text = String.format(getResources().getQuantityText(
                      R.plurals.phone_in_ecm_notification_time, minutes).toString(), time);
         }
-        // Set the info in the notification
-        notification.setLatestEventInfo(this, getText(R.string.phone_in_ecm_notification_title),
-                text, contentIntent);
-
-        notification.flags = Notification.FLAG_ONGOING_EVENT;
+        builder.setContentText(text);
 
         // Show notification
-        mNotificationManager.notify(R.string.phone_in_ecm_notification_title, notification);
+        mNotificationManager.notify(R.string.phone_in_ecm_notification_title, builder.build());
     }
 
     /**
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c608b1d..5ca4481 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -442,7 +442,7 @@
                             }
                         }
                         openChannelResp = new IccOpenLogicalChannelResponse(channelId,
-                            IccOpenLogicalChannelResponse.NO_ERROR, selectResponse );
+                            IccOpenLogicalChannelResponse.STATUS_NO_ERROR, selectResponse);
                     } else {
                         if (ar.result == null) {
                             loge("iccOpenLogicalChannel: Empty response");
@@ -451,12 +451,12 @@
                             loge("iccOpenLogicalChannel: Exception: " + ar.exception);
                         }
 
-                        int errorCode = IccOpenLogicalChannelResponse.UNKNOWN_ERROR;
+                        int errorCode = IccOpenLogicalChannelResponse.STATUS_UNKNOWN_ERROR;
                         if ((ar.exception != null) && (ar.exception instanceof CommandException)) {
                             if (ar.exception.getMessage().compareTo("MISSING_RESOURCE") == 0) {
-                                errorCode = IccOpenLogicalChannelResponse.MISSING_RESOURCE;
+                                errorCode = IccOpenLogicalChannelResponse.STATUS_MISSING_RESOURCE;
                             } else if (ar.exception.getMessage().compareTo("NO_SUCH_ELEMENT") == 0) {
-                                errorCode = IccOpenLogicalChannelResponse.NO_SUCH_ELEMENT;
+                                errorCode = IccOpenLogicalChannelResponse.STATUS_NO_SUCH_ELEMENT;
                             }
                         }
                         openChannelResp = new IccOpenLogicalChannelResponse(
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index f13676a..67104b5 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -24,8 +24,15 @@
  * Manages a single phone call handled by CDMA.
  */
 final class CdmaConnection extends TelephonyConnection {
-    CdmaConnection(Connection connection) {
+
+    /**
+     * {@code True} if the CDMA connection should allow mute.
+     */
+    private final boolean mAllowMute;
+
+    CdmaConnection(Connection connection, boolean allowMute) {
         super(connection);
+        mAllowMute = allowMute;
     }
 
     /** {@inheritDoc} */
@@ -49,7 +56,10 @@
 
     @Override
     protected int buildCallCapabilities() {
-        int capabilities = PhoneCapabilities.MUTE;
+        int capabilities = 0;
+        if (mAllowMute) {
+            capabilities = PhoneCapabilities.MUTE;
+        }
         return capabilities;
     }
 }
diff --git a/src/com/android/services/telephony/TelecommAccountRegistry.java b/src/com/android/services/telephony/TelecommAccountRegistry.java
index fedbf6b..c342e48 100644
--- a/src/com/android/services/telephony/TelecommAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecommAccountRegistry.java
@@ -42,6 +42,7 @@
  */
 final class TelecommAccountRegistry {
     private final static int[] phoneAccountIcons = {
+        com.android.phone.R.drawable.ic_multi_sim,
         com.android.phone.R.drawable.ic_multi_sim1,
         com.android.phone.R.drawable.ic_multi_sim2,
         com.android.phone.R.drawable.ic_multi_sim3,
@@ -53,9 +54,9 @@
         private final PhoneAccount mAccount;
         private final PstnIncomingCallNotifier mIncomingCallNotifier;
 
-        AccountEntry(Phone phone, int iconResId, boolean isEmergency, boolean isDummy) {
+        AccountEntry(Phone phone, boolean isEmergency, boolean isDummy) {
             mPhone = phone;
-            mAccount = registerPstnPhoneAccount(iconResId, isEmergency, isDummy);
+            mAccount = registerPstnPhoneAccount(isEmergency, isDummy);
             Log.d(this, "Registered phoneAccount: %s with handle: %s",
                     mAccount, mAccount.getAccountHandle());
             mIncomingCallNotifier = new PstnIncomingCallNotifier((PhoneProxy) mPhone);
@@ -69,8 +70,7 @@
         /**
          * Registers the specified account with Telecomm as a PhoneAccountHandle.
          */
-        private PhoneAccount registerPstnPhoneAccount(
-                int iconResId, boolean isEmergency, boolean isDummyAccount) {
+        private PhoneAccount registerPstnPhoneAccount(boolean isEmergency, boolean isDummyAccount) {
             TelephonyManager telephonyManager = TelephonyManager.from(mContext);
             String dummyPrefix = isDummyAccount ? "Dummy " : "";
 
@@ -101,7 +101,7 @@
                     .withSubscriptionNumber(subNumber)
                     .withCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
                             PhoneAccount.CAPABILITY_CALL_PROVIDER)
-                    .withIconResId(iconResId)
+                    .withIconResId(getPhoneAccountIcon(slotId))
                     .withLabel(label)
                     .withShortDescription(description)
                     .build();
@@ -188,9 +188,6 @@
         // Before we do anything, we need to clear whatever entries we registered at boot.
         clearCurrentTelephonyAccounts();
 
-        // Use counter to keep track of which default icon we are using
-        int currAccountIcon = 0;
-
         // Go through SIM-based phones and register ourselves
         Phone[] phones = PhoneFactory.getPhones();
         Log.d(this, "Found %d phones.  Attempting to register.", phones.length);
@@ -198,8 +195,7 @@
             long subscriptionId = phone.getSubId();
             Log.d(this, "Phone with subscription id %d", subscriptionId);
             if (subscriptionId >= 0) {
-                mAccounts.add(new AccountEntry(phone, getPhoneAccountIcon(currAccountIcon++),
-                        false /* emergency */, false /* isDummy */));
+                mAccounts.add(new AccountEntry(phone, false /* emergency */, false /* isDummy */));
             }
         }
 
@@ -207,15 +203,13 @@
         // for emergency numbers since no actual SIM is needed for dialing emergency
         // numbers but a phone account is.
         if (mAccounts.isEmpty()) {
-            mAccounts.add(new AccountEntry(
-                    PhoneFactory.getDefaultPhone(), getPhoneAccountIcon(currAccountIcon++),
-                    true /* emergency */, false /* isDummy */));
+            mAccounts.add(new AccountEntry(PhoneFactory.getDefaultPhone(), true /* emergency */,
+                    false /* isDummy */));
         }
 
         // Add a fake account entry.
         if (phones.length > 0 && "TRUE".equals(System.getProperty("dummy_sim"))) {
-            mAccounts.add(new AccountEntry(phones[0], getPhoneAccountIcon(currAccountIcon++),
-                    false /* emergency */, true /* isDummy */));
+            mAccounts.add(new AccountEntry(phones[0], false /* emergency */, true /* isDummy */));
         }
 
         // TODO: Add SIP accounts.
@@ -225,7 +219,8 @@
         if (index < TelecommAccountRegistry.phoneAccountIcons.length) {
             return TelecommAccountRegistry.phoneAccountIcons[index];
         }
-        return com.android.phone.R.drawable.ic_multi_sim;
+        // default blank icon
+        return TelecommAccountRegistry.phoneAccountIcons[0];
     }
 
     private void tearDownAccounts() {
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index adb430c..3821132 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -360,7 +360,12 @@
     private void hangup(int disconnectCause) {
         if (mOriginalConnection != null) {
             try {
-                mOriginalConnection.hangup();
+                Call call = getCall();
+                if (call != null) {
+                    call.hangup();
+                } else {
+                    Log.w(this, "Attempting to hangup a connection without backing call.");
+                }
             } catch (CallStateException e) {
                 Log.e(this, e, "Call to Connection.hangup failed with exception");
             }
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 7c4d1ae..851269d 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -36,7 +36,9 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.PhoneProxy;
 import com.android.internal.telephony.SubscriptionController;
+import com.android.internal.telephony.cdma.CDMAPhone;
 import com.android.phone.MMIDialogActivity;
 
 import java.util.Objects;
@@ -120,7 +122,7 @@
             }
         }
 
-        final TelephonyConnection connection = createConnectionFor(phone.getPhoneType(), null);
+        final TelephonyConnection connection = createConnectionFor(phone, null);
         if (connection == null) {
             return Connection.createFailedConnection(
                     DisconnectCause.OUTGOING_FAILURE, "Invalid phone type");
@@ -182,7 +184,7 @@
             return Connection.createCanceledConnection();
         }
 
-        Connection connection = createConnectionFor(phone.getPhoneType(), originalConnection);
+        Connection connection = createConnectionFor(phone, originalConnection);
         if (connection == null) {
             connection = Connection.createCanceledConnection();
             return Connection.createCanceledConnection();
@@ -248,11 +250,13 @@
     }
 
     private TelephonyConnection createConnectionFor(
-            int phoneType, com.android.internal.telephony.Connection originalConnection) {
+            Phone phone, com.android.internal.telephony.Connection originalConnection) {
+        int phoneType = phone.getPhoneType();
         if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
             return new GsmConnection(originalConnection);
         } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
-            return new CdmaConnection(originalConnection);
+            boolean allowMute = allowMute(phone);
+            return new CdmaConnection(originalConnection, allowMute);
         } else {
             return null;
         }
@@ -289,4 +293,26 @@
         }
         return null;
     }
+
+    /**
+     * Determines if the connection should allow mute.
+     *
+     * @param phone The current phone.
+     * @return {@code True} if the connection should allow mute.
+     */
+    private boolean allowMute(Phone phone) {
+        // For CDMA phones, check if we are in Emergency Callback Mode (ECM).  Mute is disallowed
+        // in ECM mode.
+        if (phone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
+            PhoneProxy phoneProxy = (PhoneProxy)phone;
+            CDMAPhone cdmaPhone = (CDMAPhone)phoneProxy.getActivePhone();
+            if (cdmaPhone != null) {
+                if (cdmaPhone.isInEcm()) {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
 }