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

Commit 78620247 authored by lucaslin's avatar lucaslin
Browse files

Add NET_CAPABILITY_NOT_VPN when requesting test network

Add NET_CAPABILITY_NOT_VPN can prevent Ikev2VpnNetworkCallback
receiving onAvailable when VPN is connected. Otherwise, the VPN
network will be misused as underlying network to establish VPN
connection again, which is a wrong behavior.

Bug: 228574221
Test: atest CtsNetTestCases:Ikev2VpnTest
Change-Id: Iac85caa0f5bd37a7e79c14fe796737d7b36fa4bd
parent c4227ee2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.Manifest.permission.BIND_VPN_SERVICE;
import static android.Manifest.permission.CONTROL_VPN;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_METERED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VPN;
import static android.net.RouteInfo.RTN_THROW;
import static android.net.RouteInfo.RTN_UNREACHABLE;
import static android.net.VpnManager.NOTIFICATION_CHANNEL_VPN;
@@ -2542,6 +2543,7 @@ public class Vpn {
                req = new NetworkRequest.Builder()
                        .clearCapabilities()
                        .addTransportType(NetworkCapabilities.TRANSPORT_TEST)
                        .addCapability(NET_CAPABILITY_NOT_VPN)
                        .build();
            } else {
                // Basically, the request here is referring to the default request which is defined