Move the check on multisim support when switch configuration is done
The methods switchMultiSimConfig() and isMultisimSupported() in
TelephonyManager have different permissions. So, in order to check if
the switch operation can be performed, the check needs to be moved after
the verification of the permissions.
Bug: 124462964
Test: compilation
Change-Id: I343a2e649087c6f883eff20075b2176df2247125
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index ce4a8b9..b447989 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6586,35 +6586,39 @@
final long identity = Binder.clearCallingIdentity();
try {
- // If the device has less than 2 SIM cards, indicate that multisim is restricted.
- int numPhysicalSlots = UiccController.getInstance().getUiccSlots().length;
- if (numPhysicalSlots < 2) {
- loge("isMultisimSupported: requires at least 2 cards");
- return false;
- }
- // Check if the hardware supports multisim functionality. If usage of multisim is not
- // supported by the modem, indicate that it is restricted.
- PhoneCapability staticCapability =
- mPhoneConfigurationManager.getStaticPhoneCapability();
- if (staticCapability == null) {
- loge("isMultisimSupported: no static configuration available");
- return false;
- }
- if (staticCapability.logicalModemList.size() < 2) {
- loge("isMultisimSupported: maximum number of modem is < 2");
- return false;
- }
- // Check if support of multiple SIMs is restricted by carrier
- if (mTelephonySharedPreferences.getBoolean(PREF_MULTI_SIM_RESTRICTED, false)) {
- return false;
- }
-
- return true;
+ return isMultisimSupportedInternal();
} finally {
Binder.restoreCallingIdentity(identity);
}
}
+ private boolean isMultisimSupportedInternal() {
+ // If the device has less than 2 SIM cards, indicate that multisim is restricted.
+ int numPhysicalSlots = UiccController.getInstance().getUiccSlots().length;
+ if (numPhysicalSlots < 2) {
+ loge("isMultisimSupportedInternal: requires at least 2 cards");
+ return false;
+ }
+ // Check if the hardware supports multisim functionality. If usage of multisim is not
+ // supported by the modem, indicate that it is restricted.
+ PhoneCapability staticCapability =
+ mPhoneConfigurationManager.getStaticPhoneCapability();
+ if (staticCapability == null) {
+ loge("isMultisimSupportedInternal: no static configuration available");
+ return false;
+ }
+ if (staticCapability.logicalModemList.size() < 2) {
+ loge("isMultisimSupportedInternal: maximum number of modem is < 2");
+ return false;
+ }
+ // Check if support of multiple SIMs is restricted by carrier
+ if (mTelephonySharedPreferences.getBoolean(PREF_MULTI_SIM_RESTRICTED, false)) {
+ return false;
+ }
+
+ return true;
+ }
+
/**
* Switch configs to enable multi-sim or switch back to single-sim
* @param numOfSims number of active sims we want to switch to
@@ -6624,7 +6628,13 @@
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, "switchMultiSimConfig");
final long identity = Binder.clearCallingIdentity();
+
try {
+ //only proceed if multi-sim is not restricted
+ if (!isMultisimSupportedInternal()) {
+ loge("switchMultiSimConfig not possible. It is restricted or not supported.");
+ return;
+ }
mPhoneConfigurationManager.switchMultiSimConfig(numOfSims);
} finally {
Binder.restoreCallingIdentity(identity);