summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-04-21 17:43:36 -0700
committerAndrew Lee <anwlee@google.com>2015-04-24 15:33:14 -0700
commitd8978ce8f61b3145b77f5526bb7efe697f5fd614 (patch)
treec5df489c711aa21fb0f9788bb386c07cbf48eb04
parent5e31872ceaa9b21f34588d7353a4ad2812b3b536 (diff)
downloadandroid_packages_services_Telephony-d8978ce8f61b3145b77f5526bb7efe697f5fd614.tar.gz
android_packages_services_Telephony-d8978ce8f61b3145b77f5526bb7efe697f5fd614.tar.bz2
android_packages_services_Telephony-d8978ce8f61b3145b77f5526bb7efe697f5fd614.zip
Provide config for excluding CDMA activation code.
Bug: 19296388 Change-Id: I97d7f495b38df0c878f1742fc1677a769dc5ad6a
-rwxr-xr-xres/values/config.xml2
-rw-r--r--src/com/android/services/telephony/TelephonyConnectionService.java55
2 files changed, 40 insertions, 17 deletions
diff --git a/res/values/config.xml b/res/values/config.xml
index 25b23a11d..6f7784ae5 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 38ba75cd2..9a51346a2 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -20,6 +20,7 @@ import android.content.ComponentName;
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 @@ public class TelephonyConnectionService extends ConnectionService {
// 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);
-
- 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"));
+ // 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);
+
+ // 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"));
+ }
}
}
}