diff options
| -rw-r--r-- | core/java/android/net/InterfaceConfiguration.java | 8 | ||||
| -rw-r--r-- | services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java | 13 |
2 files changed, 18 insertions, 3 deletions
diff --git a/core/java/android/net/InterfaceConfiguration.java b/core/java/android/net/InterfaceConfiguration.java index 8cdd15305018..ea53a71245a5 100644 --- a/core/java/android/net/InterfaceConfiguration.java +++ b/core/java/android/net/InterfaceConfiguration.java @@ -80,6 +80,14 @@ public class InterfaceConfiguration implements Parcelable { mFlags.add(FLAG_DOWN); } + /** + * Set flags so that no changes will be made to the up/down status. + */ + public void ignoreInterfaceUpDownStatus() { + mFlags.remove(FLAG_UP); + mFlags.remove(FLAG_DOWN); + } + public LinkAddress getLinkAddress() { return mAddr; } 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 50bb022ef3f0..76ad9d75bb2d 100644 --- a/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java +++ b/services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java @@ -136,10 +136,17 @@ public class TetherInterfaceStateMachine extends StateMachine { if (ifcg != null) { InetAddress addr = NetworkUtils.numericToInetAddress(ipAsString); ifcg.setLinkAddress(new LinkAddress(addr, prefixLen)); - if (enabled) { - ifcg.setInterfaceUp(); + if (mInterfaceType == ConnectivityManager.TETHERING_WIFI) { + // The WiFi stack has ownership of the interface up/down state. + // It is unclear whether the bluetooth or USB stacks will manage their own + // state. + ifcg.ignoreInterfaceUpDownStatus(); } else { - ifcg.setInterfaceDown(); + if (enabled) { + ifcg.setInterfaceUp(); + } else { + ifcg.setInterfaceDown(); + } } ifcg.clearFlag("running"); mNMService.setInterfaceConfig(mIfaceName, ifcg); |