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

Commit 1fcdbab4 authored by fionaxu's avatar fionaxu
Browse files

not bypass roaming checking for restricted nw request

Bug: 74096275
Test: Manual
Change-Id: Iae57cbf231fa4be27c77c2f30ad21c50f78a4697
parent bc0269bd
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1337,11 +1337,11 @@ public class DcTracker extends Handler {
            reasons.add(DataAllowedReasonType.UNMETERED_APN);
        }

        // If the request is restricted and there are only soft disallowed reasons (e.g. data
        // disabled, data roaming disabled) existing, we should allow the data.
        // If the request is restricted and there are only disallowed reasons due to data
        // disabled, we should allow the data.
        if (apnContext != null
                && !apnContext.hasNoRestrictedRequests(true)
                && !reasons.allowed()) {
                && reasons.contains(DataDisallowedReasonType.DATA_DISABLED)) {
            reasons.add(DataAllowedReasonType.RESTRICTED_REQUEST);
        }

+31 −0
Original line number Diff line number Diff line
@@ -1085,6 +1085,37 @@ public class DcTrackerTest extends TelephonyTest {
                any(Message.class));
    }

    // Test the restricted data request when roaming is disabled.
    @Test
    @SmallTest
    public void testTrySetupRestrictedRoamingDisabled() throws Exception {
        initApns(PhoneConstants.APN_TYPE_DEFAULT, new String[]{PhoneConstants.APN_TYPE_ALL});
        doReturn(false).when(mApnContext).hasNoRestrictedRequests(eq(true));

        mDct.setUserDataEnabled(true);
        mDct.setDataRoamingEnabledByUser(false);
        mBundle.putStringArray(CarrierConfigManager.KEY_CARRIER_METERED_APN_TYPES_STRINGS,
                new String[]{PhoneConstants.APN_TYPE_DEFAULT});
        //user is in roaming
        doReturn(true).when(mServiceState).getDataRoaming();

        logd("Sending EVENT_RECORDS_LOADED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_RECORDS_LOADED, null));
        waitForMs(200);

        logd("Sending EVENT_DATA_CONNECTION_ATTACHED");
        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_DATA_CONNECTION_ATTACHED, null));
        waitForMs(200);

        mDct.sendMessage(mDct.obtainMessage(DctConstants.EVENT_TRY_SETUP_DATA, mApnContext));
        waitForMs(200);

        // expect no restricted data connection
        verify(mSimulatedCommandsVerifier, times(0)).setupDataCall(anyInt(), any(DataProfile.class),
                eq(false), eq(false), eq(DataService.REQUEST_REASON_NORMAL), any(),
                any(Message.class));
    }

    // Test the default data when data is not connectable.
    @Test
    @SmallTest