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

Commit a7277582 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fixed incorrect profile shown on Settings" into main

parents 7a6ecced 7f90d26a
Loading
Loading
Loading
Loading
+105 −101
Original line number Original line Diff line number Diff line
@@ -1242,6 +1242,7 @@ public class SubscriptionManagerService extends ISub.Stub {
            // Check if this is the final state. Only update the subscription if NOT_READY is a
            // Check if this is the final state. Only update the subscription if NOT_READY is a
            // final state.
            // final state.
            IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard();
            IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard();
            if (iccCard.isEmptyProfile()) log("updateSubscription: iccCard has empty profile.");
            if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) {
            if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) {
                log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update "
                log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update "
                        + "subscription later.");
                        + "subscription later.");
@@ -1252,19 +1253,20 @@ public class SubscriptionManagerService extends ISub.Stub {
                logl("updateSubscription: UICC app disabled on slot " + phoneId);
                logl("updateSubscription: UICC app disabled on slot " + phoneId);
                markSubscriptionsInactive(phoneId);
                markSubscriptionsInactive(phoneId);
            }
            }
        }
        } else {


            String iccId = getIccId(phoneId);
            String iccId = getIccId(phoneId);
            log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId)
            log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId)
                    + " on phone " + phoneId);
                    + " on phone " + phoneId);


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


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


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