Loading flags/messaging.aconfig +0 −8 Original line number Diff line number Diff line package: "com.android.internal.telephony.flags" container: "system" # OWNER=linggm TARGET=24Q1 flag { name: "reject_bad_sub_id_interaction" namespace: "telephony" description: "Previously, the DB allows insertion of a random sub Id, but doesn't allow query it. This change rejects such interaction." bug: "294125411" } # OWNER=hwangoo TARGET=24Q2 flag { name: "sms_domain_selection_enabled" Loading tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +1 −29 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ public class TelephonyPermissionsTest { // Mocked classes private Context mMockContext; private FeatureFlags mMockFeatureFlag; private AppOpsManager mMockAppOps; private SubscriptionManager mMockSubscriptionManager; private ITelephony mMockTelephony; Loading @@ -92,7 +91,6 @@ public class TelephonyPermissionsTest { @Before public void setUp() throws Exception { mMockContext = mock(Context.class); mMockFeatureFlag = mock(FeatureFlags.class); mMockAppOps = mock(AppOpsManager.class); mMockSubscriptionManager = mock(SubscriptionManager.class); mMockTelephony = mock(ITelephony.class); Loading Loading @@ -135,13 +133,11 @@ public class TelephonyPermissionsTest { when(mMockContext.checkPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, PID, UID)).thenReturn(PackageManager.PERMISSION_DENIED); replaceFeatureFlag(mMockFeatureFlag); setTelephonyMockAsService(); } @After public void tearDown() throws Exception { replaceFeatureFlag(mRealFeatureFlagToBeRestored); mMockContentResolver = null; mFakeSettingsConfigProvider = null; mRealFeatureFlagToBeRestored = null; Loading Loading @@ -554,9 +550,7 @@ public class TelephonyPermissionsTest { } @Test public void testCheckSubscriptionAssociatedWithUser_badSub_flag_enabled() { doReturn(true).when(mMockFeatureFlag).rejectBadSubIdInteraction(); public void testCheckSubscriptionAssociatedWithUser() { doThrow(new IllegalArgumentException("has no records on device")) .when(mMockSubscriptionManager).isSubscriptionAssociatedWithUser(SUB_ID, UserHandle.SYSTEM); Loading @@ -564,19 +558,6 @@ public class TelephonyPermissionsTest { UserHandle.SYSTEM)); } @Test public void testCheckSubscriptionAssociatedWithUser_badSub_flag_disabled() { doReturn(false).when(mMockFeatureFlag).rejectBadSubIdInteraction(); doThrow(new IllegalArgumentException("No records found for sub")) .when(mMockSubscriptionManager).isSubscriptionAssociatedWithUser(SUB_ID, UserHandle.SYSTEM); assertTrue(TelephonyPermissions.checkSubscriptionAssociatedWithUser(mMockContext, SUB_ID, UserHandle.SYSTEM)); assertTrue(TelephonyPermissions.checkSubscriptionAssociatedWithUser(mMockContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, UserHandle.SYSTEM)); } // Put mMockTelephony into service cache so that TELEPHONY_SUPPLIER will get it. private void setTelephonyMockAsService() throws Exception { when(mMockTelephonyBinder.queryLocalInterface(anyString())).thenReturn(mMockTelephony); Loading Loading @@ -666,13 +647,4 @@ public class TelephonyPermissionsTest { field.setAccessible(true); field.set(providerHolder, iContentProvider); } private synchronized void replaceFeatureFlag(final FeatureFlags newValue) throws Exception { Field field = TelephonyPermissions.class.getDeclaredField("sFeatureFlag"); field.setAccessible(true); mRealFeatureFlagToBeRestored = (FeatureFlags) field.get(null); field.set(null, newValue); } } Loading
flags/messaging.aconfig +0 −8 Original line number Diff line number Diff line package: "com.android.internal.telephony.flags" container: "system" # OWNER=linggm TARGET=24Q1 flag { name: "reject_bad_sub_id_interaction" namespace: "telephony" description: "Previously, the DB allows insertion of a random sub Id, but doesn't allow query it. This change rejects such interaction." bug: "294125411" } # OWNER=hwangoo TARGET=24Q2 flag { name: "sms_domain_selection_enabled" Loading
tests/telephonytests/src/com/android/internal/telephony/TelephonyPermissionsTest.java +1 −29 Original line number Diff line number Diff line Loading @@ -73,7 +73,6 @@ public class TelephonyPermissionsTest { // Mocked classes private Context mMockContext; private FeatureFlags mMockFeatureFlag; private AppOpsManager mMockAppOps; private SubscriptionManager mMockSubscriptionManager; private ITelephony mMockTelephony; Loading @@ -92,7 +91,6 @@ public class TelephonyPermissionsTest { @Before public void setUp() throws Exception { mMockContext = mock(Context.class); mMockFeatureFlag = mock(FeatureFlags.class); mMockAppOps = mock(AppOpsManager.class); mMockSubscriptionManager = mock(SubscriptionManager.class); mMockTelephony = mock(ITelephony.class); Loading Loading @@ -135,13 +133,11 @@ public class TelephonyPermissionsTest { when(mMockContext.checkPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, PID, UID)).thenReturn(PackageManager.PERMISSION_DENIED); replaceFeatureFlag(mMockFeatureFlag); setTelephonyMockAsService(); } @After public void tearDown() throws Exception { replaceFeatureFlag(mRealFeatureFlagToBeRestored); mMockContentResolver = null; mFakeSettingsConfigProvider = null; mRealFeatureFlagToBeRestored = null; Loading Loading @@ -554,9 +550,7 @@ public class TelephonyPermissionsTest { } @Test public void testCheckSubscriptionAssociatedWithUser_badSub_flag_enabled() { doReturn(true).when(mMockFeatureFlag).rejectBadSubIdInteraction(); public void testCheckSubscriptionAssociatedWithUser() { doThrow(new IllegalArgumentException("has no records on device")) .when(mMockSubscriptionManager).isSubscriptionAssociatedWithUser(SUB_ID, UserHandle.SYSTEM); Loading @@ -564,19 +558,6 @@ public class TelephonyPermissionsTest { UserHandle.SYSTEM)); } @Test public void testCheckSubscriptionAssociatedWithUser_badSub_flag_disabled() { doReturn(false).when(mMockFeatureFlag).rejectBadSubIdInteraction(); doThrow(new IllegalArgumentException("No records found for sub")) .when(mMockSubscriptionManager).isSubscriptionAssociatedWithUser(SUB_ID, UserHandle.SYSTEM); assertTrue(TelephonyPermissions.checkSubscriptionAssociatedWithUser(mMockContext, SUB_ID, UserHandle.SYSTEM)); assertTrue(TelephonyPermissions.checkSubscriptionAssociatedWithUser(mMockContext, SubscriptionManager.INVALID_SUBSCRIPTION_ID, UserHandle.SYSTEM)); } // Put mMockTelephony into service cache so that TELEPHONY_SUPPLIER will get it. private void setTelephonyMockAsService() throws Exception { when(mMockTelephonyBinder.queryLocalInterface(anyString())).thenReturn(mMockTelephony); Loading Loading @@ -666,13 +647,4 @@ public class TelephonyPermissionsTest { field.setAccessible(true); field.set(providerHolder, iContentProvider); } private synchronized void replaceFeatureFlag(final FeatureFlags newValue) throws Exception { Field field = TelephonyPermissions.class.getDeclaredField("sFeatureFlag"); field.setAccessible(true); mRealFeatureFlagToBeRestored = (FeatureFlags) field.get(null); field.set(null, newValue); } }