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

Commit 1e5905bb authored by Amit Mahajan's avatar Amit Mahajan Committed by Automerger Merge Worker
Browse files

Merge "Add subId from SIM Ready event" am: 8d7db4a0 am: defdfe70 am: 278e4159

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If2bfe23bdd2d57aa44ed0e9562a94f2b8fb5be72
parents 4cd8ca22 278e4159
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -407,6 +407,26 @@ public class SubscriptionInfoUpdater extends Handler {

    protected void handleSimReady(int phoneId) {
        List<Integer> cardIds = new ArrayList<>();
        logd("handleSimReady: phoneId: " + phoneId);

        if (sIccId[phoneId] != null && sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) {
            logd(" SIM" + (phoneId + 1) + " hot plug in");
            sIccId[phoneId] = null;
        }

        // ICCID is not available in IccRecords by the time SIM Ready event received
        // hence get ICCID from UiccSlot.
        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) -> {
@@ -419,7 +439,6 @@ public class SubscriptionInfoUpdater extends Handler {
        broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY);
    }


    protected void handleSimNotReady(int phoneId) {
        logd("handleSimNotReady: phoneId: " + phoneId);
        boolean isFinalState = false;
@@ -482,9 +501,14 @@ public class SubscriptionInfoUpdater extends Handler {
            logd("handleSimLoaded: IccID null");
            return;
        }

        // Call updateSubscriptionInfoByIccId() only if was not done earlier from SIM READY event
        if (sIccId[phoneId] == null) {
            sIccId[phoneId] = IccUtils.stripTrailingFs(records.getFullIccId());

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

        List<SubscriptionInfo> subscriptionInfos =
                mSubscriptionController.getSubInfoUsingSlotIndexPrivileged(phoneId);
        if (subscriptionInfos == null || subscriptionInfos.isEmpty()) {
+0 −35
Original line number Diff line number Diff line
@@ -77,41 +77,6 @@ public class VendorSubscriptionInfoUpdater extends SubscriptionInfoUpdater {
        }
    }

    @Override
    protected void handleSimReady(int phoneId) {
        List<Integer> cardIds = new ArrayList<>();
        Rlog.d(LOG_TAG, "handleSimReady: phoneId: " + phoneId);

        if (sIccId[phoneId] != null && sIccId[phoneId].equals(ICCID_STRING_FOR_NO_SIM)) {
            Rlog.d(LOG_TAG, " SIM" + (phoneId + 1) + " hot plug in");
            sIccId[phoneId] = null;
        }
        UiccSlot uiccSlot = UiccController.getInstance().getUiccSlotForPhone(phoneId);
        if (uiccSlot == null) {
            Rlog.d(LOG_TAG, "handleSimReady: uiccSlot null");
            return;
        }

        String iccId = uiccSlot.getIccId();
        if (IccUtils.stripTrailingFs(iccId) == null) {
            Rlog.d(LOG_TAG, "handleSimReady: IccID null");
            return;
        }
        sIccId[phoneId] = IccUtils.stripTrailingFs(iccId);

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

        cardIds.add(getCardIdFromPhoneId(phoneId));
        updateEmbeddedSubscriptions(cardIds, (hasChanges) -> {
            if (hasChanges) {
                mSubscriptionController.notifySubscriptionInfoChanged();
            }
        });
        broadcastSimStateChanged(phoneId, IccCardConstants.INTENT_VALUE_ICC_READY, null);
        broadcastSimCardStateChanged(phoneId, TelephonyManager.SIM_STATE_PRESENT);
        broadcastSimApplicationStateChanged(phoneId, TelephonyManager.SIM_STATE_NOT_READY);
    }

    @Override
    protected void handleSimLoaded(int phoneId) {
        // mIsRecordUpdateRequired set to false if sIccId has a valid Iccid to skip
+40 −0
Original line number Diff line number Diff line
@@ -902,4 +902,44 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        verify(mSubscriptionController, times(1)).refreshCachedActiveSubscriptionInfoList();
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testSimReady() throws Exception {
        replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null,new String[]{""});

        doReturn(FAKE_ICCID_1).when(mUiccSlot).getIccId();

        mUpdater.updateInternalIccState(
            IccCardConstants.INTENT_VALUE_ICC_READY, "TESTING", FAKE_SUB_ID_1);
        processAllMessages();

        verify(mSubscriptionController).clearSubInfoRecord(eq(FAKE_SUB_ID_1));
        verify(mSubscriptionManager, times(1)).addSubscriptionInfoRecord(
                eq(FAKE_ICCID_1), eq(FAKE_SUB_ID_1));
        assertTrue(mUpdater.isSubInfoInitialized());
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

    @Test
    @SmallTest
    public void testSimReadyAndLoaded() throws Exception {
        replaceInstance(SubscriptionInfoUpdater.class, "sIccId", null,new String[]{""});

        doReturn(null).when(mUiccSlot).getIccId();

        mUpdater.updateInternalIccState(
            IccCardConstants.INTENT_VALUE_ICC_READY, "TESTING", FAKE_SUB_ID_1);
        processAllMessages();

        verify(mSubscriptionManager, times(0)).addSubscriptionInfoRecord(
                eq(FAKE_ICCID_1), eq(FAKE_SUB_ID_1));

        loadSim();

        SubscriptionManager mSubscriptionManager = SubscriptionManager.from(mContext);
        verify(mSubscriptionManager, times(1)).addSubscriptionInfoRecord(
                eq(FAKE_ICCID_1), eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }
}