summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/connectivity/Vpn.java17
1 files changed, 5 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/connectivity/Vpn.java b/services/core/java/com/android/server/connectivity/Vpn.java
index 431be88bd892..676dc196f20c 100644
--- a/services/core/java/com/android/server/connectivity/Vpn.java
+++ b/services/core/java/com/android/server/connectivity/Vpn.java
@@ -99,6 +99,7 @@ import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.FileUtils;
+import android.os.Handler;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.Looper;
@@ -2784,26 +2785,18 @@ public class Vpn {
// When restricted to test networks, select any network with TRANSPORT_TEST. Since the
// creator of the profile and the test network creator both have MANAGE_TEST_NETWORKS,
// this is considered safe.
- final NetworkRequest req;
if (mProfile.isRestrictedToTestNetworks()) {
- req = new NetworkRequest.Builder()
+ final NetworkRequest req = new NetworkRequest.Builder()
.clearCapabilities()
.addTransportType(NetworkCapabilities.TRANSPORT_TEST)
.addCapability(NET_CAPABILITY_NOT_VPN)
.build();
+ mConnectivityManager.requestNetwork(req, mNetworkCallback);
} else {
- // 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();
+ mConnectivityManager.registerSystemDefaultNetworkCallback(mNetworkCallback,
+ new Handler(mLooper));
}
-
- mConnectivityManager.requestNetwork(req, mNetworkCallback);
}
private boolean isActiveNetwork(@Nullable Network network) {