merge in lmp-mr1-release history after reset to lmp-mr1-dev
diff --git a/src/java/com/android/internal/telephony/CommandsInterface.java b/src/java/com/android/internal/telephony/CommandsInterface.java
index a2cbf96..07662aa 100644
--- a/src/java/com/android/internal/telephony/CommandsInterface.java
+++ b/src/java/com/android/internal/telephony/CommandsInterface.java
@@ -94,12 +94,8 @@
 
     // Numeric representation of string values returned
     // by messages sent to setOnUSSD handler
-    static final int USSD_MODE_NOTIFY        = 0;
-    static final int USSD_MODE_REQUEST       = 1;
-    static final int USSD_MODE_NW_RELEASE    = 2;
-    static final int USSD_MODE_LOCAL_CLIENT  = 3;
-    static final int USSD_MODE_NOT_SUPPORTED = 4;
-    static final int USSD_MODE_NW_TIMEOUT    = 5;
+    static final int USSD_MODE_NOTIFY       = 0;
+    static final int USSD_MODE_REQUEST      = 1;
 
     // GSM SMS fail cause for acknowledgeLastIncomingSMS. From TS 23.040, 9.2.3.22.
     static final int GSM_SMS_FAIL_CAUSE_MEMORY_CAPACITY_EXCEEDED    = 0xD3;
diff --git a/src/java/com/android/internal/telephony/Connection.java b/src/java/com/android/internal/telephony/Connection.java
index 4ea8d29..0fa4026 100644
--- a/src/java/com/android/internal/telephony/Connection.java
+++ b/src/java/com/android/internal/telephony/Connection.java
@@ -47,7 +47,7 @@
         public void onVideoProviderChanged(
                 android.telecom.Connection.VideoProvider videoProvider);
         public void onAudioQualityChanged(int audioQuality);
-        public void onConferenceParticipantsChanged(List<ConferenceParticipant> participants);
+        public void onConferenceParticipantChanged(ConferenceParticipant participant);
     }
 
     /**
@@ -66,7 +66,7 @@
         @Override
         public void onAudioQualityChanged(int audioQuality) {}
         @Override
-        public void onConferenceParticipantsChanged(List<ConferenceParticipant> participants) {}
+        public void onConferenceParticipantChanged(ConferenceParticipant participant) {}
     }
 
     public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -548,13 +548,13 @@
     }
 
     /**
-     * Notifies listeners of a change to conference participant(s).
+     * Notifies listeners of a change to a conference participant.
      *
-     * @param conferenceParticipants The participant(s).
+     * @param conferenceParticipant The participant.
      */
