Merge "Handle exceptions other than CommandException" into lmp-mr1-dev
diff --git a/res/layout/network_settings.xml b/res/layout/network_settings.xml
new file mode 100644
index 0000000..d2a4acc
--- /dev/null
+++ b/res/layout/network_settings.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@android:id/tabhost"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:id="@+id/tabs_container"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="vertical">
+
+        <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:scrollbars="none"
+            android:fillViewport="true">
+
+            <TabWidget
+                android:id="@android:id/tabs"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                style="?android:attr/tabWidgetStyle" />
+
+        </HorizontalScrollView>
+
+        <!-- give an empty content area to make tabhost happy -->
+        <FrameLayout
+            android:id="@android:id/tabcontent"
+            android:layout_width="0dip"
+            android:layout_height="0dip" />
+
+        <ListView
+            android:id="@android:id/list"
+            android:layout_width="match_parent"
+            android:layout_height="0dip"
+            android:layout_weight="1"
+            android:clipChildren="false"
+            android:clipToPadding="false"
+            android:smoothScrollbar="false" />
+
+    </LinearLayout>
+
+</TabHost>
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 4651677..2755bd7 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -1129,7 +1129,7 @@
         // Show the voicemail preference in onResume if the calling intent specifies the
         // ACTION_ADD_VOICEMAIL action.
         mShowVoicemailPreference = (icicle == null) &&
-                getIntent().getAction().equals(ACTION_ADD_VOICEMAIL);
+                TextUtils.equals(getIntent().getAction(), ACTION_ADD_VOICEMAIL);
 
         mSubscriptionInfoHelper = new SubscriptionInfoHelper(getIntent());
         mSubscriptionInfoHelper.setActionBarTitle(
diff --git a/src/com/android/phone/MobileNetworkSettings.java b/src/com/android/phone/MobileNetworkSettings.java
index 3c385f9..306a653 100644
--- a/src/com/android/phone/MobileNetworkSettings.java
+++ b/src/com/android/phone/MobileNetworkSettings.java
@@ -20,9 +20,13 @@
 import com.android.ims.ImsException;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.TelephonyProperties;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import android.app.ActionBar;
 import android.app.AlertDialog;
 import android.content.Context;
@@ -41,13 +45,22 @@
 import android.preference.ListPreference;
 import android.preference.Preference;
 import android.preference.PreferenceActivity;
+import android.preference.PreferenceGroup;
 import android.preference.PreferenceScreen;
 import android.preference.SwitchPreference;
+import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.MenuItem;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.TabHost;
+import android.widget.TabHost.OnTabChangeListener;
+import android.widget.TabHost.TabContentFactory;
+import android.widget.TabHost.TabSpec;
+import android.widget.TabWidget;
 
 /**
  * "Mobile network settings" screen.  This preference screen lets you
@@ -96,12 +109,17 @@
     private Preference mLteDataServicePref;
 
     private static final String iface = "rmnet0"; //TODO: this will go away
+    private List<SubscriptionInfo> mSelectableSubInfos = null;
 
     private UserManager mUm;
     private Phone mPhone;
     private MyHandler mHandler;
     private boolean mOkClicked;
 
+    private TabHost mTabHost;
+    private TabWidget mTabWidget;
+    private ListView mListView;
+
     //GsmUmts options and Cdma options
     GsmUmtsOptions mGsmUmtsOptions;
     CdmaOptions mCdmaOptions;
@@ -137,6 +155,7 @@
     @Override
     public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
         /** TODO: Refactor and get rid of the if's using subclasses */
+        final int phoneSubId = mPhone.getSubId();
         if (preference.getKey().equals(BUTTON_4G_LTE_KEY)) {
             return true;
         } else if (mGsmUmtsOptions != null &&
@@ -158,7 +177,8 @@
         } else if (preference == mButtonPreferredNetworkMode) {
             //displays the value taken from the Settings.System
             int settingsNetworkMode = android.provider.Settings.Global.getInt(mPhone.getContext().
-                    getContentResolver(), android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                    getContentResolver(),
+                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                     preferredNetworkMode);
             mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
             return true;
@@ -182,7 +202,8 @@
             return true;
         }  else if (preference == mButtonEnabledNetworks) {
             int settingsNetworkMode = android.provider.Settings.Global.getInt(mPhone.getContext().
-                    getContentResolver(), android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                    getContentResolver(),
+                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                     preferredNetworkMode);
             mButtonEnabledNetworks.setValue(Integer.toString(settingsNetworkMode));
             return true;
@@ -206,10 +227,46 @@
                   android.provider.Settings.Global.ENHANCED_4G_MODE_ENABLED, value);
     }
 
