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

Commit c9d80664 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update Mobile Data State on subscription changes." into sc-dev

parents a7ff24bf 1dba7e09
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -453,6 +453,10 @@ public class Vcn extends Handler {
        for (VcnGatewayConnection gatewayConnection : mVcnGatewayConnections.values()) {
            gatewayConnection.updateSubscriptionSnapshot(mLastSnapshot);
        }

        // Update the mobile data state after updating the subscription snapshot as a change in
        // subIds for a subGroup may affect the mobile data state.
        handleMobileDataToggled();
    }

    private void handleMobileDataToggled() {
+21 −0
Original line number Diff line number Diff line
@@ -242,6 +242,27 @@ public class VcnTest {
        verifyUpdateSubscriptionSnapshotNotifiesGatewayConnections(VCN_STATUS_CODE_SAFE_MODE);
    }

    @Test
    public void testSubscriptionSnapshotUpdatesMobileDataState() {
        final NetworkRequestListener requestListener = verifyAndGetRequestListener();
        startVcnGatewayWithCapabilities(requestListener, TEST_CAPS[0]);

        // Expect mobile data enabled from setUp()
        assertTrue(mVcn.isMobileDataEnabled());

        final TelephonySubscriptionSnapshot updatedSnapshot =
                mock(TelephonySubscriptionSnapshot.class);
        doReturn(TEST_SUB_IDS_IN_GROUP)
                .when(updatedSnapshot)
                .getAllSubIdsInGroup(eq(TEST_SUB_GROUP));
        doReturn(false).when(mTelephonyManager).isDataEnabled();

        mVcn.updateSubscriptionSnapshot(updatedSnapshot);
        mTestLooper.dispatchAll();

        assertFalse(mVcn.isMobileDataEnabled());
    }

    private void triggerVcnRequestListeners(NetworkRequestListener requestListener) {
        for (final int[] caps : TEST_CAPS) {
            startVcnGatewayWithCapabilities(requestListener, caps);