From 3d4941b9c2554813c4c4e3c4433734958820ab28 Mon Sep 17 00:00:00 2001 From: lucaslin Date: Fri, 13 Nov 2020 14:58:05 +0800 Subject: [PATCH] Define and use default request in Ikev2VpnRunner Vpn might be included in ConnectivityService mainline module, so it should prevent calling @hide API. Even if Vpn isn't included in ConnectivityService mainline module eventually, it's still fine to use local defined default request instead of calling @hide API. Ideally, ConnectivityManager will provide a new API which can provide the status of physical network even though there is a virtual network. b/147280869 is used for tracking the new API. Bug: 172183305 Test: atest FrameworksNetTests Test: atest CtsNetTestCasesLatestSdk Test: Manual setup IKEV2 VPN connection. Change-Id: If76e7497bef4890a74641695c3ebd395795bbe7f --- .../core/java/com/android/server/connectivity/Vpn.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java index 2c29106c5cd38..e748fa0eff4fc 100644 --- a/services/core/java/com/android/server/connectivity/Vpn.java +++ b/services/core/java/com/android/server/connectivity/Vpn.java @@ -2407,7 +2407,14 @@ public class Vpn { .addTransportType(NetworkCapabilities.TRANSPORT_TEST) .build(); } else { - req = cm.getDefaultRequest(); + // Basically, the request here is referring to the default request which is defined + // in ConnectivityService. Ideally, ConnectivityManager should provide an new API + // which can provide the status of physical network even though there is a virtual + // network. b/147280869 is used for tracking the new API. + // TODO: Use the new API to register default physical network. + req = new NetworkRequest.Builder() + .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + .build(); } cm.requestNetwork(req, mNetworkCallback);