+    private OnTabChangeListener mTabListener = new OnTabChangeListener() {
+        @Override
+        public void onTabChanged(String tabId) {
+            final int slotId = Integer.parseInt(tabId);
+            final SubscriptionInfo sir = findRecordBySlotId(slotId);
+            mPhone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId()));
+
+            // The User has changed tab; update the body.
+            updateBody();
+        }
+    };
+
+    private TabContentFactory mEmptyTabContent = new TabContentFactory() {
+        @Override
+        public View createTabContent(String tag) {
+            return new View(mTabHost.getContext());
+        }
+    };
+
+    private TabSpec buildTabSpec(String tag, String title) {
+        return mTabHost.newTabSpec(tag).setIndicator(title).setContent(
+                mEmptyTabContent);
+    }
+
     @Override
     protected void onCreate(Bundle icicle) {
         setTheme(R.style.Theme_Material_Settings);
         super.onCreate(icicle);
+        final Context context = getApplicationContext();
+
+        mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
+        final TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+
+        for (int i = 0; i < tm.getSimCount(); i++) {
+            SubscriptionInfo sir = findRecordBySlotId(i);
+            if (sir != null) {
+                mSelectableSubInfos.add(sir);
+            }
+        }
 
         mPhone = PhoneGlobals.getPhone();
         mHandler = new MyHandler();
@@ -250,10 +307,79 @@
 
         mLteDataServicePref = prefSet.findPreference(BUTTON_CDMA_LTE_DATA_SERVICE_KEY);
 
+        if (mSelectableSubInfos.size() > 1) {
+            setContentView(R.layout.network_settings);
+
+            mTabHost = (TabHost) findViewById(android.R.id.tabhost);
+            mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
+            mListView = (ListView) findViewById(android.R.id.list);
+
+            mTabHost.setup();
+            mTabHost.setOnTabChangedListener(mTabListener);
+            mTabHost.clearAllTabs();
+
+            for (int i = 0; i < mSelectableSubInfos.size(); i++) {
+                mTabHost.addTab(buildTabSpec(String.valueOf(i),
+                        String.valueOf(mSelectableSubInfos.get(i).getDisplayName())));
+            }
+        }
+
+        updateBody();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+
+        if (mUnavailable) {
+            return;
+        }
+
+        // upon resumption from the sub-activity, make sure we re-enable the
+        // preferences.
+        getPreferenceScreen().setEnabled(true);
+
+        // Set UI state in onResume because a user could go home, launch some
+        // app to change this setting's backend, and re-launch this settings app
+        // and the UI state would be inconsistent with actual state
+        mButtonDataRoam.setChecked(mPhone.getDataRoamingEnabled());
+
+        if (getPreferenceScreen().findPreference(BUTTON_PREFERED_NETWORK_MODE) != null)  {
+            mPhone.getPreferredNetworkType(mHandler.obtainMessage(
+                    MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
+        }
+
+        if (getPreferenceScreen().findPreference(BUTTON_ENABLED_NETWORKS_KEY) != null)  {
+            mPhone.getPreferredNetworkType(mHandler.obtainMessage(
+                    MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
+        }
+    }
+
+    private void updateBody() {
+        final Context context = getApplicationContext();
+        final TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        PreferenceScreen prefSet = getPreferenceScreen();
         boolean isLteOnCdma = mPhone.getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
+        final int phoneSubId = mPhone.getSubId();
+
+        if (prefSet != null) {
+            prefSet.removeAll();
+            prefSet.addPreference(mButtonDataRoam);
+            prefSet.addPreference(mButtonPreferredNetworkMode);
+            prefSet.addPreference(mButtonEnabledNetworks);
+        }
+
+        int settingsNetworkMode = android.provider.Settings.Global.getInt(
+                mPhone.getContext().getContentResolver(),
+                android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
+                preferredNetworkMode);
+
         mIsGlobalCdma = isLteOnCdma && getResources().getBoolean(R.bool.config_show_cdma);
-        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
-        if (tm.getSimplifiedNetworkSettingsEnabledForSubscriber(SubscriptionManager.getDefaultSubId())) {
+        int shouldHideCarrierSettings = android.provider.Settings.Global.getInt(
+                mPhone.getContext().getContentResolver(),
+                android.provider.Settings.Global.HIDE_CARRIER_NETWORK_SETTINGS, 0);
+        if (shouldHideCarrierSettings == 1 ) {
             prefSet.removePreference(mButtonPreferredNetworkMode);
             prefSet.removePreference(mButtonEnabledNetworks);
             prefSet.removePreference(mLteDataServicePref);
@@ -263,11 +389,6 @@
             // change Preferred Network Mode.
             mButtonPreferredNetworkMode.setOnPreferenceChangeListener(this);
 
-            //Get the networkMode from Settings.System and displays it
-            int settingsNetworkMode = android.provider.Settings.Global.getInt(mPhone.getContext().
-                    getContentResolver(),android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
-                    preferredNetworkMode);
-            mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
             mCdmaOptions = new CdmaOptions(this, prefSet, mPhone);
             mGsmUmtsOptions = new GsmUmtsOptions(this, prefSet);
         } else {
@@ -323,12 +444,7 @@
                         R.array.preferred_network_mode_values_world_mode);
             }
             mButtonEnabledNetworks.setOnPreferenceChangeListener(this);
-            int settingsNetworkMode = android.provider.Settings.Global.getInt(
-                    mPhone.getContext().getContentResolver(),
-                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
-                    preferredNetworkMode);
             if (DBG) log("settingsNetworkMode: " + settingsNetworkMode);
-            mButtonEnabledNetworks.setValue(Integer.toString(settingsNetworkMode));
         }
 
         final boolean missingDataServiceUrl = TextUtils.isEmpty(
@@ -366,34 +482,13 @@
                 root.removePreference(ps);
             }
         }
-    }
 
-    @Override
-    protected void onResume() {
-        super.onResume();
-
-        if (mUnavailable) {
-            return;
-        }
-
-        // upon resumption from the sub-activity, make sure we re-enable the
-        // preferences.
-        getPreferenceScreen().setEnabled(true);
-
-        // Set UI state in onResume because a user could go home, launch some
-        // app to change this setting's backend, and re-launch this settings app
-        // and the UI state would be inconsistent with actual state
+        //Get the networkMode from Settings.System and displays it
         mButtonDataRoam.setChecked(mPhone.getDataRoamingEnabled());
-
-        if (getPreferenceScreen().findPreference(BUTTON_PREFERED_NETWORK_MODE) != null)  {
-            mPhone.getPreferredNetworkType(mHandler.obtainMessage(
-                    MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
-        }
-
-        if (getPreferenceScreen().findPreference(BUTTON_ENABLED_NETWORKS_KEY) != null)  {
-            mPhone.getPreferredNetworkType(mHandler.obtainMessage(
-                    MyHandler.MESSAGE_GET_PREFERRED_NETWORK_TYPE));
-        }
+        mButtonEnabledNetworks.setValue(Integer.toString(settingsNetworkMode));
+        mButtonPreferredNetworkMode.setValue(Integer.toString(settingsNetworkMode));
+        UpdatePreferredNetworkModeSummary(settingsNetworkMode);
+        UpdateEnabledNetworksValueAndSummary(settingsNetworkMode);
     }
 
     @Override
@@ -410,6 +505,7 @@
      * display value.
      */
     public boolean onPreferenceChange(Preference preference, Object objValue) {
+        final int phoneSubId = mPhone.getSubId();
         if (preference == mButtonPreferredNetworkMode) {
             //NOTE onPreferenceChange seems to be called even if there is no change
             //Check if the button value is changed from the System.Setting
@@ -418,7 +514,8 @@
             buttonNetworkMode = Integer.valueOf((String) objValue).intValue();
             int settingsNetworkMode = android.provider.Settings.Global.getInt(
                     mPhone.getContext().getContentResolver(),
-                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE, preferredNetworkMode);
+                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
+                    preferredNetworkMode);
             if (buttonNetworkMode != settingsNetworkMode) {
                 int modemNetworkMode;
                 // if new mode is invalid ignore it
@@ -447,7 +544,7 @@
                 UpdatePreferredNetworkModeSummary(buttonNetworkMode);
 
                 android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         buttonNetworkMode );
                 //Set the modem network mode
                 mPhone.setPreferredNetworkType(modemNetworkMode, mHandler
@@ -460,7 +557,8 @@
             if (DBG) log("buttonNetworkMode: " + buttonNetworkMode);
             int settingsNetworkMode = android.provider.Settings.Global.getInt(
                     mPhone.getContext().getContentResolver(),
-                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE, preferredNetworkMode);
+                    android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
+                    preferredNetworkMode);
             if (buttonNetworkMode != settingsNetworkMode) {
                 int modemNetworkMode;
                 // if new mode is invalid ignore it
@@ -483,7 +581,7 @@
                 UpdateEnabledNetworksValueAndSummary(buttonNetworkMode);
 
                 android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         buttonNetworkMode );
                 //Set the modem network mode
                 mPhone.setPreferredNetworkType(modemNetworkMode, mHandler
@@ -548,6 +646,7 @@
         }
 
         private void handleGetPreferredNetworkTypeResponse(Message msg) {
+            final int phoneSubId = mPhone.getSubId();
             AsyncResult ar = (AsyncResult) msg.obj;
 
             if (ar.exception == null) {
@@ -560,7 +659,7 @@
 
                 int settingsNetworkMode = android.provider.Settings.Global.getInt(
                         mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         preferredNetworkMode);
 
                 if (DBG) {
@@ -614,17 +713,18 @@
 
         private void handleSetPreferredNetworkTypeResponse(Message msg) {
             AsyncResult ar = (AsyncResult) msg.obj;
+            final int phoneSubId = mPhone.getSubId();
 
             if (ar.exception == null) {
                 int networkMode = Integer.valueOf(
                         mButtonPreferredNetworkMode.getValue()).intValue();
                 android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         networkMode );
                 networkMode = Integer.valueOf(
                         mButtonEnabledNetworks.getValue()).intValue();
                 android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         networkMode );
             } else {
                 mPhone.getPreferredNetworkType(obtainMessage(MESSAGE_GET_PREFERRED_NETWORK_TYPE));
@@ -632,12 +732,13 @@
         }
 
         private void resetNetworkModeToDefault() {
+            final int phoneSubId = mPhone.getSubId();
             //set the mButtonPreferredNetworkMode
             mButtonPreferredNetworkMode.setValue(Integer.toString(preferredNetworkMode));
             mButtonEnabledNetworks.setValue(Integer.toString(preferredNetworkMode));
             //set the Settings.System
             android.provider.Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE,
+                        android.provider.Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId,
                         preferredNetworkMode );
             //Set the Modem
             mPhone.setPreferredNetworkType(preferredNetworkMode,
@@ -924,4 +1025,24 @@
             systemSelect.setEnabled(enable);
         }
     }
+
+    /**
+     * finds a record with slotId.
+     * Since the number of SIMs are few, an array is fine.
+     */
+    public static SubscriptionInfo findRecordBySlotId(final int slotId) {
+        final List<SubscriptionInfo> subInfoList =
+            SubscriptionManager.getActiveSubscriptionInfoList();
+        final int subInfoLength = subInfoList.size();
+
+        for (int i = 0; i < subInfoLength; ++i) {
+            final SubscriptionInfo sir = subInfoList.get(i);
+            if (sir.getSimSlotIndex() == slotId) {
+                //Right now we take the first subscription on a SIM.
+                return sir;
+            }
+        }
+
+        return null;
+    }
 }
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e3d1a08..f0e37f2 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -47,7 +47,7 @@
 import android.telephony.RadioAccessFamily;
 import android.telephony.ServiceState;
 import android.telephony.SubscriptionManager;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.util.Log;
@@ -140,8 +140,6 @@
     SharedPreferences mTelephonySharedPreferences;
     private static final String PREF_CARRIERS_ALPHATAG_PREFIX = "carrier_alphtag_";
     private static final String PREF_CARRIERS_NUMBER_PREFIX = "carrier_number_";
-    private static final String PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX =
-            "carrier_simplified_network_settings_";
     private static final String PREF_ENABLE_VIDEO_CALLING = "enable_video_calling";
 
     /**
@@ -771,8 +769,8 @@
         }
 
         boolean isValid = false;
-        List<SubInfoRecord> slist = SubscriptionManager.getActiveSubInfoList();
-        for (SubInfoRecord subInfoRecord : slist) {
+        List<SubscriptionInfo> slist = SubscriptionManager.getActiveSubscriptionInfoList();
+        for (SubscriptionInfo subInfoRecord : slist) {
             if (subInfoRecord.getSubscriptionId() == subId) {
                 isValid = true;
                 break;
@@ -1853,12 +1851,13 @@
     @Override
     public boolean setPreferredNetworkType(int networkType) {
         enforceModifyPermissionOrCarrierPrivilege();
+        final int phoneSubId = mPhone.getSubId();
         if (DBG) log("setPreferredNetworkType: type " + networkType);
         Boolean success = (Boolean) sendRequest(CMD_SET_PREFERRED_NETWORK_TYPE, networkType);
         if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail"));
         if (success) {
             Settings.Global.putInt(mPhone.getContext().getContentResolver(),
-                    Settings.Global.PREFERRED_NETWORK_MODE, networkType);
+                    Settings.Global.PREFERRED_NETWORK_MODE + phoneSubId, networkType);
         }
         return success;
     }
@@ -1943,34 +1942,6 @@
     }
 
     @Override
-    public void enableSimplifiedNetworkSettingsForSubscriber(int subId, boolean enable) {
-        enforceModifyPermissionOrCarrierPrivilege();
-
-        String iccId = getIccId(subId);
-        if (iccId != null) {
-            String snsPrefKey = PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX + iccId;
-            SharedPreferences.Editor editor = mTelephonySharedPreferences.edit();
-            if (enable) {
-                editor.putBoolean(snsPrefKey, true);
-            } else {
-                editor.remove(snsPrefKey);
-            }
-            editor.commit();
-        }
-    }
-
-    @Override
-    public boolean getSimplifiedNetworkSettingsEnabledForSubscriber(int subId) {
-        enforceReadPermission();
-        String iccId = getIccId(subId);
-        if (iccId != null) {
-            String snsPrefKey = PREF_CARRIERS_SIMPLIFIED_NETWORK_SETTINGS_PREFIX + iccId;
-            return mTelephonySharedPreferences.getBoolean(snsPrefKey, false);
-        }
-        return false;
-    }
-
-    @Override
     public void setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, String number) {
         enforceModifyPermissionOrCarrierPrivilege();
 
diff --git a/src/com/android/phone/SubscriptionInfoHelper.java b/src/com/android/phone/SubscriptionInfoHelper.java
index 926a156..1255452 100644
--- a/src/com/android/phone/SubscriptionInfoHelper.java
+++ b/src/com/android/phone/SubscriptionInfoHelper.java
@@ -20,7 +20,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
 
@@ -75,7 +75,7 @@
         return intent;
     }
 
-    public static void addExtrasToIntent(Intent intent, SubInfoRecord subscription) {
+    public static void addExtrasToIntent(Intent intent, SubscriptionInfo subscription) {
         intent.putExtra(SubscriptionInfoHelper.SUB_ID_EXTRA, subscription.getSubscriptionId());
         intent.putExtra(
                 SubscriptionInfoHelper.SUB_LABEL_EXTRA, subscription.getDisplayName().toString());
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 5226e0d..a99c5f0 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -12,7 +12,7 @@
 import android.preference.PreferenceFragment;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.util.Log;
@@ -297,7 +297,7 @@
     }
 
     private void initAccountList() {
-        for (SubInfoRecord subscription : SubscriptionManager.getActiveSubInfoList()) {
+        for (SubscriptionInfo subscription : SubscriptionManager.getActiveSubscriptionInfoList()) {
             CharSequence label = subscription.getDisplayName();
             Intent intent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
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/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 49767a2..7bd396b 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -16,11 +16,8 @@
 
 package com.android.services.telephony;
 
-import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
 import android.telecom.PhoneAccount;
@@ -28,7 +25,8 @@
 import android.telecom.TelecomManager;
 import android.telephony.PhoneStateListener;
 import android.telephony.ServiceState;
-import android.telephony.SubInfoRecord;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionListener;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -36,7 +34,6 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.PhoneProxy;
-import com.android.internal.telephony.TelephonyIntents;
 import com.android.phone.R;
 
 import java.util.Arrays;
@@ -129,7 +126,7 @@
                 CharSequence subDisplayName = null;
                 // We can only get the real slotId from the SubInfoRecord, we can't calculate the
                 // slotId from the subId or the phoneId in all instances.
-                SubInfoRecord record = SubscriptionManager.getSubInfoForSubscriber(subId);
+                SubscriptionInfo record = SubscriptionManager.getSubscriptionInfoForSubscriber(subId);
                 if (record != null) {
                     subDisplayName = record.getDisplayName();
                     slotId = record.getSubscriptionId();
@@ -169,10 +166,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))
@@ -192,31 +186,12 @@
         return colors[((int) subId) % colors.length];
     }
 
-    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+    private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() {
         @Override
-        public void onReceive(Context context, Intent intent) {
-            boolean rebuildAccounts = false;
-            String action = intent.getAction();
-            if (TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED.equals(action)) {
-                int status = intent.getIntExtra(
-                        SubscriptionManager.INTENT_KEY_DETECT_STATUS,
-                        SubscriptionManager.EXTRA_VALUE_NOCHANGE);
-                Log.i(this, "SUBINFO_RECORD_UPDATED : %d.", status);
-                // Anytime the SIM state changes...rerun the setup
-                // We rely on this notification even when the status is EXTRA_VALUE_NOCHANGE,
-                // so we explicitly do not check for that here.
-                rebuildAccounts = true;
-            } else if (TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE.equals(action)) {
-                String columnName = intent.getStringExtra(TelephonyIntents.EXTRA_COLUMN_NAME);
-                String stringContent = intent.getStringExtra(TelephonyIntents.EXTRA_STRING_CONTENT);
-                Log.v(this, "SUBINFO_CONTENT_CHANGE: Column: %s Content: %s",
-                        columnName, stringContent);
-                rebuildAccounts = true;
-            }
-            if (rebuildAccounts) {
-                tearDownAccounts();
-                setupAccounts();
-            }
+        public void onSubscriptionInfoChanged() {
+            // Any time the SubscriptionInfo changes...rerun the setup
+            tearDownAccounts();
+            setupAccounts();
         }
     };
 
@@ -256,12 +231,14 @@
      * Sets up all the phone accounts for SIMs on first boot.
      */
     void setupOnBoot() {
-        // We need to register for both types of intents if we want to see added/removed Subs
-        // along with changes to a given Sub.
-        IntentFilter intentFilter = new IntentFilter();
-        intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED);
-        intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE);
-        mContext.registerReceiver(mReceiver, intentFilter);
+        // TODO: When this object "finishes" we should unregister by invoking
+        // SubscriptionManager.unregister(mContext, mSubscriptionListener);
+        // This is not strictly necessary because it will be unregistered if the
+        // notification fails but it is good form.
+
+        // Register for SubscriptionInfo list changes
+        SubscriptionManager.register(mContext, mSubscriptionListener,
+                SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED);
 
         // We also need to listen for changes to the service state (e.g. emergency -> in service)
         // because this could signal a removal or addition of a SIM in a single SIM phone.