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

Commit d2e73d18 authored by Jordan Liu's avatar Jordan Liu Committed by android-build-merger
Browse files

Merge "Populate cardId in updateCache instead of waiting for activation" am: cee1ecba

am: b70c31d1

Change-Id: Ia95b250f2b93f48aa35407be7f2f3b04839b6f9c
parents 8a8194f5 b70c31d1
Loading
Loading
Loading
Loading
+16 −5
Original line number Original line Diff line number Diff line
@@ -53,6 +53,7 @@ import android.telephony.TelephonyManager;
import android.telephony.UiccAccessRule;
import android.telephony.UiccAccessRule;
import android.telephony.euicc.EuiccManager;
import android.telephony.euicc.EuiccManager;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.Pair;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.euicc.EuiccController;
@@ -714,19 +715,20 @@ public class SubscriptionInfoUpdater extends Handler {
        }
        }


        mBackgroundHandler.post(() -> {
        mBackgroundHandler.post(() -> {
            List<GetEuiccProfileInfoListResult> results = new ArrayList<>();
            List<Pair<Integer, GetEuiccProfileInfoListResult>> results = new ArrayList<>();
            for (int cardId : cardIds) {
            for (int cardId : cardIds) {
                GetEuiccProfileInfoListResult result =
                GetEuiccProfileInfoListResult result =
                        EuiccController.get().blockingGetEuiccProfileInfoList(cardId);
                        EuiccController.get().blockingGetEuiccProfileInfoList(cardId);
                if (DBG) logd("blockingGetEuiccProfileInfoList cardId " + cardId);
                if (DBG) logd("blockingGetEuiccProfileInfoList cardId " + cardId);
                results.add(result);
                results.add(Pair.create(cardId, result));
            }
            }


            // The runnable will be executed in the main thread.
            // The runnable will be executed in the main thread.
            this.post(() -> {
            this.post(() -> {
                boolean hasChanges = false;
                boolean hasChanges = false;
                for (GetEuiccProfileInfoListResult result : results) {
                for (Pair<Integer, GetEuiccProfileInfoListResult> cardIdAndResult : results) {
                    if (updateEmbeddedSubscriptionsCache(result)) {
                    if (updateEmbeddedSubscriptionsCache(cardIdAndResult.first,
                            cardIdAndResult.second)) {
                        hasChanges = true;
                        hasChanges = true;
                    }
                    }
                }
                }
@@ -747,7 +749,8 @@ public class SubscriptionInfoUpdater extends Handler {
     * but notifications about subscription changes may be skipped if this returns false as an
     * but notifications about subscription changes may be skipped if this returns false as an
     * optimization to avoid spurious notifications.
     * optimization to avoid spurious notifications.
     */
     */
    private boolean updateEmbeddedSubscriptionsCache(GetEuiccProfileInfoListResult result) {
    private boolean updateEmbeddedSubscriptionsCache(int cardId,
            GetEuiccProfileInfoListResult result) {
        if (DBG) logd("updateEmbeddedSubscriptionsCache");
        if (DBG) logd("updateEmbeddedSubscriptionsCache");


        if (result == null) {
        if (result == null) {
@@ -852,6 +855,14 @@ public class SubscriptionInfoUpdater extends Handler {
                values.put(SubscriptionManager.MNC_STRING, mnc);
                values.put(SubscriptionManager.MNC_STRING, mnc);
                values.put(SubscriptionManager.MNC, mnc);
                values.put(SubscriptionManager.MNC, mnc);
            }
            }
            // If cardId = unsupported or unitialized, we have no reason to update DB.
            // Additionally, if the device does not support cardId for default eUICC, the CARD_ID
            // field should not contain the EID
            if (cardId >= 0 && UiccController.getInstance().getCardIdForDefaultEuicc()
                    != TelephonyManager.UNSUPPORTED_CARD_ID) {
                values.put(SubscriptionManager.CARD_ID,
                        mEuiccManager.createForCardId(cardId).getEid());
            }
            hasChanges = true;
            hasChanges = true;
            contentResolver.update(SubscriptionManager.CONTENT_URI, values,
            contentResolver.update(SubscriptionManager.CONTENT_URI, values,
                    SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.getIccid() + "\"", null);
                    SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.getIccid() + "\"", null);
+3 −0
Original line number Original line Diff line number Diff line
@@ -76,6 +76,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
    private static final int FAKE_SUB_ID_1 = 0;
    private static final int FAKE_SUB_ID_1 = 0;
    private static final int FAKE_SUB_ID_2 = 1;
    private static final int FAKE_SUB_ID_2 = 1;
    private static final int FAKE_CARD_ID = 0;
    private static final int FAKE_CARD_ID = 0;
    private static final String FAKE_EID = "89049032000001000000031328322874";
    private static final String FAKE_MCC_MNC_1 = "123456";
    private static final String FAKE_MCC_MNC_1 = "123456";
    private static final String FAKE_MCC_MNC_2 = "456789";
    private static final String FAKE_MCC_MNC_2 = "456789";


@@ -485,6 +486,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
    @SmallTest
    @SmallTest
    public void testUpdateEmbeddedSubscriptions_listSuccess() throws Exception {
    public void testUpdateEmbeddedSubscriptions_listSuccess() throws Exception {
        when(mEuiccManager.isEnabled()).thenReturn(true);
        when(mEuiccManager.isEnabled()).thenReturn(true);
        when(mEuiccManager.createForCardId(anyInt())).thenReturn(mEuiccManager);
        when(mEuiccManager.getEid()).thenReturn(FAKE_EID);


        EuiccProfileInfo[] euiccProfiles = new EuiccProfileInfo[] {
        EuiccProfileInfo[] euiccProfiles = new EuiccProfileInfo[] {
                new EuiccProfileInfo("1", null /* accessRules */, null /* nickname */),
                new EuiccProfileInfo("1", null /* accessRules */, null /* nickname */),