Loading src/java/com/android/internal/telephony/SubscriptionController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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. Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +7 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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) { Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading @@ -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(); } Loading @@ -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(); } Loading @@ -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(); } Loading @@ -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(); } Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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 Loading Loading @@ -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(); } Loading @@ -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 */ Loading Loading @@ -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. Loading Loading @@ -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. Loading Loading
src/java/com/android/internal/telephony/SubscriptionController.java +3 −2 Original line number Diff line number Diff line Loading @@ -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. Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +7 −2 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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) { Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionInfoUpdaterTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading @@ -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(); } Loading @@ -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(); } Loading @@ -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(); } Loading @@ -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(); } Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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), Loading Loading @@ -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 Loading Loading @@ -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(); } Loading @@ -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 */ Loading Loading @@ -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. Loading Loading @@ -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. Loading