Merge "Hide carrier network settings if HIDE_CARRIER_NETWORK_SETTINGS is 1." into lmp-mr1-dev
diff --git a/sip/src/com/android/services/telephony/sip/SipUtil.java b/sip/src/com/android/services/telephony/sip/SipUtil.java
index df1a03a..54bdc1e 100644
--- a/sip/src/com/android/services/telephony/sip/SipUtil.java
+++ b/sip/src/com/android/services/telephony/sip/SipUtil.java
@@ -119,9 +119,7 @@
                 .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
                 .setAddress(Uri.parse(profile.getUriString()))
                 .setShortDescription(profile.getDisplayName())
-                .setIconBitmap(BitmapFactory.decodeResource(
-                        context.getResources(),
-                        R.drawable.ic_dialer_sip_black_24dp))
+                .setIcon(context, R.drawable.ic_dialer_sip_black_24dp)
                 .setSupportedUriSchemes(supportedUriSchemes);
 
         return builder.build();
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 02bbf6d..4651677 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -21,7 +21,6 @@
 import android.app.ActivityOptions;
 import android.app.AlertDialog;
 import android.app.Dialog;
-import android.app.ProgressDialog;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -52,7 +51,6 @@
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.MenuItem;
-import android.view.WindowManager;
 import android.widget.ListAdapter;
 
 import com.android.ims.ImsManager;
@@ -62,6 +60,7 @@
 import com.android.phone.common.util.SettingsUtil;
 import com.android.phone.settings.AccountSelectionPreference;
 import com.android.phone.settings.CallForwardInfoUtil;
+import com.android.phone.settings.VoicemailDialogUtil;
 import com.android.phone.settings.VoicemailProviderSettings;
 import com.android.phone.settings.VoicemailProviderSettingsUtil;
 import com.android.phone.settings.fdn.FdnSetting;
@@ -190,18 +189,6 @@
     private AudioManager mAudioManager;
     private VoicemailProviderSettingsUtil mVmProviderSettingsUtil;
 
-    private static final int VM_NOCHANGE_ERROR = 400;
-    private static final int VM_RESPONSE_ERROR = 500;
-    private static final int FW_SET_RESPONSE_ERROR = 501;
-    private static final int FW_GET_RESPONSE_ERROR = 502;
-
-
-    // dialog identifiers for voicemail
-    private static final int VOICEMAIL_DIALOG_CONFIRM = 600;
-    private static final int VOICEMAIL_FWD_SAVING_DIALOG = 601;
-    private static final int VOICEMAIL_FWD_READING_DIALOG = 602;
-    private static final int VOICEMAIL_REVERTING_DIALOG = 603;
-
     // voicemail notification vibration string constants
     private static final String VOICEMAIL_VIBRATION_ALWAYS = "always";
     private static final String VOICEMAIL_VIBRATION_NEVER = "never";
@@ -523,7 +510,7 @@
         }
 
         if (mVMChangeCompletedSuccessfully || mFwdChangesRequireRollback) {
-            showDialogIfForeground(VOICEMAIL_REVERTING_DIALOG);
+            showDialogIfForeground(VoicemailDialogUtil.VM_REVERTING_DIALOG);
             final VoicemailProviderSettings prevSettings =
                     mVmProviderSettingsUtil.load(mPreviousVMProviderKey);
             if (prevSettings == null) {
@@ -734,7 +721,7 @@
         // Throw a warning if the voicemail is the same and we did not change forwarding.
         if (mNewVMNumber.equals(mOldVmNumber)
                 && mNewFwdSettings == VoicemailProviderSettings.NO_FORWARDING) {
-            showDialogIfForeground(VM_NOCHANGE_ERROR);
+            showDialogIfForeground(VoicemailDialogUtil.VM_NOCHANGE_ERROR_DIALOG);
             return;
         }
 
@@ -753,7 +740,7 @@
                         VoicemailProviderSettings.FORWARDING_SETTINGS_REASONS[i],
                         mGetOptionComplete.obtainMessage(EVENT_FORWARDING_GET_COMPLETED, i, 0));
             }
-            showDialogIfForeground(VOICEMAIL_FWD_READING_DIALOG);
+            showDialogIfForeground(VoicemailDialogUtil.VM_FWD_READING_DIALOG);
         } else {
             saveVoiceMailAndForwardingNumberStage2();
         }
