Loading src/java/com/android/internal/telephony/SubscriptionController.java +9 −3 Original line number Diff line number Diff line Loading @@ -897,7 +897,12 @@ public class SubscriptionController extends ISub.Stub { selection += " OR " + SubscriptionManager.IS_EMBEDDED + "=1"; } List<String> iccIds = getIccIdsOfInsertedSims(); // Available eSIM profiles are reported by EuiccManager. However for physical SIMs if // they are in inactive slot or programmatically disabled, they are still considered // available. In this case we get their iccid from slot info and include their // subscriptionInfos. List<String> iccIds = getIccIdsOfInsertedPhysicalSims(); if (!iccIds.isEmpty()) { selection += " OR (" + getSelectionForIccIdList(iccIds.toArray(new String[0])) + ")"; Loading @@ -919,7 +924,7 @@ public class SubscriptionController extends ISub.Stub { } } private List<String> getIccIdsOfInsertedSims() { private List<String> getIccIdsOfInsertedPhysicalSims() { List<String> ret = new ArrayList<>(); UiccSlot[] uiccSlots = UiccController.getInstance().getUiccSlots(); if (uiccSlots == null) return ret; Loading @@ -927,8 +932,9 @@ public class SubscriptionController extends ISub.Stub { for (UiccSlot uiccSlot : uiccSlots) { if (uiccSlot != null && uiccSlot.getCardState() != null && uiccSlot.getCardState().isCardPresent() && !uiccSlot.isEuicc() && !TextUtils.isEmpty(uiccSlot.getIccId())) { ret.add(uiccSlot.getIccId()); ret.add(IccUtils.stripTrailingFs(uiccSlot.getIccId())); } } Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -1107,6 +1107,36 @@ public class SubscriptionControllerTest extends TelephonyTest { SubscriptionManager.NAME_SOURCE_CARRIER_ID)); } @Test @SmallTest public void testGetAvailableSubscriptionList_withTrailingF() throws Exception { // TODO b/123300875 slot index 1 is not expected to be valid mSubscriptionControllerUT.addSubInfoRecord("123", 1); // sub 1 mSubscriptionControllerUT.addSubInfoRecord("456", 0); // sub 2 // Remove "123" from active sim list but have it inserted. UiccSlot[] uiccSlots = {mUiccSlot}; IccCardStatus.CardState cardState = CARDSTATE_PRESENT; doReturn(uiccSlots).when(mUiccController).getUiccSlots(); doReturn(cardState).when(mUiccSlot).getCardState(); // IccId ends with a 'F' which should be ignored and taking into account. doReturn("123F").when(mUiccSlot).getIccId(); mSubscriptionControllerUT.clearSubInfoRecord(1); // Active sub list should return 1 now. List<SubscriptionInfo> infoList = mSubscriptionControllerUT .getActiveSubscriptionInfoList(mCallingPackage, mCallingFeature); assertEquals(1, infoList.size()); assertEquals("456", infoList.get(0).getIccId()); // Available sub list should still return two. infoList = mSubscriptionControllerUT .getAvailableSubscriptionInfoList(mCallingPackage, mCallingFeature); assertEquals(2, infoList.size()); assertEquals("123", infoList.get(0).getIccId()); assertEquals("456", infoList.get(1).getIccId()); } @Test @SmallTest public void testSetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { Loading Loading
src/java/com/android/internal/telephony/SubscriptionController.java +9 −3 Original line number Diff line number Diff line Loading @@ -897,7 +897,12 @@ public class SubscriptionController extends ISub.Stub { selection += " OR " + SubscriptionManager.IS_EMBEDDED + "=1"; } List<String> iccIds = getIccIdsOfInsertedSims(); // Available eSIM profiles are reported by EuiccManager. However for physical SIMs if // they are in inactive slot or programmatically disabled, they are still considered // available. In this case we get their iccid from slot info and include their // subscriptionInfos. List<String> iccIds = getIccIdsOfInsertedPhysicalSims(); if (!iccIds.isEmpty()) { selection += " OR (" + getSelectionForIccIdList(iccIds.toArray(new String[0])) + ")"; Loading @@ -919,7 +924,7 @@ public class SubscriptionController extends ISub.Stub { } } private List<String> getIccIdsOfInsertedSims() { private List<String> getIccIdsOfInsertedPhysicalSims() { List<String> ret = new ArrayList<>(); UiccSlot[] uiccSlots = UiccController.getInstance().getUiccSlots(); if (uiccSlots == null) return ret; Loading @@ -927,8 +932,9 @@ public class SubscriptionController extends ISub.Stub { for (UiccSlot uiccSlot : uiccSlots) { if (uiccSlot != null && uiccSlot.getCardState() != null && uiccSlot.getCardState().isCardPresent() && !uiccSlot.isEuicc() && !TextUtils.isEmpty(uiccSlot.getIccId())) { ret.add(uiccSlot.getIccId()); ret.add(IccUtils.stripTrailingFs(uiccSlot.getIccId())); } } Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +30 −0 Original line number Diff line number Diff line Loading @@ -1107,6 +1107,36 @@ public class SubscriptionControllerTest extends TelephonyTest { SubscriptionManager.NAME_SOURCE_CARRIER_ID)); } @Test @SmallTest public void testGetAvailableSubscriptionList_withTrailingF() throws Exception { // TODO b/123300875 slot index 1 is not expected to be valid mSubscriptionControllerUT.addSubInfoRecord("123", 1); // sub 1 mSubscriptionControllerUT.addSubInfoRecord("456", 0); // sub 2 // Remove "123" from active sim list but have it inserted. UiccSlot[] uiccSlots = {mUiccSlot}; IccCardStatus.CardState cardState = CARDSTATE_PRESENT; doReturn(uiccSlots).when(mUiccController).getUiccSlots(); doReturn(cardState).when(mUiccSlot).getCardState(); // IccId ends with a 'F' which should be ignored and taking into account. doReturn("123F").when(mUiccSlot).getIccId(); mSubscriptionControllerUT.clearSubInfoRecord(1); // Active sub list should return 1 now. List<SubscriptionInfo> infoList = mSubscriptionControllerUT .getActiveSubscriptionInfoList(mCallingPackage, mCallingFeature); assertEquals(1, infoList.size()); assertEquals("456", infoList.get(0).getIccId()); // Available sub list should still return two. infoList = mSubscriptionControllerUT .getAvailableSubscriptionInfoList(mCallingPackage, mCallingFeature); assertEquals(2, infoList.size()); assertEquals("123", infoList.get(0).getIccId()); assertEquals("456", infoList.get(1).getIccId()); } @Test @SmallTest public void testSetPreferredDataSubscriptionId_phoneSwitcherNotInitialized() throws Exception { Loading