Use a carrier config to get the sim call manager

Currently the default sim call manager is set using an OEM
config. We want to switch to using a carrier config.

With this CL, carriers can set the sim call manager using
the CarrierConfigManager.KEY_DEFAULT_SIM_CALL_MANAGER_STRING
config.

Once the carrier config is rolled out we can remove the OEM config.

BUG: 21499566

Change-Id: Ic0d33673b8a6424c6c20eb6686aa29dc35d4dfcd
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index ff41c5b..aa17b14 100644
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -29,6 +29,7 @@
 import android.graphics.drawable.Icon;
 import android.net.Uri;
 import android.os.Binder;
+import android.os.PersistableBundle;
 import android.os.Process;
 import android.os.UserHandle;
 import android.os.UserManager;
@@ -36,6 +37,7 @@
 import android.telecom.ConnectionService;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
+import android.telephony.CarrierConfigManager;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
@@ -300,11 +302,24 @@
             return mState.simCallManager;
         }
 
-        // We have no set call manager, but check to see if the OEM has specified a default one.
-        String defaultConnectionMgr =
-                mContext.getResources().getString(R.string.default_connection_manager_component);
-        if (!TextUtils.isEmpty(defaultConnectionMgr)) {
-            ComponentName componentName = ComponentName.unflattenFromString(defaultConnectionMgr);
+        // Check carrier config.
+        String defaultSimCallManager = null;
+        CarrierConfigManager configManager = (CarrierConfigManager) mContext.getSystemService(
+                Context.CARRIER_CONFIG_SERVICE);
+        PersistableBundle configBundle = configManager.getConfig();
+        if (configBundle != null) {
+            defaultSimCallManager = configBundle.getString(
+                    CarrierConfigManager.KEY_DEFAULT_SIM_CALL_MANAGER_STRING);
+        }
+
+        // Check OEM config. TODO: Remove this once the carrier config value is set.
+        if (TextUtils.isEmpty(defaultSimCallManager)) {
+            defaultSimCallManager = mContext.getResources().getString(
+                    R.string.default_connection_manager_component);
+        }
+
+        if (!TextUtils.isEmpty(defaultSimCallManager)) {
+            ComponentName componentName = ComponentName.unflattenFromString(defaultSimCallManager);
             if (componentName == null) {
                 return null;
             }