@@ -794,8 +781,8 @@
         if (error != null) {
             if (DBG) Log.d(LOG_TAG, "Error discovered for fwd read : " + idx);
             mForwardingReadResults = null;
-            dismissDialogSafely(VOICEMAIL_FWD_READING_DIALOG);
-            showDialogIfForeground(FW_GET_RESPONSE_ERROR);
+            dismissDialogSafely(VoicemailDialogUtil.VM_FWD_READING_DIALOG);
+            showDialogIfForeground(VoicemailDialogUtil.FWD_GET_RESPONSE_ERROR_DIALOG);
             return;
         }
 
@@ -815,7 +802,7 @@
 
         if (done) {
             if (DBG) Log.d(LOG_TAG, "Done receiving fwd info");
-            dismissDialogSafely(VOICEMAIL_FWD_READING_DIALOG);
+            dismissDialogSafely(VoicemailDialogUtil.VM_FWD_READING_DIALOG);
 
             if (mReadingSettingsForDefaultProvider) {
                 mVmProviderSettingsUtil.save(DEFAULT_VM_PROVIDER_KEY,
@@ -853,7 +840,7 @@
                                     EVENT_FORWARDING_CHANGED, fi.reason, 0));
                 }
             }
-            showDialogIfForeground(VOICEMAIL_FWD_SAVING_DIALOG);
+            showDialogIfForeground(VoicemailDialogUtil.VM_FWD_SAVING_DIALOG);
         } else {
             if (DBG) log("Not touching fwd #");
             setVMNumberWithCarrier();
@@ -922,7 +909,7 @@
             if (done) {
                 if (DBG) log("All VM provider related changes done");
                 if (mForwardingChangeResults != null) {
-                    dismissDialogSafely(VOICEMAIL_FWD_SAVING_DIALOG);
+                    dismissDialogSafely(VoicemailDialogUtil.VM_FWD_SAVING_DIALOG);
                 }
                 handleSetVmOrFwdMessage();
             }
@@ -959,7 +946,7 @@
                     && (!mFwdChangesRequireRollback || isForwardingCompleted());
             if (done) {
                 if (DBG) log("All VM reverts done");
-                dismissDialogSafely(VOICEMAIL_REVERTING_DIALOG);
+                dismissDialogSafely(VoicemailDialogUtil.VM_REVERTING_DIALOG);
                 onRevertDone();
             }
         }
@@ -1013,11 +1000,11 @@
         if (DBG) log("handleSetVMMessage: set VM request complete");
 
         if (!isFwdChangeSuccess()) {
-            handleVmOrFwdSetError(FW_SET_RESPONSE_ERROR);
+            handleVmOrFwdSetError(VoicemailDialogUtil.FWD_SET_RESPONSE_ERROR_DIALOG);
         } else if (!isVmChangeSuccess()) {
-            handleVmOrFwdSetError(VM_RESPONSE_ERROR);
+            handleVmOrFwdSetError(VoicemailDialogUtil.VM_RESPONSE_ERROR_DIALOG);
         } else {
-            handleVmAndFwdSetSuccess(VOICEMAIL_DIALOG_CONFIRM);
+            handleVmAndFwdSetSuccess(VoicemailDialogUtil.VM_CONFIRM_DIALOG);
         }
     }
 
@@ -1026,7 +1013,7 @@
      * changes to those settings and show "failure" dialog.
      *
      * @param dialogId ID of the dialog to show for the specific error case. Either
