From 5645af4e2ab80180012e421b4fbf1f352d45ce3e Mon Sep 17 00:00:00 2001 From: Erik Kline Date: Mon, 23 Jan 2017 16:42:01 +0900 Subject: [PATCH] All upstream mobile connection management is now in UpstreamNetworkMonitor Test: as follows - built (bullhead) - flashed - booted - runtest frameworks-net passes Bug: 32163131 Change-Id: Ifbd430d5bf2d2191469c9810ad8f073506abde46 --- .../server/connectivity/Tethering.java | 40 ++----------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java index e84bf40b344ed..b0e45097aff69 100644 --- a/services/core/java/com/android/server/connectivity/Tethering.java +++ b/services/core/java/com/android/server/connectivity/Tethering.java @@ -975,8 +975,6 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering private final ArrayList mNotifyList; private final IPv6TetheringCoordinator mIPv6TetheringCoordinator; - private int mPreviousMobileType = ConnectivityManager.TYPE_NONE; - private static final int UPSTREAM_SETTLE_TIME_MS = 10000; TetherMasterSM(String name, Looper looper) { @@ -1010,43 +1008,14 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering return false; } - protected boolean requestUpstreamMobileConnection(int apnType) { - if (apnType == ConnectivityManager.TYPE_NONE) { return false; } - - if (apnType != mPreviousMobileType) { - // Unregister any previous mobile upstream callback because - // this request, if any, will be different. - unrequestUpstreamMobileConnection(); - } - - if (mUpstreamNetworkMonitor.mobileNetworkRequested()) { - // Looks like we already filed a request for this apnType. - return true; - } - - switch (apnType) { - case ConnectivityManager.TYPE_MOBILE_DUN: - case ConnectivityManager.TYPE_MOBILE: - case ConnectivityManager.TYPE_MOBILE_HIPRI: - mPreviousMobileType = apnType; - break; - default: - return false; - } - - // TODO: Replace this with a call to pass the current tethering - // configuration to mUpstreamNetworkMonitor and let it handle - // choosing APN type accordingly. - mUpstreamNetworkMonitor.updateMobileRequiresDun( - apnType == ConnectivityManager.TYPE_MOBILE_DUN); - + protected boolean requestUpstreamMobileConnection() { + mUpstreamNetworkMonitor.updateMobileRequiresDun(mConfig.isDunRequired); mUpstreamNetworkMonitor.registerMobileNetworkRequest(); return true; } protected void unrequestUpstreamMobileConnection() { mUpstreamNetworkMonitor.releaseMobileNetworkRequest(); - mPreviousMobileType = ConnectivityManager.TYPE_NONE; } protected boolean turnOnMasterTetherSettings() { @@ -1128,11 +1097,10 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: // If we're on DUN, put our own grab on it. - requestUpstreamMobileConnection(upType); + requestUpstreamMobileConnection(); break; case ConnectivityManager.TYPE_NONE: - if (tryCell && - requestUpstreamMobileConnection(preferredUpstreamMobileApn)) { + if (tryCell && requestUpstreamMobileConnection()) { // We think mobile should be coming up; don't set a retry. } else { sendMessageDelayed(CMD_RETRY_UPSTREAM, UPSTREAM_SETTLE_TIME_MS);