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

Commit c364c3ce authored by Jordan Liu's avatar Jordan Liu Committed by Gerrit Code Review
Browse files

Merge "Check that UiccCard is not null"

parents 20cc0878 b66615d8
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -603,10 +603,14 @@ public class UiccController extends Handler {
            final UiccSlot slot = mUiccSlots[slotIndex];
            final UiccSlot slot = mUiccSlots[slotIndex];
            boolean isEuicc = slot.isEuicc();
            boolean isEuicc = slot.isEuicc();
            String eid = null;
            String eid = null;
            String iccid = slot.getUiccCard().getIccId();
            UiccCard card = slot.getUiccCard();
            if (card == null) {
                continue;
            }
            String iccid = card.getIccId();
            int cardId = INVALID_CARD_ID;
            int cardId = INVALID_CARD_ID;
            if (isEuicc) {
            if (isEuicc) {
                eid = slot.getUiccCard().getCardId();
                eid = card.getCardId();
                cardId = convertToPublicCardId(eid);
                cardId = convertToPublicCardId(eid);
            } else {
            } else {
                // leave eid null if the UICC is not embedded
                // leave eid null if the UICC is not embedded
+25 −0
Original line number Original line Diff line number Diff line
@@ -319,4 +319,29 @@ public class UiccControllerTest extends TelephonyTest {
                0);        // slotIndex
                0);        // slotIndex
        assertEquals(uiccCardInfo, mUiccControllerUT.getAllUiccCardInfos().get(0));
        assertEquals(uiccCardInfo, mUiccControllerUT.getAllUiccCardInfos().get(0));
    }
    }

    @Test
    public void testGetAllUiccCardInfosNullCard() {
        // Give UiccController a real context so it can use shared preferences
        mUiccControllerUT.mContext = InstrumentationRegistry.getContext();

        // Mock out UiccSlots
        mUiccControllerUT.mUiccSlots[0] = mMockSlot;
        doReturn(true).when(mMockSlot).isEuicc();
        doReturn(null).when(mMockSlot).getUiccCard();

        // simulate card status loaded so that the UiccController sets the card ID
        IccCardStatus ics = new IccCardStatus();
        ics.setCardState(1 /* present */);
        ics.setUniversalPinState(3 /* disabled */);
        ics.atr = "abcdef0123456789abcdef";
        ics.iccid = "123451234567890";
        ics.eid = "A1B2C3D4";
        AsyncResult ar = new AsyncResult(null, ics, null);
        Message msg = Message.obtain(mUiccControllerUT, EVENT_GET_ICC_STATUS_DONE, ar);
        mUiccControllerUT.handleMessage(msg);

        // assert that the getAllUiccCardInfos returns an empty list without crashing
        assertEquals(0, mUiccControllerUT.getAllUiccCardInfos().size());
    }
}
}