-    public void updateConferenceParticipants(List<ConferenceParticipant> conferenceParticipants) {
+    public void updateConferenceParticipant(ConferenceParticipant conferenceParticipant) {
         for (Listener l : mListeners) {
-            l.onConferenceParticipantsChanged(conferenceParticipants);
+            l.onConferenceParticipantChanged(conferenceParticipant);
         }
     }
 
diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
index 73d52fb..56a9069 100644
--- a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
+++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
@@ -1071,7 +1071,7 @@
 
     private String filterDestAddress(String destAddr) {
         String result  = null;
-        result = SmsNumberUtils.filterDestAddr(mPhone, destAddr);
+        result = SmsNumberUtils.filterDestAddr(mContext, destAddr);
         return result != null ? result : destAddr;
     }
 
diff --git a/src/java/com/android/internal/telephony/SmsNumberUtils.java b/src/java/com/android/internal/telephony/SmsNumberUtils.java
index b785a67..8672ffc 100644
--- a/src/java/com/android/internal/telephony/SmsNumberUtils.java
+++ b/src/java/com/android/internal/telephony/SmsNumberUtils.java
@@ -23,8 +23,6 @@
 
 import android.content.Context;
 import android.os.SystemProperties;
-import android.os.Build;
-import android.text.TextUtils;
 import android.content.ContentResolver;
 import android.database.Cursor;
 import android.database.SQLException;
@@ -43,7 +41,7 @@
  */
 public class SmsNumberUtils {
     private static final String TAG = "SmsNumberUtils";
-    private static final boolean DBG = Build.IS_DEBUGGABLE;
+    private static final boolean DBG = false;
 
     private static final String PLUS_SIGN = "+";
 
@@ -530,7 +528,7 @@
     /**
      *  Filter the destination number if using VZW sim card.
      */
-    public static String filterDestAddr(PhoneBase phoneBase, String destAddr) {
+    public static String filterDestAddr(Context context, String destAddr) {
         if (DBG) Rlog.d(TAG, "enter filterDestAddr. destAddr=\"" + destAddr + "\"" );
 
         if (destAddr == null || !PhoneNumberUtils.isGlobalPhoneNumber(destAddr)) {
@@ -541,12 +539,12 @@
         final String networkOperator = TelephonyManager.getDefault().getNetworkOperator();
         String result = null;
 
-        if (needToConvert(phoneBase)) {
-            final int networkType = getNetworkType(phoneBase);
+        if (isVZWSimCard()) {
+            final int networkType = getNetworkType(networkOperator);
             if (networkType != -1) {
                 String networkMcc = networkOperator.substring(0, 3);
                 if (networkMcc != null && networkMcc.trim().length() > 0) {
-                    result = formatNumber(phoneBase.getContext(), destAddr, networkMcc, networkType);
+                    result = formatNumber(context, destAddr, networkMcc, networkType);
                 }
             }
         }
@@ -558,17 +556,17 @@
     /**
      * Returns the current network type
      */
-    private static int getNetworkType(PhoneBase phoneBase) {
+    private static int getNetworkType(String networkOperator) {
         int networkType = -1;
         int phoneType = TelephonyManager.getDefault().getPhoneType();
 
         if (phoneType == TelephonyManager.PHONE_TYPE_GSM) {
             networkType = GSM_UMTS_NETWORK;
         } else if (phoneType == TelephonyManager.PHONE_TYPE_CDMA) {
-            if (isInternationalRoaming(phoneBase)) {
-                networkType = CDMA_ROAMING_NETWORK;
-            } else {
+            if (isVZWNetwork(networkOperator)) {
                 networkType = CDMA_HOME_NETWORK;
+            } else {
+                networkType = CDMA_ROAMING_NETWORK;
             }
         } else {
             if (DBG) Rlog.w(TAG, "warning! unknown mPhoneType value=" + phoneType);
@@ -577,66 +575,24 @@
         return networkType;
     }
 
-    private static boolean isInternationalRoaming(PhoneBase phoneBase) {
-        String operatorIsoCountry = phoneBase.getSystemProperty(
-                TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, "");
-        String simIsoCountry = phoneBase.getSystemProperty(
-                TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY, "");
-        boolean internationalRoaming = !TextUtils.isEmpty(operatorIsoCountry)
-                && !TextUtils.isEmpty(simIsoCountry)
-                && !simIsoCountry.equals(operatorIsoCountry);
-        if (internationalRoaming) {
-            if ("us".equals(simIsoCountry)) {
-                internationalRoaming = !"vi".equals(operatorIsoCountry);
-            } else if ("vi".equals(simIsoCountry)) {
-                internationalRoaming = !"us".equals(operatorIsoCountry);
-            }
-        }
-        return internationalRoaming;
+    /**
+     * VZW Network Operator List.
+     * Refers to the wiki link : http://en.wikipedia.org/wiki/Mobile_Network_Code
+     */
+    private final static List<String> sVZWNetworkOperatorList = Arrays.asList("310004", "310005",
+            "310012", "311480");
+
+    private final static List<String> sVZWSimcardOperatorList = Arrays.asList("20404", "310004",
+            "311480");
+
+    private static boolean isVZWSimCard() {
+        String simOperator =
+                SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC);
+        return sVZWSimcardOperatorList.contains(simOperator);
     }
 
-    private static boolean needToConvert(PhoneBase phoneBase) {
-        boolean bNeedToConvert  = false;
-        String[] listArray = phoneBase.getContext().getResources()
-                .getStringArray(com.android.internal.R.array
-                .config_sms_convert_destination_number_support);
-        if (listArray != null && listArray.length > 0) {
-            for (int i=0; i<listArray.length; i++) {
-                if (!TextUtils.isEmpty(listArray[i])) {
-                    String[] needToConvertArray = listArray[i].split(";");
-                    if (needToConvertArray != null && needToConvertArray.length > 0) {
-                        if (needToConvertArray.length == 1) {
-                            bNeedToConvert = "true".equalsIgnoreCase(needToConvertArray[0]);
-                        } else if (needToConvertArray.length == 2 &&
-                                !TextUtils.isEmpty(needToConvertArray[1]) &&
-                                compareGid1(phoneBase, needToConvertArray[1])) {
-                            bNeedToConvert = "true".equalsIgnoreCase(needToConvertArray[0]);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        return bNeedToConvert;
+    private static boolean isVZWNetwork(String networkOperator) {
+        return sVZWNetworkOperatorList.contains(networkOperator);
     }
 
-    private static boolean compareGid1(PhoneBase phoneBase, String serviceGid1) {
-        String gid1 = phoneBase.getGroupIdLevel1();
-        boolean ret = true;
-
-        if (TextUtils.isEmpty(serviceGid1)) {
-            if (DBG) Rlog.d(TAG, "compareGid1 serviceGid is empty, return " + ret);
-            return ret;
-        }
-
-        int gid_length = serviceGid1.length();
-        // Check if gid1 match service GID1
-        if (!((gid1 != null) && (gid1.length() >= gid_length) &&
-                gid1.substring(0, gid_length).equalsIgnoreCase(serviceGid1))) {
-            if (DBG) Rlog.d(TAG, " gid1 " + gid1 + " serviceGid1 " + serviceGid1);
-            ret = false;
-        }
-        if (DBG) Rlog.d(TAG, "compareGid1 is " + (ret?"Same":"Different"));
-        return ret;
-    }
 }
diff --git a/src/java/com/android/internal/telephony/SubInfoRecordUpdater.java b/src/java/com/android/internal/telephony/SubInfoRecordUpdater.java
index 872d76d..9c0705e 100644
--- a/src/java/com/android/internal/telephony/SubInfoRecordUpdater.java
+++ b/src/java/com/android/internal/telephony/SubInfoRecordUpdater.java
@@ -24,29 +24,24 @@
 import android.content.ContentValues;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.SharedPreferences;
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
-import android.os.SystemProperties;
 import android.os.UserHandle;
-import android.preference.PreferenceManager;
-import android.provider.Settings;
 import android.telephony.Rlog;
 import android.telephony.SubscriptionManager;
 import android.telephony.SubInfoRecord;
 import android.telephony.TelephonyManager;
-import android.util.Log;
-
+import com.android.internal.telephony.CommandsInterface;
+import com.android.internal.telephony.IccCardConstants;
+import com.android.internal.telephony.Phone;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.PhoneProxy;
+import com.android.internal.telephony.TelephonyIntents;
 import com.android.internal.telephony.uicc.IccConstants;
 import com.android.internal.telephony.uicc.IccFileHandler;
 import com.android.internal.telephony.uicc.IccUtils;
 import com.android.internal.telephony.uicc.SpnOverride;
-import android.provider.Telephony;
-import android.content.ContentUris;
-import android.net.Uri;
-import android.database.Cursor;
-import android.text.TextUtils;
 
 import java.util.List;
 
@@ -82,9 +77,6 @@
     public static final int STATUS_SIM3_INSERTED = 0x04;
     public static final int STATUS_SIM4_INSERTED = 0x08;
 
-    // Key used to read/write the current IMSI. Updated on SIM_STATE_CHANGED - LOADED.
-    public static final String CURR_IMSI = "curr_imsi";
-
     private static Phone[] sPhone;
     private static Context sContext = null;
     private static IccFileHandler[] sFh = new IccFileHandler[PROJECT_SIM_NUM];
@@ -154,55 +146,27 @@
                                 SubscriptionManager.getSubInfoForSubscriber(subId);
 
                         if (subInfo != null
-                                && subInfo.getNameSource() !=
-                                SubscriptionManager.NAME_SOURCE_USER_INPUT) {
+                                && subInfo.getNameSource() != SubscriptionManager.NAME_SOURCE_USER_INPUT) {
+                            SpnOverride mSpnOverride = new SpnOverride();
                             String nameToSet;
                             String CarrierName =
                                     TelephonyManager.getDefault().getSimOperator(subId);
                             logd("CarrierName = " + CarrierName);
-                            String simCarrierName =
-                                    TelephonyManager.getDefault().getSimOperatorName(subId);
 
-                            if (!TextUtils.isEmpty(simCarrierName)) {
-                                nameToSet = simCarrierName;
+                            if (mSpnOverride.containsCarrier(CarrierName)) {
+                                nameToSet = mSpnOverride.getSpn(CarrierName) + " 0"
+                                        + Integer.toString(slotId + 1);
+                                logd("Found, name = " + nameToSet);
                             } else {
-                                nameToSet = "CARD " + Integer.toString(slotId + 1);
+                                nameToSet = "";
+                                logd("Not found, name = " + nameToSet);
                             }
-                            logd("sim name = " + nameToSet + " carrier name = " + simCarrierName);
 
                             ContentValues name = new ContentValues(1);
                             name.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
-                            name.put(SubscriptionManager.CARRIER_NAME,
-                                    !TextUtils.isEmpty(simCarrierName) ? simCarrierName :
-                                    sContext.getString(com.android.internal.R.string.unknownName));
                             contentResolver.update(SubscriptionManager.CONTENT_URI, name,
                                     SubscriptionManager._ID + "=" + Long.toString(subId), null);
                         }
-
-                        /* Update preferred network type and network selection mode on IMSI change.
-                         * Storing last IMSI in SharedPreference for now. Can consider making it
-                         * part of subscription info db */
-                        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
-                        String storedImsi = sp.getString(CURR_IMSI + slotId, "");
-                        String newImsi = sPhone[slotId].getSubscriberId();
-
-                        if (!storedImsi.equals(newImsi)) {
-                            int networkType = SystemProperties.getInt("ro.telephony.default_network",
-                                    RILConstants.PREFERRED_NETWORK_MODE);
-
-                            // Set the modem network mode
-                            sPhone[slotId].setPreferredNetworkType(networkType, null);
-                            Settings.Global.putInt(sPhone[slotId].getContext().getContentResolver(),
-                                    Settings.Global.PREFERRED_NETWORK_MODE, networkType);
-
-                            // Only support automatic selection mode on IMSI change
-                            sPhone[slotId].setNetworkSelectionModeAutomatic(null);
-
-                            // Update stored IMSI
-                            SharedPreferences.Editor editor = sp.edit();
-                            editor.putString(CURR_IMSI + slotId, newImsi);
-                            editor.apply();
-                        }
                     } else {
                         logd("[Receiver] Invalid subId, could not update ContentResolver");
                     }
diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
index 24f7ef4..de757d4 100644
--- a/src/java/com/android/internal/telephony/SubscriptionController.java
+++ b/src/java/com/android/internal/telephony/SubscriptionController.java
@@ -16,36 +16,37 @@
 
 package com.android.internal.telephony;
 
-import android.content.ContentResolver;
-import android.content.ContentValues;
 import android.content.Context;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.net.Uri;
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
 import android.os.ServiceManager;
 import android.os.UserHandle;
+import android.telephony.Rlog;
+import android.util.Log;
+import android.net.Uri;
+import android.database.Cursor;
+import android.content.Intent;
 import android.provider.BaseColumns;
 import android.provider.Settings;
-import android.telephony.Rlog;
-import android.telephony.SubInfoRecord;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+
+import com.android.internal.telephony.ISub;
+import com.android.internal.telephony.uicc.SpnOverride;
+
 import android.telephony.SubscriptionManager;
+import android.telephony.SubInfoRecord;
 import android.telephony.TelephonyManager;
-import android.text.TextUtils;
 import android.text.format.Time;
-import android.util.Log;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.HashMap;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -119,6 +120,12 @@
     protected Context mContext;
     protected CallManager mCM;
 
+    private static final int RES_TYPE_BACKGROUND_DARK = 0;
+    private static final int RES_TYPE_BACKGROUND_LIGHT = 1;
+
+    private static final int[] sSimBackgroundDarkRes = setSimResource(RES_TYPE_BACKGROUND_DARK);
+    private static final int[] sSimBackgroundLightRes = setSimResource(RES_TYPE_BACKGROUND_LIGHT);
+
     //FIXME this does not allow for multiple subs in a slot
     private static HashMap<Integer, Integer> mSimInfo = new HashMap<Integer, Integer>();
     private static int mDefaultVoiceSubId = SubscriptionManager.INVALID_SUB_ID;
@@ -253,31 +260,32 @@
                     SubscriptionManager.SIM_ID));
             String displayName = cursor.getString(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.DISPLAY_NAME));
-            String carrierName = cursor.getString(cursor.getColumnIndexOrThrow(
-                    SubscriptionManager.CARRIER_NAME));
             int nameSource = cursor.getInt(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.NAME_SOURCE));
-            int iconTint = cursor.getInt(cursor.getColumnIndexOrThrow(
+            int color = cursor.getInt(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.COLOR));
             String number = cursor.getString(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.NUMBER));
             int dataRoaming = cursor.getInt(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.DATA_ROAMING));
-            // Get the blank bitmap for this SubInfoRecord
-            Bitmap iconBitmap = BitmapFactory.decodeResource(mContext.getResources(),
-                    com.android.internal.R.drawable.sim_dark_blue);
+
+            int[] simIconRes = new int[2];
+            int size = sSimBackgroundDarkRes.length;
+            if (color >= 0 && color < size) {
+                simIconRes[RES_TYPE_BACKGROUND_DARK] = sSimBackgroundDarkRes[color];
+                simIconRes[RES_TYPE_BACKGROUND_LIGHT] = sSimBackgroundLightRes[color];
+            }
             int mcc = cursor.getInt(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.MCC));
             int mnc = cursor.getInt(cursor.getColumnIndexOrThrow(
                     SubscriptionManager.MNC));
 
             logd("[getSubInfoRecord] id:" + id + " iccid:" + iccId + " simSlotIndex:" + simSlotIndex
-                    + " displayName:" + displayName + " nameSource:" + nameSource
-                    + " iconTint:" + iconTint + " number:" + number + " dataRoaming:" + dataRoaming
-                    + " mcc:" + mcc + " mnc:" + mnc);
+                    + " displayName:" + displayName + " color:" + color + " mcc:" + mcc
+                    + " mnc:" + mnc);
 
-            return new SubInfoRecord(id, iccId, simSlotIndex, displayName, carrierName, nameSource,
-                    iconTint, number, dataRoaming, iconBitmap, mcc, mnc);
+            return new SubInfoRecord(id, iccId, simSlotIndex, displayName, nameSource, color,
+                    number, dataRoaming, simIconRes, mcc, mnc);
     }
 
     /**
@@ -327,10 +335,11 @@
     private int getUnusedColor() {
         List<SubInfoRecord> availableSubInfos = SubscriptionManager.getActiveSubInfoList();
         colorArr = mContext.getResources().getIntArray(com.android.internal.R.array.sim_colors);
+
         for (int i = 0; i < colorArr.length; i++) {
             int j;
             for (j = 0; j < availableSubInfos.size(); j++) {
-                if (colorArr[i] == availableSubInfos.get(j).getIconTint()) {
+                if (colorArr[i] == availableSubInfos.get(j).getColor()) {
                     break;
                 }
             }
@@ -541,18 +550,18 @@
         }
 
         String nameToSet;
+        SpnOverride mSpnOverride = new SpnOverride();
+
         String CarrierName = TelephonyManager.getDefault().getSimOperator(subIds[0]);
         logdl("[addSubInfoRecord] CarrierName = " + CarrierName);
-        String simCarrierName =
-                TelephonyManager.getDefault().getSimOperatorName(subIds[0]);
 
-        if (!TextUtils.isEmpty(simCarrierName)) {
-            nameToSet = simCarrierName;
+        if (mSpnOverride.containsCarrier(CarrierName)) {
+            nameToSet = mSpnOverride.getSpn(CarrierName) + " 0" + Integer.toString(slotId + 1);
+            logdl("[addSubInfoRecord] SpnOverride set name=" + nameToSet);
         } else {
-            nameToSet = "CARD " + Integer.toString(slotId + 1);
+            nameToSet = "";
+            logdl("[addSubInfoRecord] no SpnOverride");
         }
-        logdl("[addSubInfoRecord] sim name = " + nameToSet);
-        logdl("[addSubInfoRecord] carrier name = " + simCarrierName);
 
         ContentResolver resolver = mContext.getContentResolver();
         Cursor cursor = resolver.query(SubscriptionManager.CONTENT_URI,
@@ -570,9 +579,6 @@
                 value.put(SubscriptionManager.COLOR, color);
                 value.put(SubscriptionManager.SIM_ID, slotId);
                 value.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
-                value.put(SubscriptionManager.CARRIER_NAME,
-                        !TextUtils.isEmpty(simCarrierName) ? simCarrierName :
-                        mContext.getString(com.android.internal.R.string.unknownName));
                 Uri uri = resolver.insert(SubscriptionManager.CONTENT_URI, value);
                 logdl("[addSubInfoRecord]- New record created: " + uri);
             } else {
@@ -589,10 +595,6 @@
                     value.put(SubscriptionManager.DISPLAY_NAME, nameToSet);
                 }
 
-                if (!TextUtils.isEmpty(simCarrierName)) {
-                    value.put(SubscriptionManager.CARRIER_NAME, simCarrierName);
-                }
-
                 if (value.size() > 0) {
                     resolver.update(SubscriptionManager.CONTENT_URI, value,
                             BaseColumns._ID + "=" + Long.toString(subId), null);
@@ -664,25 +666,26 @@
     }
 
     /**
-     * Set SIM color tint by simInfo index
-     * @param tint the tint color of the SIM
+     * Set SIM color by simInfo index
+     * @param color the color of the SIM
      * @param subId the unique SubInfoRecord index in database
      * @return the number of records updated
      */
     @Override
-    public int setIconTint(int tint, int subId) {
-        logd("[setIconTint]+ tint:" + tint + " subId:" + subId);
+    public int setColor(int color, int subId) {
+        logd("[setColor]+ color:" + color + " subId:" + subId);
         enforceSubscriptionPermission();
 
         validateSubId(subId);
+        int size = sSimBackgroundDarkRes.length;
         ContentValues value = new ContentValues(1);
-        value.put(SubscriptionManager.COLOR, tint);
-        logd("[setIconTint]- tint:" + tint + " set");
+        value.put(SubscriptionManager.COLOR, color);
+        logd("[setColor]- color:" + color + " set");
 
         int result = mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value,
                 BaseColumns._ID + "=" + Long.toString(subId), null);
         broadcastSimInfoContentChanged(subId, SubscriptionManager.COLOR,
-                tint, SubscriptionManager.DEFAULT_STRING_VALUE);
+                color, SubscriptionManager.DEFAULT_STRING_VALUE);
 
         return result;
     }
@@ -787,6 +790,34 @@
     }
 
     /**
+     * Set number display format. 0: none, 1: the first four digits, 2: the last four digits
+     * @param format the display format of phone number
+     * @param subId the unique SubInfoRecord index in database
+     * @return the number of records updated
+     */
+    @Override
+    public int setDisplayNumberFormat(int format, int subId) {
+        logd("[setDisplayNumberFormat]+ format:" + format + " subId:" + subId);
+        enforceSubscriptionPermission();
+
+        validateSubId(subId);
+        if (format < 0) {
+            logd("[setDisplayNumberFormat]- fail, return -1");
+            return -1;
+        }
+        ContentValues value = new ContentValues(1);
+        value.put(SubscriptionManager.DISPLAY_NUMBER_FORMAT, format);
+        logd("[setDisplayNumberFormat]- format:" + format + " set");
+
+        int result = mContext.getContentResolver().update(SubscriptionManager.CONTENT_URI, value,
+                BaseColumns._ID + "=" + Long.toString(subId), null);
+        broadcastSimInfoContentChanged(subId, SubscriptionManager.DISPLAY_NUMBER_FORMAT,
+                format, SubscriptionManager.DEFAULT_STRING_VALUE);
+
+        return result;
+    }
+
+    /**
      * Set data roaming by simInfo index
      * @param roaming 0:Don't allow data when roaming, 1:Allow data when roaming
      * @param subId the unique SubInfoRecord index in database
@@ -1005,6 +1036,31 @@
         return size;
     }
 
+    private static int[] setSimResource(int type) {
+        int[] simResource = null;
+
+        switch (type) {
+            case RES_TYPE_BACKGROUND_DARK:
+                simResource = new int[] {
+                    com.android.internal.R.drawable.sim_dark_blue,
+                    com.android.internal.R.drawable.sim_dark_orange,
+                    com.android.internal.R.drawable.sim_dark_green,
+                    com.android.internal.R.drawable.sim_dark_purple
+                };
+                break;
+            case RES_TYPE_BACKGROUND_LIGHT:
+                simResource = new int[] {
+                    com.android.internal.R.drawable.sim_light_blue,
+                    com.android.internal.R.drawable.sim_light_orange,
+                    com.android.internal.R.drawable.sim_light_green,
+                    com.android.internal.R.drawable.sim_light_purple
+                };
+                break;
+        }
+
+        return simResource;
+    }
+
     private void logvl(String msg) {
         logv(msg);
         mLocalLog.log(msg);
diff --git a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
index 5b31ff5..f2ca37a 100644
--- a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
+++ b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
@@ -424,14 +424,6 @@
             Rlog.w(LOG_TAG, "IMS is disabled: forced to CS");
         }
 
-        if (DBG) {
-            Rlog.d(LOG_TAG, "imsUseEnabled=" + imsUseEnabled + ", imsPhone=" + imsPhone
-                    + ", imsPhone.isVolteEnabled()="
-                    + ((imsPhone != null) ? imsPhone.isVolteEnabled() : "N/A")
-                    + ", imsPhone.getServiceState().getState()="
-                    + ((imsPhone != null) ? imsPhone.getServiceState().getState() : "N/A"));
-        }
-
         if (imsUseEnabled && imsPhone != null && imsPhone.isVolteEnabled()
                 && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE
                 && !PhoneNumberUtils.isEmergencyNumber(dialString))
diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
index c6b5ab6..f96fdc2 100644
--- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -809,14 +809,6 @@
             Rlog.w(LOG_TAG, "IMS is disabled: forced to CS");
         }
 
-        if (LOCAL_DEBUG) {
-            Rlog.d(LOG_TAG, "imsUseEnabled=" + imsUseEnabled + ", imsPhone=" + imsPhone
-                    + ", imsPhone.isVolteEnabled()="
-                    + ((imsPhone != null) ? imsPhone.isVolteEnabled() : "N/A")
-                    + ", imsPhone.getServiceState().getState()="
-                    + ((imsPhone != null) ? imsPhone.getServiceState().getState() : "N/A"));
-        }
-
         if (imsUseEnabled && imsPhone != null && imsPhone.isVolteEnabled()
                 && ((imsPhone.getServiceState().getState() == ServiceState.STATE_IN_SERVICE
                 && !PhoneNumberUtils.isEmergencyNumber(dialString))
@@ -1105,7 +1097,6 @@
         }
     }
 
-    @Override
     public String getSystemProperty(String property, String defValue) {
         if(getUnitTestMode()) {
             return null;
@@ -1331,7 +1322,6 @@
     onIncomingUSSD (int ussdMode, String ussdMessage) {
         boolean isUssdError;
         boolean isUssdRequest;
-        boolean isUssdRelease;
 
         isUssdRequest
             = (ussdMode == CommandsInterface.USSD_MODE_REQUEST);
@@ -1340,8 +1330,6 @@
             = (ussdMode != CommandsInterface.USSD_MODE_NOTIFY
                 && ussdMode != CommandsInterface.USSD_MODE_REQUEST);
 
-        isUssdRelease = (ussdMode == CommandsInterface.USSD_MODE_NW_RELEASE);
-
         // See comments in GsmMmiCode.java
         // USSD requests aren't finished until one
         // of these two events happen
@@ -1356,9 +1344,7 @@
         if (found != null) {
             // Complete pending USSD
 
-            if (isUssdRelease) {
-                found.onUssdRelease();
-            } else if (isUssdError) {
+            if (isUssdError) {
                 found.onUssdFinishedError();
             } else {
                 found.onUssdFinished(ussdMessage, isUssdRequest);
@@ -1595,7 +1581,7 @@
     }
 
     protected UiccCardApplication getUiccCardApplication() {
-            return  mUiccController.getUiccCardApplication(mPhoneId,
+            return  ((UiccController) mUiccController).getUiccCardApplication(mPhoneId,
                     UiccController.APP_FAM_3GPP);
     }
 
@@ -1876,12 +1862,10 @@
      * @param what User-defined message code
      * @param obj placed in Message.obj
      */
-    @Override
     public void registerForEcmTimerReset(Handler h, int what, Object obj) {
         mEcmTimerResetRegistrants.addUnique(h, what, obj);
     }
 
-    @Override
     public void unregisterForEcmTimerReset(Handler h) {
         mEcmTimerResetRegistrants.remove(h);
     }
diff --git a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
index 0e7885a..90e783e 100644
--- a/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
+++ b/src/java/com/android/internal/telephony/gsm/GsmMmiCode.java
@@ -898,25 +898,6 @@
         }
     }
 
-    /**
-     * Called from GSMPhone
-     *
-     * An unsolicited USSD NOTIFY or REQUEST has come in matching
-     * up with this pending USSD request
-     *
-     * Note: If REQUEST, this exchange is complete, but the session remains
-     *       active (ie, the network expects user input).
-     */
-    void
-    onUssdRelease() {
-        if (mState == State.PENDING) {
-            mState = State.COMPLETE;
-            mMessage = null;
-
-            mPhone.onMMIDone(this);
-        }
-    }
-
     void sendUssd(String ussdMessage) {
         // Treat this as a USSD string
         mIsPendingUSSD = true;
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
index b3cfc97..83a1901 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneCallTracker.java
@@ -1104,19 +1104,19 @@
         }
 
         /**
-         * Called when the state of IMS conference participant(s) has changed.
+         * Called when the state of an IMS conference participant has changed.
          *
          * @param call the call object that carries out the IMS call.
-         * @param participants the participant(s) and their new state information.
+         * @param participant the participant and its new state information.
          */
         @Override
-        public void onConferenceParticipantsStateChanged(ImsCall call,
-                List<ConferenceParticipant> participants) {
-            if (DBG) log("onConferenceParticipantsStateChanged");
+        public void onConferenceParticipantStateChanged(ImsCall call,
+                ConferenceParticipant participant) {
+            if (DBG) log("onConferenceParticipantStateChanged");
 
             ImsPhoneConnection conn = findConnection(call);
             if (conn != null) {
-                conn.updateConferenceParticipants(participants);
+                conn.updateConferenceParticipant(participant);
             }
         }
     };
diff --git a/src/java/com/android/internal/telephony/uicc/UiccCarrierPrivilegeRules.java b/src/java/com/android/internal/telephony/uicc/UiccCarrierPrivilegeRules.java
index fe2db783c..308e239 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccCarrierPrivilegeRules.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccCarrierPrivilegeRules.java
@@ -83,7 +83,7 @@
      *   REF_DO = TAG_REF_DO + len + DEVICE_APP_ID_REF_DO + (optional) PKG_REF_DO
      *   AR_DO = TAG_AR_DO + len + PERM_AR_DO
      *
-     *   DEVICE_APP_ID_REF_DO = TAG_DEVICE_APP_ID_REF_DO + len + sha256 hexstring of cert
+     *   DEVICE_APP_ID_REF_DO = TAG_DEVICE_APP_ID_REF_DO + len + sha1 hexstring of cert (20 bytes)
      *   PKG_REF_DO = TAG_PKG_REF_DO + len + package name
      *   PERM_AR_DO = TAG_PERM_AR_DO + len + detailed permission (8 bytes)
      *
@@ -219,13 +219,14 @@
             return TelephonyManager.CARRIER_PRIVILEGE_STATUS_ERROR_LOADING_RULES;
         }
 
-        // SHA-1 is for backward compatible support only, strongly discouraged for new use.
-        byte[] certHash = getCertHash(signature, "SHA-1");
-        byte[] certHash256 = getCertHash(signature, "SHA-256");
-        Rlog.d(LOG_TAG, "Checking SHA1: " + IccUtils.bytesToHexString(certHash) + " : " + packageName);
-        Rlog.d(LOG_TAG, "Checking SHA256: " + IccUtils.bytesToHexString(certHash256) + " : " + packageName);
+        byte[] certHash = getCertHash(signature);
+        if (certHash == null) {
+          return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
+        }
+        Rlog.e(LOG_TAG, "Checking: " + IccUtils.bytesToHexString(certHash) + " : " + packageName);
+
         for (AccessRule ar : mAccessRules) {
-            if (ar.matches(certHash, packageName) || ar.matches(certHash256, packageName)) {
+            if (ar.matches(certHash, packageName)) {
                 Rlog.d(LOG_TAG, "Match found!");
                 return TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS;
             }
@@ -454,13 +455,22 @@
     /*
      * Converts a Signature into a Certificate hash usable for comparison.
      */
-    private static byte[] getCertHash(Signature signature, String algo) {
+    private static byte[] getCertHash(Signature signature) {
+        // TODO: Is the following sufficient.
         try {
-            MessageDigest md = MessageDigest.getInstance(algo);
-            return md.digest(signature.toByteArray());
+            CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
+            X509Certificate cert = (X509Certificate) certFactory.generateCertificate(
+                    new ByteArrayInputStream(signature.toByteArray()));
+
+            MessageDigest md = MessageDigest.getInstance("SHA");
+            return md.digest(cert.getEncoded());
+        } catch (CertificateException ex) {
+            Rlog.e(LOG_TAG, "CertificateException: " + ex);
         } catch (NoSuchAlgorithmException ex) {
             Rlog.e(LOG_TAG, "NoSuchAlgorithmException: " + ex);
         }
+
+        Rlog.e(LOG_TAG, "Cannot compute cert hash");
         return null;
     }