Merge "Move the check on multisim support when switch configuration is done"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index f729dcf..1f01822 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -6577,35 +6577,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
@@ -6615,7 +6619,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);