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

Commit 7d83feeb authored by Malcolm Chen's avatar Malcolm Chen
Browse files

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

iccid.

Also make sure eSIM empty profiles are not considered available.

Bug: 157525761
Test: manual & unittest
Change-Id: Ieeee61ba968ac9f23b355cca52374659a6cdf77f
Merged-In: Ieeee61ba968ac9f23b355cca52374659a6cdf77f
parent d1c5c851
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -897,7 +897,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]))
                        + ")";
@@ -919,7 +924,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;
@@ -927,8 +932,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 −0
Original line number Diff line number Diff line
@@ -1107,6 +1107,36 @@ public class SubscriptionControllerTest extends TelephonyTest {
                SubscriptionManager.NAME_SOURCE_CARRIER_ID));
    }

    @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 {