-     *     {@link #FW_SET_RESPONSE_ERROR} or {@link #VM_RESPONSE_ERROR}
+     *     {@link #FWD_SET_RESPONSE_ERROR_DIALOG} or {@link #VM_RESPONSE_ERROR_DIALOG}
      */
     private void handleVmOrFwdSetError(int dialogId) {
         if (mChangingVMorFwdDueToProviderChange) {
@@ -1086,78 +1073,8 @@
 
     // dialog creation method, called by showDialog()
     @Override
-    protected Dialog onCreateDialog(int id) {
-        if ((id == VM_RESPONSE_ERROR) || (id == VM_NOCHANGE_ERROR) ||
-            (id == FW_SET_RESPONSE_ERROR) || (id == FW_GET_RESPONSE_ERROR) ||
-                (id == VOICEMAIL_DIALOG_CONFIRM)) {
-
-            AlertDialog.Builder b = new AlertDialog.Builder(this);
-
-            int msgId;
-            int titleId = R.string.error_updating_title;
-            switch (id) {
-                case VOICEMAIL_DIALOG_CONFIRM:
-                    msgId = R.string.vm_changed;
-                    titleId = R.string.voicemail;
-                    // Set Button 2
-                    b.setNegativeButton(R.string.close_dialog, this);
-                    break;
-                case VM_NOCHANGE_ERROR:
-                    // even though this is technically an error,
-                    // keep the title friendly.
-                    msgId = R.string.no_change;
-                    titleId = R.string.voicemail;
-                    // Set Button 2
-                    b.setNegativeButton(R.string.close_dialog, this);
-                    break;
-                case VM_RESPONSE_ERROR:
-                    msgId = R.string.vm_change_failed;
-                    // Set Button 1
-                    b.setPositiveButton(R.string.close_dialog, this);
-                    break;
-                case FW_SET_RESPONSE_ERROR:
-                    msgId = R.string.fw_change_failed;
-                    // Set Button 1
-                    b.setPositiveButton(R.string.close_dialog, this);
-                    break;
-                case FW_GET_RESPONSE_ERROR:
-                    msgId = R.string.fw_get_in_vm_failed;
-                    b.setPositiveButton(R.string.alert_dialog_yes, this);
-                    b.setNegativeButton(R.string.alert_dialog_no, this);
-                    break;
-                default:
-                    msgId = R.string.exception_error;
-                    // Set Button 3, tells the activity that the error is
-                    // not recoverable on dialog exit.
-                    b.setNeutralButton(R.string.close_dialog, this);
-                    break;
-            }
-
-            b.setTitle(getText(titleId));
-            String message = getText(msgId).toString();
-            b.setMessage(message);
-            b.setCancelable(false);
-            AlertDialog dialog = b.create();
-
-            // make the dialog more obvious by bluring the background.
-            dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
-
-            return dialog;
-        } else if (id == VOICEMAIL_FWD_SAVING_DIALOG || id == VOICEMAIL_FWD_READING_DIALOG ||
-                id == VOICEMAIL_REVERTING_DIALOG) {
-            ProgressDialog dialog = new ProgressDialog(this);
-            dialog.setTitle(getText(R.string.call_settings));
-            dialog.setIndeterminate(true);
-            dialog.setCancelable(false);
-            dialog.setMessage(getText(
-                    id == VOICEMAIL_FWD_SAVING_DIALOG ? R.string.updating_settings :
-                    (id == VOICEMAIL_REVERTING_DIALOG ? R.string.reverting_settings :
-                    R.string.reading_settings)));
-            return dialog;
-        }
-
-
-        return null;
+    protected Dialog onCreateDialog(int dialogId) {
+        return VoicemailDialogUtil.getDialog(this, dialogId);
     }
 
     // This is a method implemented for DialogInterface.OnClickListener.
@@ -1170,14 +1087,14 @@
         dialog.dismiss();
         switch (which){
             case DialogInterface.BUTTON_NEGATIVE:
-                if (mCurrentDialogId == FW_GET_RESPONSE_ERROR) {
+                if (mCurrentDialogId == VoicemailDialogUtil.FWD_GET_RESPONSE_ERROR_DIALOG) {
                     // We failed to get current forwarding settings and the user
                     // does not wish to continue.
                     switchToPreviousVoicemailProvider();
                 }
                 break;
             case DialogInterface.BUTTON_POSITIVE:
-                if (mCurrentDialogId == FW_GET_RESPONSE_ERROR) {
+                if (mCurrentDialogId == VoicemailDialogUtil.FWD_GET_RESPONSE_ERROR_DIALOG) {
                     // We failed to get current forwarding settings but the user
                     // wishes to continue changing settings to the new vm provider
                     saveVoiceMailAndForwardingNumberStage2();
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index bef8c0f..bbef032 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -76,6 +76,10 @@
     private static final String BUTTON_ENABLED_NETWORKS_KEY = "enabled_networks_key";
     private static final String BUTTON_4G_LTE_KEY = "enhanced_4g_lte";
     private static final String BUTTON_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings";
+    private static final String BUTTON_APN_EXPAND_KEY = "button_apn_key";
+    private static final String BUTTON_OPERATOR_SELECTION_EXPAND_KEY = "button_carrier_sel_key";
+    private static final String BUTTON_CARRIER_SETTINGS_KEY = "carrier_settings_key";
+    private static final String BUTTON_CDMA_SYSTEM_SELECT_KEY = "cdma_system_select_key";
 
     static final int preferredNetworkMode = Phone.PREFERRED_NT_MODE;
 
@@ -694,7 +698,7 @@
                         R.string.preferred_network_mode_lte_cdma_evdo_summary);
                 break;
             case Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
-                if (mIsGlobalCdma) {
+                if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
                     mButtonPreferredNetworkMode.setSummary(
                             R.string.preferred_network_mode_global_summary);
                 } else {
@@ -743,9 +747,11 @@
                 }
                 break;
             case Phone.NT_MODE_LTE_GSM_WCDMA:
-                if(isWorldMode()) {
+                if (isWorldMode()) {
                     mButtonEnabledNetworks.setSummary(
                             R.string.preferred_network_mode_lte_gsm_umts_summary);
+                    controlCdmaOptions(false);
+                    controlGsmOptions(true);
                     break;
                 }
             case Phone.NT_MODE_LTE_ONLY:
@@ -762,9 +768,11 @@
                 }
                 break;
             case Phone.NT_MODE_LTE_CDMA_AND_EVDO:
-                if(isWorldMode()) {
+                if (isWorldMode()) {
                     mButtonEnabledNetworks.setSummary(
                             R.string.preferred_network_mode_lte_cdma_summary);
+                    controlCdmaOptions(true);
+                    controlGsmOptions(false);
                 } else {
                     mButtonEnabledNetworks.setValue(
                             Integer.toString(Phone.NT_MODE_LTE_CDMA_AND_EVDO));
@@ -784,9 +792,13 @@
                 mButtonEnabledNetworks.setSummary(R.string.network_1x);
                 break;
             case Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA:
+                if (isWorldMode()) {
+                    controlCdmaOptions(true);
+                    controlGsmOptions(false);
+                }
                 mButtonEnabledNetworks.setValue(
                         Integer.toString(Phone.NT_MODE_LTE_CDMA_EVDO_GSM_WCDMA));
-                if (mIsGlobalCdma) {
+                if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
                     mButtonEnabledNetworks.setSummary(R.string.network_global);
                 } else {
                     mButtonEnabledNetworks.setSummary((mShow4GForLTE == true)
@@ -871,4 +883,46 @@
 
         return worldModeOn;
     }
+
+    private void controlGsmOptions(boolean enable) {
+        PreferenceScreen prefSet = getPreferenceScreen();
+        if (prefSet == null) {
+            return;
+        }
+
+        if (enable && mGsmUmtsOptions == null) {
+            mGsmUmtsOptions = new GsmUmtsOptions(this, prefSet);
+        }
+        PreferenceScreen apnExpand =
+                (PreferenceScreen) prefSet.findPreference(BUTTON_APN_EXPAND_KEY);
+        PreferenceScreen operatorSelectionExpand =
+                (PreferenceScreen) prefSet.findPreference(BUTTON_OPERATOR_SELECTION_EXPAND_KEY);
+        PreferenceScreen carrierSettings =
+                (PreferenceScreen) prefSet.findPreference(BUTTON_CARRIER_SETTINGS_KEY);
+        if (apnExpand != null) {
+            apnExpand.setEnabled(enable);
+        }
+        if (operatorSelectionExpand != null) {
+            operatorSelectionExpand.setEnabled(enable);
+        }
+        if (carrierSettings != null) {
+            prefSet.removePreference(carrierSettings);
+        }
+    }
+
+    private void controlCdmaOptions(boolean enable) {
+        PreferenceScreen prefSet = getPreferenceScreen();
+        if (prefSet == null) {
+            return;
+        }
+        if (enable && mCdmaOptions == null) {
+            mCdmaOptions = new CdmaOptions(this, prefSet, mPhone);
+        }
+        CdmaSystemSelectListPreference systemSelect =
+                (CdmaSystemSelectListPreference)prefSet.findPreference
+                        (BUTTON_CDMA_SYSTEM_SELECT_KEY);
+        if (systemSelect != null) {
+            systemSelect.setEnabled(enable);
+        }
+    }
 }
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index fd54750..5226e0d 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -30,10 +30,6 @@
                 Preference.OnPreferenceClickListener,
                 AccountSelectionPreference.AccountSelectionListener {
 
-    private static final Intent CONNECTION_SERVICE_CONFIGURE_INTENT =
-            new Intent(TelecomManager.ACTION_CONNECTION_SERVICE_CONFIGURE)
-                    .addCategory(Intent.CATEGORY_DEFAULT);
-
     private static final String ACCOUNTS_LIST_CATEGORY_KEY =
             "phone_accounts_accounts_list_category_key";
 
@@ -183,10 +179,20 @@
     @Override
     public boolean onPreferenceClick(Preference pref) {
         if (pref == mConfigureCallAssistant) {
-            try {
-                startActivity(CONNECTION_SERVICE_CONFIGURE_INTENT);
-            } catch (ActivityNotFoundException e) {
-                Log.d(LOG_TAG, "Could not resolve telecom connection service configure intent.");
+            String packageName = null;
+            PhoneAccountHandle handle = mTelecomManager.getSimCallManager();
+            if (handle != null) {
+                packageName = handle.getComponentName().getPackageName();
+            }
+            if (packageName != null) {
+                Intent intent = new Intent(TelecomManager.ACTION_CONNECTION_SERVICE_CONFIGURE)
+                        .addCategory(Intent.CATEGORY_DEFAULT)
+                        .setPackage(packageName);
+                try {
+                    startActivity(intent);
+                } catch (ActivityNotFoundException e) {
+                    Log.d(LOG_TAG, "Could not resolve call assistant configure intent: " + intent);
+                }
             }
             return true;
         }
diff --git a/src/com/android/phone/settings/VoicemailDialogUtil.java b/src/com/android/phone/settings/VoicemailDialogUtil.java
new file mode 100644
index 0000000..0a9e4bc
--- /dev/null
+++ b/src/com/android/phone/settings/VoicemailDialogUtil.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.settings;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.view.WindowManager;
+
+import com.android.phone.CallFeaturesSetting;
+import com.android.phone.R;
+
+public class VoicemailDialogUtil {
+
+    // Voicemail dialog identifiers.
+    public static final int VM_NOCHANGE_ERROR_DIALOG = 400;
+    public static final int VM_RESPONSE_ERROR_DIALOG = 500;
+    public static final int FWD_SET_RESPONSE_ERROR_DIALOG = 501;
+    public static final int FWD_GET_RESPONSE_ERROR_DIALOG = 502;
+    public static final int VM_CONFIRM_DIALOG = 600;
+    public static final int VM_FWD_SAVING_DIALOG = 601;
+    public static final int VM_FWD_READING_DIALOG = 602;
+    public static final int VM_REVERTING_DIALOG = 603;
+
+    public static Dialog getDialog(CallFeaturesSetting parent, int id) {
+        if ((id == VM_RESPONSE_ERROR_DIALOG) || (id == VM_NOCHANGE_ERROR_DIALOG) ||
+            (id == FWD_SET_RESPONSE_ERROR_DIALOG) || (id == FWD_GET_RESPONSE_ERROR_DIALOG) ||
+                (id == VM_CONFIRM_DIALOG)) {
+
+            AlertDialog.Builder b = new AlertDialog.Builder(parent);
+
+            int msgId;
+            int titleId = R.string.error_updating_title;
+            switch (id) {
+                case VM_CONFIRM_DIALOG:
+                    msgId = R.string.vm_changed;
+                    titleId = R.string.voicemail;
+                    // Set Button 2
+                    b.setNegativeButton(R.string.close_dialog, parent);
+                    break;
+                case VM_NOCHANGE_ERROR_DIALOG:
+                    // even though this is technically an error,
+                    // keep the title friendly.
+                    msgId = R.string.no_change;
+                    titleId = R.string.voicemail;
+                    // Set Button 2
+                    b.setNegativeButton(R.string.close_dialog, parent);
+                    break;
+                case VM_RESPONSE_ERROR_DIALOG:
+                    msgId = R.string.vm_change_failed;
+                    // Set Button 1
+                    b.setPositiveButton(R.string.close_dialog, parent);
+                    break;
+                case FWD_SET_RESPONSE_ERROR_DIALOG:
+                    msgId = R.string.fw_change_failed;
+                    // Set Button 1
+                    b.setPositiveButton(R.string.close_dialog, parent);
+                    break;
+                case FWD_GET_RESPONSE_ERROR_DIALOG:
+                    msgId = R.string.fw_get_in_vm_failed;
+                    b.setPositiveButton(R.string.alert_dialog_yes, parent);
+                    b.setNegativeButton(R.string.alert_dialog_no, parent);
+                    break;
+                default:
+                    msgId = R.string.exception_error;
+                    // Set Button 3, tells the activity that the error is
+                    // not recoverable on dialog exit.
+                    b.setNeutralButton(R.string.close_dialog, parent);
+                    break;
+            }
+
+            b.setTitle(parent.getText(titleId));
+            String message = parent.getText(msgId).toString();
+            b.setMessage(message);
+            b.setCancelable(false);
+            AlertDialog dialog = b.create();
+
+            // make the dialog more obvious by bluring the background.
+            dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
+
+            return dialog;
+        } else if (id == VM_FWD_SAVING_DIALOG || id == VM_FWD_READING_DIALOG ||
+                id == VM_REVERTING_DIALOG) {
+            ProgressDialog dialog = new ProgressDialog(parent);
+            dialog.setTitle(parent.getText(R.string.call_settings));
+            dialog.setIndeterminate(true);
+            dialog.setCancelable(false);
+            dialog.setMessage(parent.getText(
+                    id == VM_FWD_SAVING_DIALOG ? R.string.updating_settings :
+                    (id == VM_REVERTING_DIALOG ? R.string.reverting_settings :
+                    R.string.reading_settings)));
+            return dialog;
+        }
+
+        return null;
+    }
+}
diff --git a/src/com/android/services/telephony/CdmaConference.java b/src/com/android/services/telephony/CdmaConference.java
index 5372548..2d5ee47 100755
--- a/src/com/android/services/telephony/CdmaConference.java
+++ b/src/com/android/services/telephony/CdmaConference.java
@@ -37,15 +37,15 @@
 
     private int mCapabilities = PhoneCapabilities.MUTE;
 
-    public CdmaConference(PhoneAccountHandle phoneAccount, int capabilities) {
+    public CdmaConference(PhoneAccountHandle phoneAccount) {
         super(phoneAccount);
-        setCapabilities(mCapabilities | capabilities);
         setActive();
     }
 
     private void updateCapabilities() {
         setCapabilities(mCapabilities);
     }
+
     /**
      * Invoked when the Conference and all it's {@link Connection}s should be disconnected.
      */
diff --git a/src/com/android/services/telephony/CdmaConferenceController.java b/src/com/android/services/telephony/CdmaConferenceController.java
index d6d5659..e2f0b50 100644
--- a/src/com/android/services/telephony/CdmaConferenceController.java
+++ b/src/com/android/services/telephony/CdmaConferenceController.java
@@ -149,18 +149,20 @@
             // 1) Create a new conference connection if it doesn't exist.
             if (mConference == null) {
                 Log.i(this, "Creating new Cdma conference call");
-                CdmaConnection newConnection = mCdmaConnections.get(mCdmaConnections.size() - 1);
-                if (newConnection.isOutgoing()) {
-                    // Only an outgoing call can be merged with an ongoing call.
-                    mConference = new CdmaConference(null, PhoneCapabilities.MERGE_CONFERENCE);
-                } else {
-                    // If the most recently added connection was an incoming call, enable
-                    // swap instead of merge.
-                    mConference = new CdmaConference(null, PhoneCapabilities.SWAP_CONFERENCE);
-                }
+                mConference = new CdmaConference(null);
                 isNewlyCreated = true;
             }
 
+            CdmaConnection newConnection = mCdmaConnections.get(mCdmaConnections.size() - 1);
+            if (newConnection.isOutgoing()) {
+                // Only an outgoing call can be merged with an ongoing call.
+                mConference.setCapabilities(PhoneCapabilities.MERGE_CONFERENCE);
+            } else {
+                // If the most recently added connection was an incoming call, enable
+                // swap instead of merge.
+                mConference.setCapabilities(PhoneCapabilities.SWAP_CONFERENCE);
+            }
+
             // 2) Add any new connections to the conference
             List<Connection> existingChildConnections =
                     new ArrayList<>(mConference.getConnections());
diff --git a/src/com/android/services/telephony/CdmaConnection.java b/src/com/android/services/telephony/CdmaConnection.java
index d2988da..c52a824 100644
--- a/src/com/android/services/telephony/CdmaConnection.java
+++ b/src/com/android/services/telephony/CdmaConnection.java
@@ -160,9 +160,6 @@
         if (mAllowMute) {
             capabilities |= PhoneCapabilities.MUTE;
         }
-        if (getConference() == null) {
-            capabilities |= PhoneCapabilities.ADD_CALL;
-        }
         return capabilities;
     }
 
diff --git a/src/com/android/services/telephony/GsmConnection.java b/src/com/android/services/telephony/GsmConnection.java
index 4482d36..d2e68c6 100644
--- a/src/com/android/services/telephony/GsmConnection.java
+++ b/src/com/android/services/telephony/GsmConnection.java
@@ -48,7 +48,6 @@
     @Override
     protected int buildCallCapabilities() {
         int capabilities = super.buildCallCapabilities();
-        capabilities |= PhoneCapabilities.ADD_CALL;
         capabilities |= PhoneCapabilities.MUTE;
         capabilities |= PhoneCapabilities.SUPPORT_HOLD;
         if (getState() == STATE_ACTIVE || getState() == STATE_HOLDING) {
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 49767a2..2f20621 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -169,10 +169,7 @@
                     .setSubscriptionAddress(
                             Uri.fromParts(PhoneAccount.SCHEME_TEL, subNumber, null))
                     .setCapabilities(capabilities)
-                    .setIconBitmap(BitmapFactory.decodeResource(
-                            mContext.getResources(),
-                            getPhoneAccountIcon(slotId)))
-                    .setColor(color)
+                    .setIcon(mContext, getPhoneAccountIcon(slotId), color)
                     .setShortDescription(description)
                     .setSupportedUriSchemes(Arrays.asList(
                             PhoneAccount.SCHEME_TEL, PhoneAccount.SCHEME_VOICEMAIL))
diff --git a/src/com/android/services/telephony/TelephonyConference.java b/src/com/android/services/telephony/TelephonyConference.java
index 7736dc1..fc009bc 100644
--- a/src/com/android/services/telephony/TelephonyConference.java
+++ b/src/com/android/services/telephony/TelephonyConference.java
@@ -42,7 +42,6 @@
     public TelephonyConference(PhoneAccountHandle phoneAccount) {
         super(phoneAccount);
         setCapabilities(
-                PhoneCapabilities.ADD_CALL |
                 PhoneCapabilities.SUPPORT_HOLD |
                 PhoneCapabilities.HOLD |
                 PhoneCapabilities.MUTE |
diff --git a/src/com/android/services/telephony/TelephonyConferenceController.java b/src/com/android/services/telephony/TelephonyConferenceController.java
index f726c55..55c8338 100644
--- a/src/com/android/services/telephony/TelephonyConferenceController.java
+++ b/src/com/android/services/telephony/TelephonyConferenceController.java
@@ -117,8 +117,8 @@
     }
 
     private void recalculate() {
-        recalculateConferenceable();
         recalculateConference();
+        recalculateConferenceable();
     }
 
     private boolean isFullConference(Conference conference) {
@@ -183,6 +183,7 @@
                     nonConferencedConnections.add(c);
                 }
             }
+            Log.v(this, "conference conferenceable: %s", nonConferencedConnections);
             mTelephonyConference.setConferenceableConnections(nonConferencedConnections);
         }
 
diff --git a/src/com/android/services/telephony/TelephonyConnection.java b/src/com/android/services/telephony/TelephonyConnection.java
index 30312bb..056f62f 100644
--- a/src/com/android/services/telephony/TelephonyConnection.java
+++ b/src/com/android/services/telephony/TelephonyConnection.java
@@ -396,7 +396,6 @@
     protected int buildCallCapabilities() {
         int callCapabilities = 0;
         if (isImsConnection()) {
-            callCapabilities |= PhoneCapabilities.ADD_CALL;
             callCapabilities |= PhoneCapabilities.SUPPORT_HOLD;
             if (getState() == STATE_ACTIVE || getState() == STATE_HOLDING) {
                 callCapabilities |= PhoneCapabilities.HOLD;