Loading tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.Manifest.permission.READ_SMS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.doReturn; Loading Loading @@ -54,6 +55,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(true).when(mSubscriptionController).isActiveSubId(0, TAG); doReturn(true).when(mSubscriptionController).isActiveSubId(1, TAG); doReturn(new int[]{0, 1}).when(mSubscriptionManager) .getActiveSubscriptionIdList(anyBoolean()); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -85,7 +86,8 @@ public class TelephonyPermissionsTest { mMockSubscriptionManager); when(mMockContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn( mMockDevicePolicyManager); when(mMockSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); when(mMockSubscriptionManager.getActiveSubscriptionIdList(anyBoolean())).thenReturn( new int[]{SUB_ID}); // By default, assume we have no permissions or app-ops bits. doThrow(new SecurityException()).when(mMockContext) Loading Loading @@ -318,7 +320,7 @@ public class TelephonyPermissionsTest { @Test public void testCheckReadDeviceIdentifiers_hasCarrierPrivilegesOnOtherSubscription() throws Exception { when(mMockSubscriptionManager.getActiveSubscriptionIdList()).thenReturn( when(mMockSubscriptionManager.getActiveSubscriptionIdList(anyBoolean())).thenReturn( new int[]{SUB_ID, SUB_ID_2}); when(mMockTelephony.getCarrierPrivilegeStatusForUid(eq(SUB_ID_2), eq(UID))).thenReturn( TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS); Loading @@ -327,6 +329,20 @@ public class TelephonyPermissionsTest { SUB_ID, PID, UID, PACKAGE, MSG)); } @Test public void testCheckReadDeviceIdentifiers_hasCarrierPrivilegesOnInvisibleSubscription() throws Exception { when(mMockSubscriptionManager.getActiveSubscriptionIdList(true)).thenReturn( new int[]{SUB_ID}); when(mMockSubscriptionManager.getActiveSubscriptionIdList(false)).thenReturn( new int[]{SUB_ID, SUB_ID_2}); when(mMockTelephony.getCarrierPrivilegeStatusForUid(eq(SUB_ID_2), eq(UID))) .thenReturn(TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS); assertTrue( TelephonyPermissions.checkReadDeviceIdentifiers(mMockContext, () -> mMockTelephony, SUB_ID_2, PID, UID, PACKAGE, MSG)); } @Test public void testCheckReadDeviceIdentifiers_hasAppOpNullSubscription() { // The appop check comes after the carrier privilege check; this test verifies if the Loading Loading
tests/telephonytests/src/com/android/internal/telephony/PhoneSubInfoControllerTest.java +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.Manifest.permission.READ_SMS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.doReturn; Loading Loading @@ -54,6 +55,8 @@ public class PhoneSubInfoControllerTest extends TelephonyTest { doReturn(2).when(mTelephonyManager).getPhoneCount(); doReturn(true).when(mSubscriptionController).isActiveSubId(0, TAG); doReturn(true).when(mSubscriptionController).isActiveSubId(1, TAG); doReturn(new int[]{0, 1}).when(mSubscriptionManager) .getActiveSubscriptionIdList(anyBoolean()); mServiceManagerMockedServices.put("isub", mSubscriptionController); doReturn(mSubscriptionController).when(mSubscriptionController) Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +18 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; Loading Loading @@ -85,7 +86,8 @@ public class TelephonyPermissionsTest { mMockSubscriptionManager); when(mMockContext.getSystemService(Context.DEVICE_POLICY_SERVICE)).thenReturn( mMockDevicePolicyManager); when(mMockSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[]{SUB_ID}); when(mMockSubscriptionManager.getActiveSubscriptionIdList(anyBoolean())).thenReturn( new int[]{SUB_ID}); // By default, assume we have no permissions or app-ops bits. doThrow(new SecurityException()).when(mMockContext) Loading Loading @@ -318,7 +320,7 @@ public class TelephonyPermissionsTest { @Test public void testCheckReadDeviceIdentifiers_hasCarrierPrivilegesOnOtherSubscription() throws Exception { when(mMockSubscriptionManager.getActiveSubscriptionIdList()).thenReturn( when(mMockSubscriptionManager.getActiveSubscriptionIdList(anyBoolean())).thenReturn( new int[]{SUB_ID, SUB_ID_2}); when(mMockTelephony.getCarrierPrivilegeStatusForUid(eq(SUB_ID_2), eq(UID))).thenReturn( TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS); Loading @@ -327,6 +329,20 @@ public class TelephonyPermissionsTest { SUB_ID, PID, UID, PACKAGE, MSG)); } @Test public void testCheckReadDeviceIdentifiers_hasCarrierPrivilegesOnInvisibleSubscription() throws Exception { when(mMockSubscriptionManager.getActiveSubscriptionIdList(true)).thenReturn( new int[]{SUB_ID}); when(mMockSubscriptionManager.getActiveSubscriptionIdList(false)).thenReturn( new int[]{SUB_ID, SUB_ID_2}); when(mMockTelephony.getCarrierPrivilegeStatusForUid(eq(SUB_ID_2), eq(UID))) .thenReturn(TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS); assertTrue( TelephonyPermissions.checkReadDeviceIdentifiers(mMockContext, () -> mMockTelephony, SUB_ID_2, PID, UID, PACKAGE, MSG)); } @Test public void testCheckReadDeviceIdentifiers_hasAppOpNullSubscription() { // The appop check comes after the carrier privilege check; this test verifies if the Loading