From b140cbe7bbffecb8e080697ba5cce9b1db730294 Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Thu, 14 Jun 2018 17:36:40 +0900 Subject: [PATCH 1/2] 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) { From 41214dba83c40688b670e44af391f70909af5896 Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Tue, 26 Jun 2018 18:53:43 +0900 Subject: [PATCH 2/2] Push DNS configuration on network validation Test: as follows - built, flashed, booted - runtest frameworks-net passes - connected to captive portal network, saw failed validation attempt (opportunistic), passed portal, saw successful revalidation attempt Bug: 64133961 Bug: 72344805 Bug: 109928338 Merged-In: Ic2046e053faf58e2edf2824e01145c61a9f2991f Merged-In: I209c38fab7f05909e61731a348b1b1a2b35feab2 Change-Id: I0471685c2234af8a8c7f5b2ad3205eb6e36333c5 --- .../java/com/android/server/ConnectivityService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 18b695f36b..6ef1c1421b 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -2254,6 +2254,7 @@ public class ConnectivityService extends IConnectivityManager.Stub updateCapabilities(oldScore, nai, nai.networkCapabilities); // If score has changed, rebroadcast to NetworkFactories. b/17726566 if (oldScore != nai.getCurrentScore()) sendUpdatedScoreToFactories(nai); + if (valid) handleFreshlyValidatedNetwork(nai); } updateInetCondition(nai); // Let the NetworkAgent know the state of its network @@ -2348,6 +2349,16 @@ public class ConnectivityService extends IConnectivityManager.Stub mDefaultRequest.networkCapabilities, nai.networkCapabilities); } + private void handleFreshlyValidatedNetwork(NetworkAgentInfo nai) { + if (nai == null) return; + // If the Private DNS mode is opportunistic, reprogram the DNS servers + // in order to restart a validation pass from within netd. + final PrivateDnsConfig cfg = mDnsManager.getPrivateDnsConfig(); + if (cfg.useTls && TextUtils.isEmpty(cfg.hostname)) { + updateDnses(nai.linkProperties, null, nai.network.netId); + } + } + private void handlePrivateDnsSettingsChanged() { final PrivateDnsConfig cfg = mDnsManager.getPrivateDnsConfig();