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

Commit 7ec34710 authored by Jack Yu's avatar Jack Yu
Browse files

Allow IWLAN data in PS restricted condition

The PS restricted event from modem should only affect
the data bring up on cellular. Fixed by adding transport
check when evaluating unsatisfied network requests.

Fix: 242115939
Test: Basic testing + atest DataNetworkControllerTest
Merged-In: I9ae4ac333dad3d8b071641593c8193150a5e9b80
Change-Id: I9ae4ac333dad3d8b071641593c8193150a5e9b80
parent 0d89e50e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ public class DataNetworkController extends Handler {
    private final @NonNull Set<DataNetworkControllerCallback> mDataNetworkControllerCallbacks =
            new ArraySet<>();

    /** Indicates if packet switch data is restricted by the network. */
    /** Indicates if packet switch data is restricted by the cellular network. */
    private boolean mPsRestricted = false;

    /** Indicates if NR advanced is allowed by PCO. */
@@ -1467,8 +1467,8 @@ public class DataNetworkController extends Handler {
            evaluation.addDataDisallowedReason(DataDisallowedReason.ROAMING_DISABLED);
        }

        // Check if data is restricted by the network.
        if (mPsRestricted) {
        // Check if data is restricted by the cellular network.
        if (mPsRestricted && transport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
            evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_RESTRICTED_BY_NETWORK);
        }

+35 −0
Original line number Diff line number Diff line
@@ -1193,6 +1193,41 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET);
    }

    @Test
    public void testPsRestrictedAllowIwlan() throws Exception {
        // IMS preferred on IWLAN.
        doReturn(AccessNetworkConstants.TRANSPORT_TYPE_WLAN).when(mAccessNetworksManager)
                .getPreferredTransportByNetworkCapability(
                        eq(NetworkCapabilities.NET_CAPABILITY_IMS));

        // PS restricted
        mDataNetworkControllerUT.obtainMessage(6/*EVENT_PS_RESTRICT_ENABLED*/).sendToTarget();
        processAllMessages();

        // PS restricted, new setup NOT allowed
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET));
        setSuccessfulSetupDataResponse(mMockedDataServiceManagers
                .get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), 2);
        processAllMessages();
        verifyAllDataDisconnected();

        // Request IMS
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_IMS,
                        NetworkCapabilities.NET_CAPABILITY_MMTEL));
        setSuccessfulSetupDataResponse(mMockedDataServiceManagers
                .get(AccessNetworkConstants.TRANSPORT_TYPE_WLAN), 3);
        processAllMessages();

        // Make sure IMS on IWLAN.
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS);
        assertThat(getDataNetworks()).hasSize(1);
        DataNetwork dataNetwork = getDataNetworks().get(0);
        assertThat(dataNetwork.getTransport()).isEqualTo(
                AccessNetworkConstants.TRANSPORT_TYPE_WLAN);
    }

    @Test
    public void testRatChanges() throws Exception {
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,