Loading tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +76 −0 Original line number Diff line number Diff line Loading @@ -1079,6 +1079,22 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subscriptionInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); int subId = getFirstSubId(); SubscriptionInfo subscriptionInfo = mSubscriptionControllerUT.getActiveSubscriptionInfo( subId, mCallingPackage, mCallingFeature); assertNotNull(subscriptionInfo); assertTrue(subscriptionInfo.getIccId().length() > 0); assertTrue(subscriptionInfo.getCardString().length() > 0); } @Test public void testGetActiveSubscriptionWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1147,6 +1163,23 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subscriptionInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoForSimSlotIndexWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); SubscriptionInfo subscriptionInfo = mSubscriptionControllerUT.getActiveSubscriptionInfoForSimSlotIndex(0, mCallingPackage, mCallingFeature); assertNotNull(subscriptionInfo); assertTrue(subscriptionInfo.getIccId().length() > 0); assertTrue(subscriptionInfo.getCardString().length() > 0); } @Test public void testGetActiveSubscriptionInfoForSimSlotIndexWithPrivilegedPermission() throws Exception { Loading Loading @@ -1216,6 +1249,24 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoListWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo objects in the List. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getActiveSubscriptionInfoList(mCallingPackage, mCallingFeature); assertTrue(subInfoList.size() > 0); for (SubscriptionInfo info : subInfoList) { assertTrue(info.getIccId().length() > 0); assertTrue(info.getCardString().length() > 0); } } @Test public void testGetActiveSubscriptionInfoListWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1285,6 +1336,23 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subInfo.getNumber()); } @Test public void testGetSubscriptionsInGroupWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo objects in the List. ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest(); setupIdentifierCarrierPrivilegesTest(); List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup( groupUuid, mCallingPackage, mCallingFeature); assertTrue(subInfoList.size() > 0); for (SubscriptionInfo info : subInfoList) { assertTrue(info.getIccId().length() > 0); assertTrue(info.getCardString().length() > 0); } } @Test public void testGetSubscriptionsInGroupWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1320,6 +1388,14 @@ public class SubscriptionControllerTest extends TelephonyTest { nullable(String.class), nullable(String.class)); } private void setupIdentifierCarrierPrivilegesTest() throws Exception { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE); setupMocksForTelephonyPermissions(); setIdentifierAccess(false); setCarrierPrivileges(true); } private int getFirstSubId() throws Exception { int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,13 @@ public abstract class TelephonyTest { anyInt()); } protected void setCarrierPrivileges(boolean hasCarrierPrivileges) { doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt()); doReturn(hasCarrierPrivileges ? TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS : TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS).when( mTelephonyManager).getCarrierPrivilegeStatus(anyInt()); } protected final void waitForHandlerAction(Handler h, long timeoutMillis) { final CountDownLatch lock = new CountDownLatch(1); h.post(lock::countDown); Loading Loading
tests/telephonytests/src/com/android/internal/telephony/SubscriptionControllerTest.java +76 −0 Original line number Diff line number Diff line Loading @@ -1079,6 +1079,22 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subscriptionInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); int subId = getFirstSubId(); SubscriptionInfo subscriptionInfo = mSubscriptionControllerUT.getActiveSubscriptionInfo( subId, mCallingPackage, mCallingFeature); assertNotNull(subscriptionInfo); assertTrue(subscriptionInfo.getIccId().length() > 0); assertTrue(subscriptionInfo.getCardString().length() > 0); } @Test public void testGetActiveSubscriptionWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1147,6 +1163,23 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subscriptionInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoForSimSlotIndexWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); SubscriptionInfo subscriptionInfo = mSubscriptionControllerUT.getActiveSubscriptionInfoForSimSlotIndex(0, mCallingPackage, mCallingFeature); assertNotNull(subscriptionInfo); assertTrue(subscriptionInfo.getIccId().length() > 0); assertTrue(subscriptionInfo.getCardString().length() > 0); } @Test public void testGetActiveSubscriptionInfoForSimSlotIndexWithPrivilegedPermission() throws Exception { Loading Loading @@ -1216,6 +1249,24 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subInfo.getNumber()); } @Test public void testGetActiveSubscriptionInfoListWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo objects in the List. testInsertSim(); setupIdentifierCarrierPrivilegesTest(); List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getActiveSubscriptionInfoList(mCallingPackage, mCallingFeature); assertTrue(subInfoList.size() > 0); for (SubscriptionInfo info : subInfoList) { assertTrue(info.getIccId().length() > 0); assertTrue(info.getCardString().length() > 0); } } @Test public void testGetActiveSubscriptionInfoListWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1285,6 +1336,23 @@ public class SubscriptionControllerTest extends TelephonyTest { assertEquals(DISPLAY_NUMBER, subInfo.getNumber()); } @Test public void testGetSubscriptionsInGroupWithCarrierPrivileges() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier // privileges the ICC ID should be available in the SubscriptionInfo objects in the List. ParcelUuid groupUuid = setupGetSubscriptionsInGroupTest(); setupIdentifierCarrierPrivilegesTest(); List<SubscriptionInfo> subInfoList = mSubscriptionControllerUT.getSubscriptionsInGroup( groupUuid, mCallingPackage, mCallingFeature); assertTrue(subInfoList.size() > 0); for (SubscriptionInfo info : subInfoList) { assertTrue(info.getIccId().length() > 0); assertTrue(info.getCardString().length() > 0); } } @Test public void testGetSubscriptionsInGroupWithPrivilegedPermission() throws Exception { // If the calling package has the READ_PRIVILEGED_PHONE_STATE permission or carrier Loading Loading @@ -1320,6 +1388,14 @@ public class SubscriptionControllerTest extends TelephonyTest { nullable(String.class), nullable(String.class)); } private void setupIdentifierCarrierPrivilegesTest() throws Exception { mContextFixture.removeCallingOrSelfPermission(ContextFixture.PERMISSION_ENABLE_ALL); mContextFixture.addCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE); setupMocksForTelephonyPermissions(); setIdentifierAccess(false); setCarrierPrivileges(true); } private int getFirstSubId() throws Exception { int[] subIds = mSubscriptionControllerUT.getActiveSubIdList(/*visibleOnly*/false); assertTrue(subIds != null && subIds.length != 0); Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,13 @@ public abstract class TelephonyTest { anyInt()); } protected void setCarrierPrivileges(boolean hasCarrierPrivileges) { doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt()); doReturn(hasCarrierPrivileges ? TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS : TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS).when( mTelephonyManager).getCarrierPrivilegeStatus(anyInt()); } protected final void waitForHandlerAction(Handler h, long timeoutMillis) { final CountDownLatch lock = new CountDownLatch(1); h.post(lock::countDown); Loading