Merge "All upstream mobile connection management is now in UpstreamNetworkMonitor"

This commit is contained in:
Treehugger Robot
2017-01-24 07:54:20 +00:00
committed by Gerrit Code Review

View File

@@ -975,8 +975,6 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
private final ArrayList<TetherInterfaceStateMachine> mNotifyList; private final ArrayList<TetherInterfaceStateMachine> mNotifyList;
private final IPv6TetheringCoordinator mIPv6TetheringCoordinator; private final IPv6TetheringCoordinator mIPv6TetheringCoordinator;
private int mPreviousMobileType = ConnectivityManager.TYPE_NONE;
private static final int UPSTREAM_SETTLE_TIME_MS = 10000; private static final int UPSTREAM_SETTLE_TIME_MS = 10000;
TetherMasterSM(String name, Looper looper) { TetherMasterSM(String name, Looper looper) {
@@ -1010,43 +1008,14 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
return false; return false;
} }
protected boolean requestUpstreamMobileConnection(int apnType) { protected boolean requestUpstreamMobileConnection() {
if (apnType == ConnectivityManager.TYPE_NONE) { return false; } mUpstreamNetworkMonitor.updateMobileRequiresDun(mConfig.isDunRequired);
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);
mUpstreamNetworkMonitor.registerMobileNetworkRequest(); mUpstreamNetworkMonitor.registerMobileNetworkRequest();
return true; return true;
} }
protected void unrequestUpstreamMobileConnection() { protected void unrequestUpstreamMobileConnection() {
mUpstreamNetworkMonitor.releaseMobileNetworkRequest(); mUpstreamNetworkMonitor.releaseMobileNetworkRequest();
mPreviousMobileType = ConnectivityManager.TYPE_NONE;
} }
protected boolean turnOnMasterTetherSettings() { protected boolean turnOnMasterTetherSettings() {
@@ -1128,11 +1097,10 @@ public class Tethering extends BaseNetworkObserver implements IControlsTethering
case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_DUN:
case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_HIPRI:
// If we're on DUN, put our own grab on it. // If we're on DUN, put our own grab on it.
requestUpstreamMobileConnection(upType); requestUpstreamMobileConnection();
break; break;
case ConnectivityManager.TYPE_NONE: case ConnectivityManager.TYPE_NONE:
if (tryCell && if (tryCell && requestUpstreamMobileConnection()) {
requestUpstreamMobileConnection(preferredUpstreamMobileApn)) {
// We think mobile should be coming up; don't set a retry. // We think mobile should be coming up; don't set a retry.
} else { } else {
sendMessageDelayed(CMD_RETRY_UPSTREAM, UPSTREAM_SETTLE_TIME_MS); sendMessageDelayed(CMD_RETRY_UPSTREAM, UPSTREAM_SETTLE_TIME_MS);