Loading src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +105 −101 Original line number Diff line number Diff line Loading @@ -1242,6 +1242,7 @@ public class SubscriptionManagerService extends ISub.Stub { // Check if this is the final state. Only update the subscription if NOT_READY is a // final state. IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); if (iccCard.isEmptyProfile()) log("updateSubscription: iccCard has empty profile."); if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) { log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update " + "subscription later."); Loading @@ -1252,19 +1253,20 @@ public class SubscriptionManagerService extends ISub.Stub { logl("updateSubscription: UICC app disabled on slot " + phoneId); markSubscriptionsInactive(phoneId); } } } else { String iccId = getIccId(phoneId); log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) + " on phone " + phoneId); // For eSIM switching, SIM absent will not happen. Below is to exam if we find ICCID // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on that // logical slot invalid first. The correct subscription will be assigned the correct slot // later. // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on // that logical slot invalid first. The correct subscription will be assigned the // correct slot later. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getAllSubscriptions() .stream() .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(sub.getIccId())) .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals( sub.getIccId())) .findFirst() .orElse(null); if (subInfo != null) { Loading Loading @@ -1333,7 +1335,8 @@ public class SubscriptionManagerService extends ISub.Stub { setDisplayNumber(msisdn, subId); } String imsi = mTelephonyManager.createForSubscriptionId(subId).getSubscriberId(); String imsi = mTelephonyManager.createForSubscriptionId( subId).getSubscriberId(); if (imsi != null) { mSubscriptionDatabaseManager.setImsi(subId, imsi); } Loading Loading @@ -1373,6 +1376,7 @@ public class SubscriptionManagerService extends ISub.Stub { mSlotIndexToSubId.remove(phoneId); logl("updateSubscription: current mapping " + slotMappingToString()); } } if (areAllSubscriptionsLoaded()) { log("Notify all subscriptions loaded."); Loading tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -2182,4 +2182,14 @@ public class SubscriptionManagerServiceTest extends TelephonyTest { map.clear(); assertThat(map).hasSize(0); } @Test public void testSimNotReady() { mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE); mSubscriptionManagerServiceUT.updateSimState( 0, TelephonyManager.SIM_STATE_NOT_READY, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); } } Loading
src/java/com/android/internal/telephony/subscription/SubscriptionManagerService.java +105 −101 Original line number Diff line number Diff line Loading @@ -1242,6 +1242,7 @@ public class SubscriptionManagerService extends ISub.Stub { // Check if this is the final state. Only update the subscription if NOT_READY is a // final state. IccCard iccCard = PhoneFactory.getPhone(phoneId).getIccCard(); if (iccCard.isEmptyProfile()) log("updateSubscription: iccCard has empty profile."); if (!iccCard.isEmptyProfile() && areUiccAppsEnabledOnCard(phoneId)) { log("updateSubscription: SIM_STATE_NOT_READY is not a final state. Will update " + "subscription later."); Loading @@ -1252,19 +1253,20 @@ public class SubscriptionManagerService extends ISub.Stub { logl("updateSubscription: UICC app disabled on slot " + phoneId); markSubscriptionsInactive(phoneId); } } } else { String iccId = getIccId(phoneId); log("updateSubscription: Found iccId=" + SubscriptionInfo.givePrintableIccid(iccId) + " on phone " + phoneId); // For eSIM switching, SIM absent will not happen. Below is to exam if we find ICCID // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on that // logical slot invalid first. The correct subscription will be assigned the correct slot // later. // mismatch on the SIM slot. If that's the case, we need to mark all subscriptions on // that logical slot invalid first. The correct subscription will be assigned the // correct slot later. SubscriptionInfoInternal subInfo = mSubscriptionDatabaseManager.getAllSubscriptions() .stream() .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals(sub.getIccId())) .filter(sub -> sub.getSimSlotIndex() == phoneId && !iccId.equals( sub.getIccId())) .findFirst() .orElse(null); if (subInfo != null) { Loading Loading @@ -1333,7 +1335,8 @@ public class SubscriptionManagerService extends ISub.Stub { setDisplayNumber(msisdn, subId); } String imsi = mTelephonyManager.createForSubscriptionId(subId).getSubscriberId(); String imsi = mTelephonyManager.createForSubscriptionId( subId).getSubscriberId(); if (imsi != null) { mSubscriptionDatabaseManager.setImsi(subId, imsi); } Loading Loading @@ -1373,6 +1376,7 @@ public class SubscriptionManagerService extends ISub.Stub { mSlotIndexToSubId.remove(phoneId); logl("updateSubscription: current mapping " + slotMappingToString()); } } if (areAllSubscriptionsLoaded()) { log("Notify all subscriptions loaded."); Loading
tests/telephonytests/src/com/android/internal/telephony/subscription/SubscriptionManagerServiceTest.java +10 −0 Original line number Diff line number Diff line Loading @@ -2182,4 +2182,14 @@ public class SubscriptionManagerServiceTest extends TelephonyTest { map.clear(); assertThat(map).hasSize(0); } @Test public void testSimNotReady() { mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE); mSubscriptionManagerServiceUT.updateSimState( 0, TelephonyManager.SIM_STATE_NOT_READY, null, null); processAllMessages(); assertThat(mSubscriptionManagerServiceUT.getActiveSubIdList(false)).isEmpty(); } }