Merge changes from topic "stk_carrier_config"

* changes:
  Replace SubscriptionManager.getSubId() with other method
  Retrieve appropriate carrier configuration associated with SIM card
diff --git a/src/com/android/stk/StkAppService.java b/src/com/android/stk/StkAppService.java
index 3d8d26e..2c51efe 100644
--- a/src/com/android/stk/StkAppService.java
+++ b/src/com/android/stk/StkAppService.java
@@ -57,6 +57,7 @@
 import android.provider.Settings;
 import android.support.v4.content.LocalBroadcastManager;
 import android.telephony.CarrierConfigManager;
+import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -991,23 +992,26 @@
     /**
      * Get the boolean config from carrier config manager.
      *
-     * @param context the context to get carrier service
      * @param key config key defined in CarrierConfigManager
+     * @param slotId slot ID.
      * @return boolean value of corresponding key.
      */
-    private static boolean getBooleanCarrierConfig(Context context, String key) {
-        CarrierConfigManager configManager = (CarrierConfigManager) context.getSystemService(
-                Context.CARRIER_CONFIG_SERVICE);
+    private boolean getBooleanCarrierConfig(String key, int slotId) {
+        CarrierConfigManager ccm = (CarrierConfigManager) getSystemService(CARRIER_CONFIG_SERVICE);
+        SubscriptionManager sm = (SubscriptionManager) getSystemService(
+                Context.TELEPHONY_SUBSCRIPTION_SERVICE);
         PersistableBundle b = null;
-        if (configManager != null) {
-            b = configManager.getConfig();
+        if (ccm != null && sm != null) {
+            SubscriptionInfo info = sm.getActiveSubscriptionInfoForSimSlotIndex(slotId);
+            if (info != null) {
+                b = ccm.getConfigForSubId(info.getSubscriptionId());
+            }
         }
         if (b != null) {
             return b.getBoolean(key);
-        } else {
-            // Return static default defined in CarrierConfigManager.
-            return CarrierConfigManager.getDefaultConfig().getBoolean(key);
         }
+        // Return static default defined in CarrierConfigManager.
+        return CarrierConfigManager.getDefaultConfig().getBoolean(key);
     }
 
     private void handleCmd(CatCmdMessage cmdMsg, int slotId) {
@@ -1131,8 +1135,8 @@
             }
 
             /* Check if Carrier would not want to launch browser */
-            if (getBooleanCarrierConfig(mContext,
-                    CarrierConfigManager.KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL)) {
+            if (getBooleanCarrierConfig(CarrierConfigManager.KEY_STK_DISABLE_LAUNCH_BROWSER_BOOL,
+                    slotId)) {
                 CatLog.d(this, "Browser is not launched as per carrier.");
                 sendResponse(RES_ID_DONE, slotId, true);
                 break;
diff --git a/src/com/android/stk/StkMenuConfig.java b/src/com/android/stk/StkMenuConfig.java
index 88ce272..d0fa0d8 100644
--- a/src/com/android/stk/StkMenuConfig.java
+++ b/src/com/android/stk/StkMenuConfig.java
@@ -21,6 +21,7 @@
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.os.Build;
+import android.telephony.SubscriptionInfo;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -111,15 +112,18 @@
     }
 
     private void findConfig(int slotId) {
-        int[] subId = SubscriptionManager.getSubId(slotId);
-        if (subId == null) {
+        SubscriptionManager sm = (SubscriptionManager) mContext.getSystemService(
+                Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+        SubscriptionInfo info = (sm != null) ? sm.getActiveSubscriptionInfoForSimSlotIndex(slotId)
+                : null;
+        if (info == null) {
             mConfigs[slotId] = NO_CONFIG;
             return;
         }
 
         TelephonyManager telephony =
                 (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
-        String operator = telephony.getSimOperator(subId[0]);
+        String operator = telephony.getSimOperator(info.getSubscriptionId());
         if (TextUtils.isEmpty(operator) || (operator.length() < 5)) {
             mConfigs[slotId] = NO_CONFIG;
             return;