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

Commit 65d44b93 authored by lucaslin's avatar lucaslin Committed by Cherrypicker Worker
Browse files

Clear mInterface before calling resetIkeState()

Clear mInterface before calling resetIkeState() in
onDefaultNetworkChanged().
resetIkeState() will trigger interfaceRemoved() to be called.
If mInterface is set, interfaceRemoved() will clear
Ikev2VpnRunner which makes VPN disconnect.

This issue can be reproduced when device establishes VPN
connection with mobile data first then connects to wifi.
In this case, onLost() for mobile data will not be called
because there is a new network(wifi) can satisfy the request,
so only onAvailable() for wifi will be called.
Which means onSessionLost() will not be called and only
onDefaultNetworkChanged() will be called, which makes that
mInterface is not cleared before interfaceRemoved() is called.

Bug: 219546241
Test: Check if VPN is still there when establishing VPN with
      mobile data first, then connect to wifi and disconnect
      wifi.
Change-Id: I7f9a1d9afd2a40762e9fac68edf1fb8ae75df8bc
(cherry picked from commit 520cc2fd)
Merged-In: I7f9a1d9afd2a40762e9fac68edf1fb8ae75df8bc
parent 938c647b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2388,6 +2388,9 @@ public class Vpn {
                        return; // VPN has been shut down.
                    }

                    // Clear mInterface to prevent Ikev2VpnRunner being cleared when
                    // interfaceRemoved() is called.
                    mInterface = null;
                    // Without MOBIKE, we have no way to seamlessly migrate. Close on old
                    // (non-default) network, and start the new one.
                    resetIkeState();