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

Commit 0906d6bc authored by Benedict Wong's avatar Benedict Wong
Browse files

Don't process dup unwanted() when unregistering NetworkAgent

In cases where the NetworkAgent is unregistered (eg. Safe mode), but the
VCN is not shut down, the NetworkAgent.unwanted() call should not
trigger a teardown.

Test: atest FrameworksVcnTests
Change-Id: Icf32cb464bce2aae2846448d5a6a53a97f558398
parent f78c3512
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1474,7 +1474,13 @@ public class VcnGatewayConnection extends StateMachine {
                            mVcnContext.getVcnNetworkProvider(),
                            () -> {
                                Slog.d(TAG, "NetworkAgent was unwanted");
                                // If network agent has already been torn down, skip sending the
                                // disconnect. Unwanted() is always called, even when networkAgents
                                // are unregistered in teardownNetwork(), so prevent duplicate
                                // notifications.
                                if (mNetworkAgent != null) {
                                    teardownAsynchronously();
                                }
                            } /* networkUnwantedCallback */,
                            (status) -> {
                                if (status == NetworkAgent.VALIDATION_STATUS_VALID) {
+3 −0
Original line number Diff line number Diff line
@@ -312,6 +312,9 @@ public class VcnGatewayConnectionConnectedStateTest extends VcnGatewayConnection
        verifySafeModeTimeoutNotifiesCallbackAndUnregistersNetworkAgent(
                mGatewayConnection.mConnectedState);

        assertTrue(mGatewayConnection.isInSafeMode());
        assertFalse(mGatewayConnection.isQuitting());

        triggerChildOpened();
        mTestLooper.dispatchAll();