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

Commit 9d8fd5d8 authored by Benedict Wong's avatar Benedict Wong
Browse files

Trigger reevaluation of all requests when mobile data state changes

This change ensures mobile data state changes result in the reevaluation
of all NetworkRequests; ensuring that any requests that can be fulfilled
as a result of the mobile data state change start the relevant
GatewayConnections

Test: atest FrameworksVcnTests
Change-Id: I442ca2ee0fc8b9ad962a2491ddc3818535d9e042
parent c6fe3006
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -396,6 +396,15 @@ public class Vcn extends Handler {
                    continue;
                    continue;
                }
                }


                // This should never happen, by virtue of checking for the above check for
                // pre-existing VcnGatewayConnections that satisfy a given request, but if state
                // that affects the satsifying of requests changes, this is theoretically possible.
                if (mVcnGatewayConnections.containsKey(gatewayConnectionConfig)) {
                    Slog.wtf(getLogTag(), "Attempted to bring up VcnGatewayConnection for config "
                            + "with existing VcnGatewayConnection");
                    return;
                }

                final VcnGatewayConnection vcnGatewayConnection =
                final VcnGatewayConnection vcnGatewayConnection =
                        mDeps.newVcnGatewayConnection(
                        mDeps.newVcnGatewayConnection(
                                mVcnContext,
                                mVcnContext,
@@ -467,6 +476,9 @@ public class Vcn extends Handler {
                    }
                    }
                }
                }
            }
            }

            // Trigger re-evaluation of all requests; mobile data state impacts supported caps.
            mVcnContext.getVcnNetworkProvider().resendAllRequests(mRequestListener);
        }
        }
    }
    }


+5 −1
Original line number Original line Diff line number Diff line
@@ -388,8 +388,9 @@ public class VcnTest {
        final ContentObserver contentObserver = captor.getValue();
        final ContentObserver contentObserver = captor.getValue();


        // Start VcnGatewayConnections
        // Start VcnGatewayConnections
        final NetworkRequestListener requestListener = verifyAndGetRequestListener();
        mVcn.setMobileDataEnabled(startingToggleState);
        mVcn.setMobileDataEnabled(startingToggleState);
        triggerVcnRequestListeners(verifyAndGetRequestListener());
        triggerVcnRequestListeners(requestListener);
        final Map<VcnGatewayConnectionConfig, VcnGatewayConnection> gateways =
        final Map<VcnGatewayConnectionConfig, VcnGatewayConnection> gateways =
                mVcn.getVcnGatewayConnectionConfigMap();
                mVcn.getVcnGatewayConnectionConfigMap();


@@ -411,6 +412,9 @@ public class VcnTest {
            }
            }
        }
        }


        if (startingToggleState != endingToggleState) {
            verify(mVcnNetworkProvider).resendAllRequests(requestListener);
        }
        assertEquals(endingToggleState, mVcn.isMobileDataEnabled());
        assertEquals(endingToggleState, mVcn.isMobileDataEnabled());
    }
    }