summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/connectivity/Tethering.java35
-rw-r--r--services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java2
2 files changed, 25 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/connectivity/Tethering.java b/services/core/java/com/android/server/connectivity/Tethering.java
index 606f68bfaa5b..24f3cde61f31 100644
--- a/services/core/java/com/android/server/connectivity/Tethering.java
+++ b/services/core/java/com/android/server/connectivity/Tethering.java
@@ -815,30 +815,41 @@ public class Tethering extends BaseNetworkObserver {
case WifiManager.WIFI_AP_STATE_DISABLING:
case WifiManager.WIFI_AP_STATE_FAILED:
default:
- disableWifiIpServingLocked(curState);
+ disableWifiIpServingLocked(ifname, curState);
break;
}
}
}
}
- // TODO: Pass in the interface name and, if non-empty, only turn down IP
- // serving on that one interface.
- private void disableWifiIpServingLocked(int apState) {
- if (DBG) Log.d(TAG, "Canceling WiFi tethering request - AP_STATE=" + apState);
+ private void disableWifiIpServingLocked(String ifname, int apState) {
+ mLog.log("Canceling WiFi tethering request - AP_STATE=" + apState);
+
+ // Regardless of whether we requested this transition, the AP has gone
+ // down. Don't try to tether again unless we're requested to do so.
+ // TODO: Remove this altogether, once Wi-Fi reliably gives us an
+ // interface name with every broadcast.
+ mWifiTetherRequested = false;
+
+ if (!TextUtils.isEmpty(ifname)) {
+ final TetherState ts = mTetherStates.get(ifname);
+ if (ts != null) {
+ ts.stateMachine.unwanted();
+ return;
+ }
+ }
- // Tell appropriate interface state machines that they should tear
- // themselves down.
for (int i = 0; i < mTetherStates.size(); i++) {
TetherInterfaceStateMachine tism = mTetherStates.valueAt(i).stateMachine;
if (tism.interfaceType() == ConnectivityManager.TETHERING_WIFI) {
- tism.sendMessage(TetherInterfaceStateMachine.CMD_TETHER_UNREQUESTED);
- break; // There should be at most one of these.
+ tism.unwanted();
+ return;
}
}
- // Regardless of whether we requested this transition, the AP has gone
- // down. Don't try to tether again unless we're requested to do so.
- mWifiTetherRequested = false;
+
+ mLog.log("Error disabling Wi-Fi IP serving; " +
+ (TextUtils.isEmpty(ifname) ? "no interface name specified"
+ : "specified interface: " + ifname));
}
private void enableWifiIpServingLocked(String ifname, int wifiIpMode) {
diff --git a/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java b/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
index 82b9ca07bbc0..9eb342cf5b5f 100644
--- a/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
+++ b/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
@@ -132,6 +132,8 @@ public class TetherInterfaceStateMachine extends StateMachine {
public void stop() { sendMessage(CMD_INTERFACE_DOWN); }
+ public void unwanted() { sendMessage(CMD_TETHER_UNREQUESTED); }
+
// configured when we start tethering and unconfig'd on error or conclusion
private boolean configureIfaceIp(boolean enabled) {
if (VDBG) Log.d(TAG, "configureIfaceIp(" + enabled + ")");