From 359d4c6d610a91f976b015c9657e7d7b10ac10b0 Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Thu, 14 Jun 2018 17:36:40 +0900 Subject: [PATCH] Prefer default Internet network for upstream tethering. Rather than use the crufty config.xml list of upstream transport types, use ConnectivityService's notion of the default network for the upstream. In cases where a DUN network is required and the default network is currently a mobile network, look for a DUN network (code in Tethering is currently responsible for requesting one). Test: as follows - built, flashed, booted - runtest frameworks-net - tethered via mobile, joined captive portal network, maintained laptop access via mobile until captive passed (then used wifi) - disabled client mode wifi, disabled mobile data, plugged in ethernet adapter, observed connectivity via ethernet Bug: 32163131 Bug: 62648872 Bug: 63282480 Bug: 109786760 Bug: 110118584 Bug: 110260419 Change-Id: I925b75994e31df8046f3ef9916a2457b4210485e --- .../core/java/com/android/server/ConnectivityService.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index c995c1e90f..18b695f36b 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -925,6 +925,10 @@ public class ConnectivityService extends IConnectivityManager.Stub public boolean isTetheringSupported() { return ConnectivityService.this.isTetheringSupported(); } + @Override + public NetworkRequest getDefaultNetworkRequest() { + return mDefaultRequest; + } }; return new Tethering(mContext, mNetd, mStatsService, mPolicyManager, IoThread.get().getLooper(), new MockableSystemProperties(), @@ -942,7 +946,7 @@ public class ConnectivityService extends IConnectivityManager.Stub private NetworkRequest createDefaultInternetRequestForTransport( int transportType, NetworkRequest.Type type) { - NetworkCapabilities netCap = new NetworkCapabilities(); + final NetworkCapabilities netCap = new NetworkCapabilities(); netCap.addCapability(NET_CAPABILITY_INTERNET); netCap.addCapability(NET_CAPABILITY_NOT_RESTRICTED); if (transportType > -1) {