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

Commit a7e695e4 authored by Amit Mahajan's avatar Amit Mahajan
Browse files

Update SIM state on SIM refresh.

Test: verified by tester on b/191230032
Test: atest UiccControllerTest
Bug: 191230032
Bug: 192644220
Change-Id: I2d5fb3498670858eb1ce4a818b2b01b6ba5b8496
parent 039dec8c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1163,6 +1163,7 @@ public class UiccController extends Handler {
        }

        if (changed && resp.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) {
            uiccCard.getUiccProfile().updateIccAvailability(true);
            // If there is any change on RESET, reset carrier config as well. From carrier config
            // perspective, this is treated the same as sim state unknown
            CarrierConfigManager configManager = (CarrierConfigManager)
+4 −1
Original line number Diff line number Diff line
@@ -523,7 +523,10 @@ public class UiccProfile extends IccCard {
        }
    }

    private void updateIccAvailability(boolean allAppsChanged) {
    /**
     * ICC availability/state changed. Update corresponding fields and external state if needed.
     */
    public void updateIccAvailability(boolean allAppsChanged) {
        synchronized (mLock) {
            UiccCardApplication newApp;
            IccRecords newRecords = null;
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
@@ -60,6 +62,7 @@ public class UiccControllerTest extends TelephonyTest {
    private static final int ICC_CHANGED_EVENT = 0;
    private static final int EVENT_GET_ICC_STATUS_DONE = 3;
    private static final int EVENT_GET_SLOT_STATUS_DONE = 4;
    private static final int EVENT_SIM_REFRESH = 8;
    private static final int EVENT_EID_READY = 9;
    @Mock
    private Handler mMockedHandler;
@@ -73,6 +76,8 @@ public class UiccControllerTest extends TelephonyTest {
    private UiccCard mMockCard;
    @Mock
    private EuiccCard mMockEuiccCard;
    @Mock
    private UiccProfile mMockProfile;

    private IccCardApplicationStatus composeUiccApplicationStatus(
            IccCardApplicationStatus.AppType appType,
@@ -631,4 +636,22 @@ public class UiccControllerTest extends TelephonyTest {
        assertEquals(mUiccControllerUT.convertToPublicCardId(knownEidFromApdu),
                mUiccControllerUT.getCardIdForDefaultEuicc());
    }

    @Test
    public void testSimRefresh() {
        mUiccControllerUT.mUiccSlots[0] = mMockSlot;
        doReturn(mMockCard).when(mMockSlot).getUiccCard();
        doReturn(mMockProfile).when(mMockCard).getUiccProfile();

        doReturn(true).when(mMockCard).resetAppWithAid(nullable(String.class), eq(true));
        IccRefreshResponse resp = new IccRefreshResponse();
        resp.refreshResult = IccRefreshResponse.REFRESH_RESULT_RESET;
        AsyncResult ar = new AsyncResult(null, resp, null);
        Message msg = Message.obtain(mUiccControllerUT, EVENT_SIM_REFRESH, ar);
        mUiccControllerUT.handleMessage(msg);
        processAllMessages();

        // verify that updateIccAvailability() is called on refresh with RESET
        verify(mMockProfile).updateIccAvailability(true);
    }
}