Loading src/java/com/android/internal/telephony/euicc/EuiccController.java +10 −1 Original line number Diff line number Diff line Loading @@ -1179,7 +1179,12 @@ public class EuiccController extends IEuiccController.Stub { return false; } for (SubscriptionInfo subInfo : subInfoList) { if (subInfo.getCardId() == cardId && subInfo.isEmbedded() // If cardId == TelephonyManager.UNSUPPORTED_CARD_ID, we assume it does not support // multiple eSIMs. There are older multi-active SIM devices which do not implement HAL // 1.2 and if they have multiple eSIMs, we let it pass if the app can manage an active // subscription on any eSIM. That's the best we can do here. if ((cardId == TelephonyManager.UNSUPPORTED_CARD_ID || subInfo.getCardId() == cardId) && subInfo.isEmbedded() && mSubscriptionManager.canManageSubscription(subInfo, callingPackage)) { return true; } Loading @@ -1201,6 +1206,10 @@ public class EuiccController extends IEuiccController.Stub { if (subInfoList == null || subInfoList.size() == 0) { return false; } // If it's a multi-active SIM device, we assume it's above HAL 1.2 which supports cardId. // There are older multi-active SIM devices but don't implement HAL 1.2. In this case, // platform can't even detect UiccCardInfo#isEuicc as true for eSIM, which won't let the // below check pass. That's the best we can do here. if (supportMultiActiveSlots()) { // The target card should be an eUICC. List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo(); Loading tests/telephonytests/src/com/android/internal/telephony/euicc/EuiccControllerTest.java +15 −7 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.UiccAccessRule; import android.telephony.UiccCardInfo; import android.telephony.euicc.DownloadableSubscription; Loading Loading @@ -197,31 +198,38 @@ public class EuiccControllerTest extends TelephonyTest { @Test(expected = SecurityException.class) public void testGetEid_noPrivileges() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); callGetEid(true /* success */, "ABCDE" /* eid */); callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID); } @Test public void testGetEid_withPhoneStatePrivileged() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */)); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID)); } @Test public void testGetEid_withCarrierPrivileges() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, true /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */)); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID)); } @Test public void testGetEid_failure() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertNull(callGetEid(false /* success */, null /* eid */)); assertNull(callGetEid(false /* success */, null /* eid */, CARD_ID)); } @Test public void testGetEid_nullReturnValue() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertNull(callGetEid(true /* success */, null /* eid */)); assertNull(callGetEid(true /* success */, null /* eid */, CARD_ID)); } @Test public void testGetEid_unsupportedCardId() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, true /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, TelephonyManager.UNSUPPORTED_CARD_ID)); } @Test(expected = SecurityException.class) Loading Loading @@ -1017,7 +1025,7 @@ public class EuiccControllerTest extends TelephonyTest { Collections.singletonList(subInfo)); } private String callGetEid(final boolean success, final @Nullable String eid) { private String callGetEid(final boolean success, final @Nullable String eid, int cardId) { doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Exception { Loading @@ -1032,7 +1040,7 @@ public class EuiccControllerTest extends TelephonyTest { } }).when(mMockConnector).getEid(anyInt(), Mockito.<EuiccConnector.GetEidCommandCallback>any()); return mController.getEid(CARD_ID, PACKAGE_NAME); return mController.getEid(cardId, PACKAGE_NAME); } private int callGetOtaStatus(final boolean success, final int status) { Loading Loading
src/java/com/android/internal/telephony/euicc/EuiccController.java +10 −1 Original line number Diff line number Diff line Loading @@ -1179,7 +1179,12 @@ public class EuiccController extends IEuiccController.Stub { return false; } for (SubscriptionInfo subInfo : subInfoList) { if (subInfo.getCardId() == cardId && subInfo.isEmbedded() // If cardId == TelephonyManager.UNSUPPORTED_CARD_ID, we assume it does not support // multiple eSIMs. There are older multi-active SIM devices which do not implement HAL // 1.2 and if they have multiple eSIMs, we let it pass if the app can manage an active // subscription on any eSIM. That's the best we can do here. if ((cardId == TelephonyManager.UNSUPPORTED_CARD_ID || subInfo.getCardId() == cardId) && subInfo.isEmbedded() && mSubscriptionManager.canManageSubscription(subInfo, callingPackage)) { return true; } Loading @@ -1201,6 +1206,10 @@ public class EuiccController extends IEuiccController.Stub { if (subInfoList == null || subInfoList.size() == 0) { return false; } // If it's a multi-active SIM device, we assume it's above HAL 1.2 which supports cardId. // There are older multi-active SIM devices but don't implement HAL 1.2. In this case, // platform can't even detect UiccCardInfo#isEuicc as true for eSIM, which won't let the // below check pass. That's the best we can do here. if (supportMultiActiveSlots()) { // The target card should be an eUICC. List<UiccCardInfo> cardInfos = mTelephonyManager.getUiccCardsInfo(); Loading
tests/telephonytests/src/com/android/internal/telephony/euicc/EuiccControllerTest.java +15 −7 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.service.euicc.GetDefaultDownloadableSubscriptionListResult; import android.service.euicc.GetDownloadableSubscriptionMetadataResult; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.UiccAccessRule; import android.telephony.UiccCardInfo; import android.telephony.euicc.DownloadableSubscription; Loading Loading @@ -197,31 +198,38 @@ public class EuiccControllerTest extends TelephonyTest { @Test(expected = SecurityException.class) public void testGetEid_noPrivileges() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); callGetEid(true /* success */, "ABCDE" /* eid */); callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID); } @Test public void testGetEid_withPhoneStatePrivileged() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */)); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID)); } @Test public void testGetEid_withCarrierPrivileges() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, true /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */)); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, CARD_ID)); } @Test public void testGetEid_failure() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertNull(callGetEid(false /* success */, null /* eid */)); assertNull(callGetEid(false /* success */, null /* eid */, CARD_ID)); } @Test public void testGetEid_nullReturnValue() throws Exception { setGetEidPermissions(true /* hasPhoneStatePrivileged */, false /* hasCarrierPrivileges */); assertNull(callGetEid(true /* success */, null /* eid */)); assertNull(callGetEid(true /* success */, null /* eid */, CARD_ID)); } @Test public void testGetEid_unsupportedCardId() throws Exception { setGetEidPermissions(false /* hasPhoneStatePrivileged */, true /* hasCarrierPrivileges */); assertEquals("ABCDE", callGetEid(true /* success */, "ABCDE" /* eid */, TelephonyManager.UNSUPPORTED_CARD_ID)); } @Test(expected = SecurityException.class) Loading Loading @@ -1017,7 +1025,7 @@ public class EuiccControllerTest extends TelephonyTest { Collections.singletonList(subInfo)); } private String callGetEid(final boolean success, final @Nullable String eid) { private String callGetEid(final boolean success, final @Nullable String eid, int cardId) { doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Exception { Loading @@ -1032,7 +1040,7 @@ public class EuiccControllerTest extends TelephonyTest { } }).when(mMockConnector).getEid(anyInt(), Mockito.<EuiccConnector.GetEidCommandCallback>any()); return mController.getEid(CARD_ID, PACKAGE_NAME); return mController.getEid(cardId, PACKAGE_NAME); } private int callGetOtaStatus(final boolean success, final int status) { Loading