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

Commit 1128fb38 authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Automerger Merge Worker
Browse files

Merge "Make sure to show inserted pSIM in Settings by trimming the 'F' in iccid." am: 8887f62b

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

Change-Id: I7fea5b44f35719a87e4f9d53502f5a17a900d5b1
parents 4555adf0 8887f62b
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 {