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

Commit cb855759 authored by Cody Kesting's avatar Cody Kesting Committed by Gerrit Code Review
Browse files

Merge "Update Mobile Data State on subscription changes."

parents e2a58ab7 0da0fb10
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);