Loading src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +18 −8 Original line number Diff line number Diff line Loading @@ -1265,15 +1265,25 @@ public class SubscriptionManagerService extends ISub.Stub { } if (simState == TelephonyManager.SIM_STATE_ABSENT) { if (mSlotIndexToSubId.containsKey(phoneId)) { int subId = mSlotIndexToSubId.get(phoneId); // Re-enable the SIM when it's removed, so it will be in enabled state when it gets // Re-enable the pSIM when it's removed, so it will be in enabled state when it gets // re-inserted again. (pre-U behavior) List<String> iccIds = getIccIdsOfInsertedPhysicalSims(); mSubscriptionDatabaseManager.getAllSubscriptions().stream() // All the removed pSIMs (Note this could include some erased eSIM that has // embedded bit removed). .filter(subInfo -> !iccIds.contains(subInfo.getIccId()) && !subInfo.isEmbedded()) .forEach(subInfo -> { int subId = subInfo.getSubscriptionId(); log("updateSubscription: Re-enable Uicc application on sub " + subId); mSubscriptionDatabaseManager.setUiccApplicationsEnabled(subId, true); // When sim is absent, set the port index to invalid port index. (pre-U behavior) // When sim is absent, set the port index to invalid port index. // (pre-U behavior) mSubscriptionDatabaseManager.setPortIndex(subId, TelephonyManager.INVALID_PORT_INDEX); }); if (mSlotIndexToSubId.containsKey(phoneId)) { markSubscriptionsInactive(phoneId); } } else if (simState == TelephonyManager.SIM_STATE_NOT_READY) { Loading tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.internal.telephony.euicc.EuiccController; import com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.SubscriptionProvider; import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionManagerServiceCallback; import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionMap; import com.android.internal.telephony.uicc.IccCardStatus; import com.android.internal.telephony.uicc.UiccSlot; import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges; Loading Loading @@ -2195,4 +2196,39 @@ public class SubscriptionManagerServiceTest extends TelephonyTest { assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); } @Test public void testInactiveSimRemoval() { insertSubscription(FAKE_SUBSCRIPTION_INFO2); mContextFixture.addCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE); mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE); doReturn(FAKE_ICCID2).when(mUiccSlot).getIccId(0); doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState(); mSubscriptionManagerServiceUT.setUiccApplicationsEnabled(false, 1); mSubscriptionManagerServiceUT.updateSimState( 1, TelephonyManager.SIM_STATE_NOT_READY, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); assertThat(mSubscriptionManagerServiceUT.getSubscriptionInfo(1) .areUiccApplicationsEnabled()).isFalse(); assertThat(mSubscriptionManagerServiceUT.getAvailableSubscriptionInfoList( CALLING_PACKAGE, CALLING_FEATURE)).hasSize(1); // Now remove the SIM doReturn(null).when(mUiccSlot).getIccId(0); doReturn(IccCardStatus.CardState.CARDSTATE_ABSENT).when(mUiccSlot).getCardState(); mSubscriptionManagerServiceUT.updateSimState( 1, TelephonyManager.SIM_STATE_ABSENT, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); // UICC should be re-enabled again for next re-insertion. assertThat(mSubscriptionManagerServiceUT.getSubscriptionInfo(1) .areUiccApplicationsEnabled()).isTrue(); assertThat(mSubscriptionManagerServiceUT.getAvailableSubscriptionInfoList( CALLING_PACKAGE, CALLING_FEATURE)).isEmpty(); } } Loading
src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +18 −8 Original line number Diff line number Diff line Loading @@ -1265,15 +1265,25 @@ public class SubscriptionManagerService extends ISub.Stub { } if (simState == TelephonyManager.SIM_STATE_ABSENT) { if (mSlotIndexToSubId.containsKey(phoneId)) { int subId = mSlotIndexToSubId.get(phoneId); // Re-enable the SIM when it's removed, so it will be in enabled state when it gets // Re-enable the pSIM when it's removed, so it will be in enabled state when it gets // re-inserted again. (pre-U behavior) List<String> iccIds = getIccIdsOfInsertedPhysicalSims(); mSubscriptionDatabaseManager.getAllSubscriptions().stream() // All the removed pSIMs (Note this could include some erased eSIM that has // embedded bit removed). .filter(subInfo -> !iccIds.contains(subInfo.getIccId()) && !subInfo.isEmbedded()) .forEach(subInfo -> { int subId = subInfo.getSubscriptionId(); log("updateSubscription: Re-enable Uicc application on sub " + subId); mSubscriptionDatabaseManager.setUiccApplicationsEnabled(subId, true); // When sim is absent, set the port index to invalid port index. (pre-U behavior) // When sim is absent, set the port index to invalid port index. // (pre-U behavior) mSubscriptionDatabaseManager.setPortIndex(subId, TelephonyManager.INVALID_PORT_INDEX); }); if (mSlotIndexToSubId.containsKey(phoneId)) { markSubscriptionsInactive(phoneId); } } else if (simState == TelephonyManager.SIM_STATE_NOT_READY) { Loading
tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java +36 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import com.android.internal.telephony.euicc.EuiccController; import com.android.internal.telephony.subscription.SubscriptionDatabaseManagerTest.SubscriptionProvider; import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionManagerServiceCallback; import com.android.internal.telephony.subscription.SubscriptionManagerService.SubscriptionMap; import com.android.internal.telephony.uicc.IccCardStatus; import com.android.internal.telephony.uicc.UiccSlot; import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges; Loading Loading @@ -2195,4 +2196,39 @@ public class SubscriptionManagerServiceTest extends TelephonyTest { assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); } @Test public void testInactiveSimRemoval() { insertSubscription(FAKE_SUBSCRIPTION_INFO2); mContextFixture.addCallingOrSelfPermission(Manifest.permission.MODIFY_PHONE_STATE); mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE); doReturn(FAKE_ICCID2).when(mUiccSlot).getIccId(0); doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccSlot).getCardState(); mSubscriptionManagerServiceUT.setUiccApplicationsEnabled(false, 1); mSubscriptionManagerServiceUT.updateSimState( 1, TelephonyManager.SIM_STATE_NOT_READY, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); assertThat(mSubscriptionManagerServiceUT.getSubscriptionInfo(1) .areUiccApplicationsEnabled()).isFalse(); assertThat(mSubscriptionManagerServiceUT.getAvailableSubscriptionInfoList( CALLING_PACKAGE, CALLING_FEATURE)).hasSize(1); // Now remove the SIM doReturn(null).when(mUiccSlot).getIccId(0); doReturn(IccCardStatus.CardState.CARDSTATE_ABSENT).when(mUiccSlot).getCardState(); mSubscriptionManagerServiceUT.updateSimState( 1, TelephonyManager.SIM_STATE_ABSENT, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); // UICC should be re-enabled again for next re-insertion. assertThat(mSubscriptionManagerServiceUT.getSubscriptionInfo(1) .areUiccApplicationsEnabled()).isTrue(); assertThat(mSubscriptionManagerServiceUT.getAvailableSubscriptionInfoList( CALLING_PACKAGE, CALLING_FEATURE)).isEmpty(); } }