Check allowed network type in Phone
That are some places call Phone.setpreferredNetworkType() to set network
type directly, so move the logic that check the allowed network type to
phone to prevent check the allowed network type in every where.
Bug: 151285260
Test: atest
Change-Id: Ibb2d320ea3caea38efbf7b3490a75a26dc45b0fe
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index fee5ecc..34ec75c 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -5509,7 +5509,6 @@
/**
* Set the preferred network type.
- * Used for device configuration by some CDMA operators.
*
* @param networkType the preferred network type, defined in RILConstants.java.
* @return true on success; false on any failure.
@@ -5523,7 +5522,11 @@
try {
Settings.Global.putInt(mApp.getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType);
- return setPreferredNetworkTypesInternal(subId);
+
+ Boolean success = (Boolean) sendRequest(
+ CMD_SET_PREFERRED_NETWORK_TYPE, networkType, subId);
+ if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail"));
+ return success;
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -5561,38 +5564,15 @@
public boolean setAllowedNetworkTypes(int subId, long allowedNetworkTypes) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "setAllowedNetworkTypes");
- final long identity = Binder.clearCallingIdentity();
- try {
- SubscriptionManager.setSubscriptionProperty(subId,
- SubscriptionManager.ALLOWED_NETWORK_TYPES,
- String.valueOf(allowedNetworkTypes));
- return setPreferredNetworkTypesInternal(subId);
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- }
- private boolean setPreferredNetworkTypesInternal(int subId) {
- long networkTypeBitMask = RadioAccessFamily.getRafFromNetworkType(
- Settings.Global.getInt(mApp.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + subId,
- RILConstants.PREFERRED_NETWORK_MODE));
- long allowedNetworkTypes = SubscriptionManager.getLongSubscriptionProperty(
- subId, SubscriptionManager.ALLOWED_NETWORK_TYPES, -1, mApp);
- int networkMode = RadioAccessFamily.getNetworkTypeFromRaf(
- (int) (networkTypeBitMask & allowedNetworkTypes));
+ SubscriptionManager.setSubscriptionProperty(subId,
+ SubscriptionManager.ALLOWED_NETWORK_TYPES,
+ String.valueOf(allowedNetworkTypes));
- if (DBG) {
- log("setPreferredNetworkTypesInternal: subId " + subId
- + " networkTypes " + networkTypeBitMask
- + " allowedNetworkTypes " + allowedNetworkTypes
- + " networkMode " + networkMode);
- }
-
- Boolean success = (Boolean) sendRequest(
- CMD_SET_PREFERRED_NETWORK_TYPE, networkMode, subId);
- if (DBG) log("setPreferredNetworkTypesInternal: " + (success ? "ok" : "fail"));
- return success;
+ int preferredNetworkMode = Settings.Global.getInt(mApp.getContentResolver(),
+ Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ RILConstants.PREFERRED_NETWORK_MODE);
+ return setPreferredNetworkType(subId, preferredNetworkMode);
}
/**