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

Commit 0d99d312 authored by Malcolm Chen's avatar Malcolm Chen Committed by Automerger Merge Worker
Browse files

Make sure to show inserted pSIM in Settings by trimming the 'F' in am:...

Make sure to show inserted pSIM in Settings by trimming the 'F' in am: 03d293cf am: 1bb9a68c am: 97d7df85

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/11826336

Change-Id: I8a640d5546624e445148cd67696bff54d11b111c
parents 71618969 97d7df85
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -1067,7 +1067,12 @@ public class SubscriptionController extends ISub.Stub {
                selection += " OR " + SubscriptionManager.IS_EMBEDDED + "=1";
            }

            List<String> iccIds = getIccIdsOfInsertedSims();
            // Available eSIM profiles are reported by EuiccManager. However for physical SIMs if
            // they are in inactive slot or programmatically disabled, they are still considered
            // available. In this case we get their iccid from slot info and include their
            // subscriptionInfos.
            List<String> iccIds = getIccIdsOfInsertedPhysicalSims();

            if (!iccIds.isEmpty()) {
                selection += " OR ("  + getSelectionForIccIdList(iccIds.toArray(new String[0]))
                        + ")";
@@ -1089,7 +1094,7 @@ public class SubscriptionController extends ISub.Stub {
        }
    }

    private List<String> getIccIdsOfInsertedSims() {
    private List<String> getIccIdsOfInsertedPhysicalSims() {
        List<String> ret = new ArrayList<>();
        UiccSlot[] uiccSlots = UiccController.getInstance().getUiccSlots();
        if (uiccSlots == null) return ret;
@@ -1097,8 +1102,9 @@ public class SubscriptionController extends ISub.Stub {
        for (UiccSlot uiccSlot : uiccSlots) {
            if (uiccSlot != null && uiccSlot.getCardState() != null
                    && uiccSlot.getCardState().isCardPresent()
                    && !uiccSlot.isEuicc()
                    && !TextUtils.isEmpty(uiccSlot.getIccId())) {
                ret.add(uiccSlot.getIccId());
                ret.add(IccUtils.stripTrailingFs(uiccSlot.getIccId()));
            }
        }

+30 −1
Original line number Diff line number Diff line
@@ -1490,7 +1490,6 @@ public class SubscriptionControllerTest extends TelephonyTest {
                SubscriptionManager.NAME_SOURCE_CARRIER_ID));
    }


    @Test
    @SmallTest
    public void testGetAvailableSubscriptionList() throws Exception {
@@ -1526,6 +1525,36 @@ public class SubscriptionControllerTest extends TelephonyTest {
        assertEquals("456", infoList.get(1).getIccId());
    }

    @Test
    @SmallTest
    public void testGetAvailableSubscriptionList_withTrailingF() throws Exception {
        // TODO b/123300875 slot index 1 is not expected to be valid
        mSubscriptionControllerUT.addSubInfoRecord("123", 1);   // sub 1
        mSubscriptionControllerUT.addSubInfoRecord("456", 0);   // sub 2

        // Remove "123" from active sim list but have it inserted.
        UiccSlot[] uiccSlots = {mUiccSlot};
        IccCardStatus.CardState cardState = CARDSTATE_PRESENT;
        doReturn(uiccSlots).when(mUiccController).getUiccSlots();
        doReturn(cardState).when(mUiccSlot).getCardState();
        // IccId ends with a 'F' which should be ignored and taking into account.
        doReturn("123F").when(mUiccSlot).getIccId();
        mSubscriptionControllerUT.clearSubInfoRecord(1);

        // Active sub list should return 1 now.
        List<SubscriptionInfo> infoList = mSubscriptionControllerUT
                .getActiveSubscriptionInfoList(mCallingPackage, mCallingFeature);
        assertEquals(1, infoList.size());
        assertEquals("456", infoList.get(0).getIccId());

        // Available sub list should still return two.
        infoList = mSubscriptionControllerUT
                .getAvailableSubscriptionInfoList(mCallingPackage, mCallingFeature);
        assertEquals(2, infoList.size());
        assertEquals("123", infoList.get(0).getIccId());
        assertEquals("456", infoList.get(1).getIccId());
    }

    @Test
    @SmallTest
    public void testSetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception {