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

Commit 1ff1d1fa authored by Jack Yu's avatar Jack Yu
Browse files

Fixed incorrect profile shown on Settings

The default boot profile on eSIM can be reported by
the modem during boot up. It has 0 applications and
the SIM state is always NOT_READY.

Fixed by not pulling iccid from UiccController when
SIM is in NOT_READY state. This is essentially the same
logic as ag/5656809.

Fix: 271340832
Test: activated eSIM on Pixel 5 and verified the boot profile
      subscription was not shown on Settings.
Test: atest SubscriptionManagerServiceTest
Change-Id: I6b7123a4bc00981f7bc0904153872f1b960983c0
parent d2cbc033
Loading
Loading
Loading
Loading
+106 −103
Original line number Diff line number Diff line
@@ -1246,7 +1246,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                + TelephonyManager.simStateToString(simState));
        for (UiccSlot slot : mUiccController.getUiccSlots()) {
            if (slot != null) {
                log("  " + slot.toString());
                log("  " + slot);
            }
        }

@@ -1266,6 +1266,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            // Check if this is the final state. Only update the subscription if NOT_READY is a
            // final state.
            IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard();
            if (iccCard.isEmptyProfile()) log("updateSubscription: iccCard has empty profile.");
            if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) {
                log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update "
                        + "subscription later.");
@@ -1276,19 +1277,19 @@ public class SubscriptionManagerService extends ISub.Stub {
                logl("updateSubscription: UICC app disabled on slot " + phoneId);
                markSubscriptionsInactive(phoneId);
            }
        }

        } else {
            String iccId = getIccId(phoneId);
            log("updateSubscription: Found iccId=" + SubscriptionInfo.getPrintableId(iccId)
                    + " on phone " + phoneId);

            // For eSIM switching, SIM absent will not happen. Below is to exam if we find ICCID
        // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on that
        // logical slot invalid first. The correct subscription will be assigned the correct slot
        // later.
            // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on
            // that logical slot invalid first. The correct subscription will be assigned the
            // correct slot later.
            SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getAllSubscriptions()
                    .stream()
                .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(sub.getIccId()))
                    .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(
                            sub.getIccId()))
                    .findFirst()
                    .orElse(null);
            if (subInfo != null) {
@@ -1357,7 +1358,8 @@ public class SubscriptionManagerService extends ISub.Stub {
                        setDisplayNumber(msisdn, subId);
                    }

                String imsi = mTelephonyManager.createForSubscriptionId(subId).getSubscriberId();
                    String imsi = mTelephonyManager.createForSubscriptionId(
                            subId).getSubscriberId();
                    if (imsi != null) {
                        mSubscriptionDatabaseManager.setImsi(subId, imsi);
                    }
@@ -1397,6 +1399,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                mSlotIndexToSubId.remove(phoneId);
                logl("updateSubscription: current mapping " + slotMappingToString());
            }
        }

        if (areAllSubscriptionsLoaded()) {
            log("Notify all subscriptions loaded.");
+10 −0
Original line number Diff line number Diff line
@@ -2173,4 +2173,14 @@ public class SubscriptionManagerServiceTest extends TelephonyTest {
        map.clear();
        assertThat(map).hasSize(0);
    }

    @Test
    public void testSimNotReady() {
        mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
        mSubscriptionManagerServiceUT.updateSimState(
                0, TelephonyManager.SIM_STATE_NOT_READY, null, null);
        processAllMessages();

        assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty();
    }
}