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

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

Update subId on sim state READY.

This CL also reverts recent fixes related to faking NOT_READY
state on SIM_REFRESH. It turns out that terminal NOT_READY is
not the correct state during profile switch. And non-terminal
is not correct at profile disable time, because otherwise real
terminal NOT_READY ends up getting ignored. Conclusion is that
NOT_READY should not be faked on SIM_REFRESH.

Earlier issues are being fixed by updating subId on READY.
In R, this was not an issue because subId was updated on LOADED
'unconditionally'. In S, with aosp/1285363 subId is not always
updated. This CL removes an if check so that it is always updated
on READY.

Test: manually verified eSIM disable and eSIM profile switch
Test: atest SubscriptionInfoUpdaterTest
Test: atest UiccControllerTest
Bug: 195092083
Change-Id: I7d6d6d9e666b3eb1fda6a4de76e42df0e85d0bf6
parent a0d82996
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -419,14 +419,9 @@ public class SubscriptionInfoUpdater extends Handler {
        UiccSlot uiccSlot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
        String iccId = (uiccSlot != null) ? IccUtils.stripTrailingFs(uiccSlot.getIccId()) : null;
        if (!TextUtils.isEmpty(iccId)) {
            // Call updateSubscriptionInfoByIccId() only if was
            // not done earlier from SIM Locked event
            if (sIccId[phoneId] == null) {
            sIccId[phoneId] = iccId;

            updateSubscriptionInfoByIccId(phoneId, true /* updateEmbeddedSubs */);
        }
        }

        cardIds.add(getCardIdFromPhoneId(phoneId));
        updateEmbeddedSubscriptions(cardIds, (hasChanges) -> {
+0 −1
Original line number Diff line number Diff line
@@ -1163,7 +1163,6 @@ public class UiccController extends Handler {
        }

        if (changed && resp.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) {
            uiccCard.getUiccProfile().onSimReset();
            // 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)
+0 −8
Original line number Diff line number Diff line
@@ -523,14 +523,6 @@ public class UiccProfile extends IccCard {
        }
    }

    /**
     * This function is called on SIM_REFRESH of type RESET
     */
    public void onSimReset() {
        mLastReportedNumOfUiccApplications = 0;
        updateIccAvailability(true);
    }

    /**
     * ICC availability/state changed. Update corresponding fields and external state if needed.
     */
+0 −20
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ 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;
@@ -636,22 +634,4 @@ 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 onSimReset() is called on refresh with RESET
        verify(mMockProfile).onSimReset();
    }
}