Merge "Do not retry if port number is unavailable." into mnc-dev
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index de794de..0e82b99 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2393,7 +2393,8 @@
@Override
public String getLine1NumberForDisplay(int subId, String callingPackage) {
- if (!canReadPhoneState(callingPackage, "getLine1NumberForDisplay")) {
+ // This is open to apps with WRITE_SMS.
+ if (!canReadPhoneNumber(callingPackage, "getLine1NumberForDisplay")) {
return null;
}
@@ -2670,6 +2671,16 @@
return true;
}
+ /**
+ * Besides READ_PHONE_STATE, WRITE_SMS also allows apps to get phone numbers.
+ */
+ private boolean canReadPhoneNumber(String callingPackage, String message) {
+ // Note canReadPhoneState() may throw, so we need to do the appops check first.
+ return (mAppOps.noteOp(AppOpsManager.OP_WRITE_SMS,
+ Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED)
+ || canReadPhoneState(callingPackage, message);
+ }
+
@Override
public void factoryReset(int subId) {
enforceConnectivityInternalPermission();
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 9312992..72c9b07 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -27,6 +27,7 @@
import android.telecom.ConnectionService;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
+import android.telephony.CarrierConfigManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.telephony.SubscriptionInfo;
@@ -152,44 +153,20 @@
// 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 could 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);
+ boolean disableActivation = false;
+ CarrierConfigManager cfgManager = (CarrierConfigManager)
+ phone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ if (cfgManager != null) {
+ disableActivation = cfgManager.getConfigForSubId(phone.getSubId())
+ .getBoolean(CarrierConfigManager.KEY_DISABLE_CDMA_ACTIVATION_CODE_BOOL);
+ }
- // 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
- .CDMA_ALREADY_ACTIVATED,
- "Tried to dial *228"));
- }
- }
+ if (disableActivation) {
+ return Connection.createFailedConnection(
+ DisconnectCauseUtil.toTelecomDisconnectCause(
+ android.telephony.DisconnectCause
+ .CDMA_ALREADY_ACTIVATED,
+ "Tried to dial *228"));
}
}
}