Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2fbe2ddd authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fixed that remote SIM can't be inserted correctly" into main

parents 1641740a 1b84454e
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -2308,9 +2308,17 @@ public class SubscriptionManagerService extends ISub.Stub {

        enforceTelephonyFeatureWithException(getCurrentPackageName(), "addSubInfo");

        if (!SubscriptionManager.isValidSlotIndex(slotIndex)
                && slotIndex != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
            throw new IllegalArgumentException("Invalid slotIndex " + slotIndex);
        if (subscriptionType == SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM) {
            if (!SubscriptionManager.isValidSlotIndex(slotIndex)) {
                throw new IllegalArgumentException("Invalid slot index " + slotIndex
                        + " for local SIM");
            }
        } else if (subscriptionType == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM) {
            // We only support one remote SIM at this point, so use -1. This needs to be revisited
            // if we plan to support multiple remote SIMs in the future.
            slotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
        } else {
            throw new IllegalArgumentException("Invalid subscription type " + subscriptionType);
        }

        // Now that all security checks passes, perform the operation as ourselves.
+2 −1
Original line number Diff line number Diff line
@@ -2884,7 +2884,8 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
                .getSubscriptionInfoInternal(1);
        assertThat(subInfo.getIccId()).isEqualTo(FAKE_MAC_ADDRESS1);
        assertThat(subInfo.getDisplayName()).isEqualTo(FAKE_CARRIER_NAME1);
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(0);
        assertThat(subInfo.getSimSlotIndex()).isEqualTo(
                SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        assertThat(subInfo.getSubscriptionType()).isEqualTo(
                SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM);