Provide config for excluding CDMA activation code.

Bug: 19296388
Change-Id: I97d7f495b38df0c878f1742fc1677a769dc5ad6a
diff --git a/res/values/config.xml b/res/values/config.xml
index 25b23a1..6f7784a 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -155,5 +155,5 @@
 
     <!-- Disables dialing "*228" (OTASP provisioning) on CDMA carriers where it is not supported or
          is potentially harmful by locking the SIM to 3G. -->
-    <bool name="config_disable_cdma_activation_code">false</bool>
+    <string name="config_disable_cdma_activation_code">false</string>
 </resources>
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 4676474..725b04b 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
+import android.content.res.Resources;
 import android.net.Uri;
 import android.telecom.Connection;
 import android.telecom.ConnectionRequest;
@@ -148,22 +149,44 @@
 
             // Obtain the configuration for the outgoing phone's SIM. If the outgoing number
             // matches the *228 regex pattern, fail the call. This number is used for OTASP, and
-            // when dialed would lock LTE SIMs to 3G if not prohibited..
-            SubscriptionManager subManager = SubscriptionManager.from(phone.getContext());
-            SubscriptionInfo subInfo = subManager.getActiveSubscriptionInfo(phone.getSubId());
-            if (subInfo != null) {
-                Configuration config = new Configuration();
-                config.mcc = subInfo.getMcc();
-                config.mnc = subInfo.getMnc();
-                Context subContext = phone.getContext().createConfigurationContext(config);
+            // when dialed could lock LTE SIMs to 3G if not prohibited..
+            if (CDMA_ACTIVATION_CODE_REGEX_PATTERN.matcher(number).matches()) {
+                SubscriptionManager subManager = SubscriptionManager.from(phone.getContext());
+                SubscriptionInfo subInfo = subManager.getActiveSubscriptionInfo(phone.getSubId());
+                if (subInfo != null) {
+                    Configuration config = new Configuration();
+                    config.mcc = subInfo.getMcc();
+                    config.mnc = subInfo.getMnc();
+                    Context subContext = phone.getContext().createConfigurationContext(config);
 
-                if (subContext.getResources() != null && subContext.getResources()
-                        .getBoolean(R.bool.config_disable_cdma_activation_code)) {
-                    if (CDMA_ACTIVATION_CODE_REGEX_PATTERN.matcher(number).matches()) {
-                        return Connection.createFailedConnection(
-                                DisconnectCauseUtil.toTelecomDisconnectCause(
-                                        android.telephony.DisconnectCause.INVALID_NUMBER,
-                                        "Tried to dial *228"));
+                    // Get the resources specific to the subscription in question.
+                    Resources res = subContext.getResources();
+                    if (res != null) {
+                        boolean disableActivation = false;
+                        String configValue =
+                                res.getString(R.string.config_disable_cdma_activation_code);
+
+                        // Set disableActivation based on the configuration value.
+                        if (!TextUtils.isEmpty(configValue)) {
+                            String [] valueArray = configValue.split(";");
+
+                            if (valueArray.length == 1) {
+                                // If the configuration says just "true" disable it.
+                                disableActivation = valueArray[0].equalsIgnoreCase("true");
+                            } else if (valueArray.length == 2) {
+                                // If the configuration is split by a semicolon, make sure the
+                                // second half is equal to the group ID for the phone.
+                                disableActivation = valueArray[0].equalsIgnoreCase("true") &&
+                                        valueArray[1].equalsIgnoreCase(phone.getGroupIdLevel1());
+                            }
+                        }
+
+                        if (disableActivation) {
+                            return Connection.createFailedConnection(
+                                    DisconnectCauseUtil.toTelecomDisconnectCause(
+                                            android.telephony.DisconnectCause.INVALID_NUMBER,
+                                            "Tried to dial *228"));
+                        }
                     }
                 }
             }