Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 420a1821 authored by Ling Ma's avatar Ling Ma
Browse files

Remove rolled out flag rejectBadSubIdInteraction

The flag has been rolled out 100%: https://gantry.corp.google.com/changes/aoeo33c000001\?build_unique_id\=Frontend%3A%20android_platform_telephony%2C%20Study%3A%20ComAndroidInternalTelephonyFlagsRejectBadSubIdInteractionLaunch

Test: basic voice call + data browsing
Test: atest
Bug: 311863922

Change-Id: I86649119692aefeb57df1dc006b82bb26390b96b
parent 6cba5cc6
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
package: "com.android.internal.telephony.flags"

# 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"
+1 −29
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ public class TelephonyPermissionsTest {

    // Mocked classes
    private Context mMockContext;
    private FeatureFlags mMockFeatureFlag;
    private AppOpsManager mMockAppOps;
    private SubscriptionManager mMockSubscriptionManager;
    private ITelephony mMockTelephony;
@@ -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);
@@ -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;
@@ -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);
@@ -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);
@@ -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);
    }
}