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

Commit 6bd2f8e4 authored by Jack Yu's avatar Jack Yu Committed by android-build-merger
Browse files

Merge "Fixed a race when slot-to-sub mapping table is rebuilding" into oc-dr1-dev

am: 02558a9f

Change-Id: Idb900534391aa590eba2e1366a41d1541c382d0e
parents 6d71be89 02558a9f
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -901,10 +901,11 @@ public class SubscriptionController extends ISub.Stub {
                    do {
                        int subId = cursor.getInt(cursor.getColumnIndexOrThrow(
                                SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID));
                        // If sSlotIndexToSubId already has a valid subId for a slotIndex/phoneId,
                        // do not add another subId for same slotIndex/phoneId.
                        // If sSlotIndexToSubId already has the same subId for a slotIndex/phoneId,
                        // do not add it.
                        Integer currentSubId = sSlotIndexToSubId.get(slotIndex);
                        if (currentSubId == null
                                || currentSubId != subId
                                || !SubscriptionManager.isValidSubscriptionId(currentSubId)) {
                            // TODO While two subs active, if user deactivats first
                            // one, need to update the default subId with second one.
+7 −2
Original line number Diff line number Diff line
@@ -519,8 +519,6 @@ public class SubscriptionInfoUpdater extends Handler {
    synchronized private void updateSubscriptionInfoByIccId() {
        logd("updateSubscriptionInfoByIccId:+ Start");

        mSubscriptionManager.clearSubscriptionInfo();

        for (int i = 0; i < PROJECT_SIM_NUM; i++) {
            mInsertSimState[i] = SIM_NOT_CHANGE;
        }
@@ -534,6 +532,13 @@ public class SubscriptionInfoUpdater extends Handler {
        }
        logd("insertedSimCount = " + insertedSimCount);

        // We only clear the slot-to-sub map when one/some SIM was removed. Note this is a
        // workaround for some race conditions that the empty map was accessed while we are
        // rebuilding the map.
        if (SubscriptionController.getInstance().getActiveSubIdList().length > insertedSimCount) {
            SubscriptionController.getInstance().clearSubInfo();
        }

        int index = 0;
        for (int i = 0; i < PROJECT_SIM_NUM; i++) {
            if (mInsertSimState[i] == SIM_NOT_INSERT) {
+17 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
    private IccFileHandler mIccFileHandler;
    @Mock
    private EuiccController mEuiccController;
    @Mock
    private IntentBroadcaster mIntentBroadcaster;

    /*Custom ContentProvider */
    private class FakeSubscriptionContentProvider extends MockContentProvider {
@@ -124,6 +126,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        replaceInstance(SubscriptionInfoUpdater.class, "PROJECT_SIM_NUM", null, 1);

        replaceInstance(EuiccController.class, "sInstance", null, mEuiccController);
        replaceInstance(IntentBroadcaster.class, "sIntentBroadcaster", null, mIntentBroadcaster);

        doReturn(1).when(mTelephonyManager).getSimCount();
        doReturn(1).when(mTelephonyManager).getPhoneCount();
@@ -146,6 +149,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        ((MockContentResolver) mContext.getContentResolver()).addProvider(
                SubscriptionManager.CONTENT_URI.getAuthority(),
                new FakeSubscriptionContentProvider());
        doReturn(new int[]{}).when(mSubscriptionController).getActiveSubIdList();
        mIccRecord = mIccCardProxy.getIccRecords();

        mSubscriptionInfoUpdaterHandlerThread = new SubscriptionInfoUpdaterHandlerThread(TAG);
@@ -164,6 +168,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
    public void testSimAbsent() throws Exception {
        doReturn(Arrays.asList(mSubInfo)).when(mSubscriptionController)
                .getSubInfoUsingSlotIndexWithCheck(eq(FAKE_SUB_ID_1), anyBoolean(), anyString());
        doReturn(new int[]{FAKE_SUB_ID_1}).when(mSubscriptionController).getActiveSubIdList();
        Intent mIntent = new Intent(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
        mIntent.putExtra(IccCardConstants.INTENT_KEY_ICC_STATE,
                IccCardConstants.INTENT_VALUE_ICC_ABSENT);
@@ -179,6 +184,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
                eq(IccCardConstants.INTENT_VALUE_ICC_ABSENT));
        verify(mSubscriptionController, times(1)).clearSubInfo();
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

@@ -198,6 +204,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
                eq(IccCardConstants.INTENT_VALUE_ICC_UNKNOWN));
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, times(0)).notifySubscriptionInfoChanged();
    }

@@ -216,6 +223,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager).updateConfigForPhoneId(eq(0),
                eq(IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR));
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

@@ -234,6 +242,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, times(0)).updateConfigForPhoneId(eq(2),
                eq(IccCardConstants.INTENT_VALUE_ICC_IMSI));
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, times(0)).notifySubscriptionInfoChanged();
    }

@@ -278,6 +287,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                eq("89012604200000000000"), eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
        verify(mSubscriptionController, times(1)).setMccMnc(FAKE_MCC_MNC_1, FAKE_SUB_ID_1);
        verify(mSubscriptionController, times(0)).clearSubInfo();
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, times(1)).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
@@ -326,6 +336,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                eq("89012604200000000000"), eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
        verify(mSubscriptionController, times(0)).setMccMnc(anyString(), anyInt());
        verify(mSubscriptionController, times(0)).clearSubInfo();
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, times(1)).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
@@ -369,6 +380,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                eq("98106240020000000000"), eq(FAKE_SUB_ID_1));

        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
        verify(mSubscriptionController, times(0)).clearSubInfo();
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        verify(mConfigManager, times(1)).updateConfigForPhoneId(eq(FAKE_SUB_ID_1),
@@ -399,6 +411,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        // Mock there is no sim inserted before
        doReturn(null).when(mSubscriptionController)
                .getSubInfoUsingSlotIndexWithCheck(anyInt(), anyBoolean(), anyString());
        verify(mSubscriptionController, times(0)).clearSubInfo();
        doReturn("89012604200000000000").when(mIccRecord).getIccId();

        // Mock sending a sim loaded for SIM 1
@@ -429,6 +442,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
                eq(FAKE_SUB_ID_2));
        verify(mSubscriptionController, times(1)).setMccMnc(eq(FAKE_MCC_MNC_1), eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController, times(1)).setMccMnc(eq(FAKE_MCC_MNC_2), eq(FAKE_SUB_ID_2));
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, times(1)).notifySubscriptionInfoChanged();
    }

@@ -455,6 +469,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        verify(mSubscriptionManager, times(0)).addSubscriptionInfoRecord(
                anyString(), eq(FAKE_SUB_ID_1));
        verify(mSubscriptionController, times(0)).notifySubscriptionInfoChanged();
        verify(mSubscriptionController, times(0)).clearSubInfo();
        CarrierConfigManager mConfigManager = (CarrierConfigManager)
                mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        /* broadcast is done */
@@ -494,6 +509,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        verify(mSubscriptionController).insertEmptySubInfoRecord(
                "3", SubscriptionManager.SIM_NOT_INSERTED);
        // 1 already existed, so no new entries should be created for it.
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, never()).insertEmptySubInfoRecord(eq("1"), anyInt());

        // Info for 1 and 3 should be updated as active embedded subscriptions.
@@ -541,6 +557,7 @@ public class SubscriptionInfoUpdaterTest extends TelephonyTest {
        mUpdater.updateEmbeddedSubscriptions();

        // No new entries should be created.
        verify(mSubscriptionController, times(0)).clearSubInfo();
        verify(mSubscriptionController, never()).insertEmptySubInfoRecord(anyString(), anyInt());

        // 1 should not have been touched.