diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-07-24 14:28:15 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-07-24 14:35:03 -0700 |
commit | e8daf2a7000e12dc0d62cb98b06ca849cf40564a (patch) | |
tree | 0c53c146388a59d4cbd0efa6b844956fd741256a | |
parent | 508e86e7577fabf528afe06ecc098f8e677ff48c (diff) | |
download | frameworks_base-e8daf2a7000e12dc0d62cb98b06ca849cf40564a.zip frameworks_base-e8daf2a7000e12dc0d62cb98b06ca849cf40564a.tar.gz frameworks_base-e8daf2a7000e12dc0d62cb98b06ca849cf40564a.tar.bz2 |
Fix interface notification race
In one use case, I see that if we go straight from
wifi client mode to tethering operation, the interface change notifications
are reported in an order that causes to enter tethered state
without actually tethering through connectivity service.
It is because an interface down notification (from wifi going down) comes after
we have started soft ap and we think we have tethered after calling startTethering
and switch to Tethered state
Instead, we should make sure tethering has started before going to Tethered state.
Change-Id: Iba7e8fab0feeb5637d40938862a8638871df8b02
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 1e3afbd..98f47f2 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -1055,7 +1055,7 @@ public class WifiStateMachine extends StateMachine { } } - private void startTethering(ArrayList<String> available) { + private boolean startTethering(ArrayList<String> available) { boolean wifiAvailable = false; @@ -1081,18 +1081,20 @@ public class WifiStateMachine extends StateMachine { } catch (Exception e) { Log.e(TAG, "Error configuring interface " + intf + ", :" + e); setWifiApEnabled(null, false); - return; + return false; } if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { Log.e(TAG, "Error tethering on " + intf); setWifiApEnabled(null, false); - return; + return false; } - break; + return true; } } } + // We found no interfaces to tether + return false; } private void stopTethering() { @@ -3163,8 +3165,9 @@ public class WifiStateMachine extends StateMachine { break; case CMD_TETHER_INTERFACE: ArrayList<String> available = (ArrayList<String>) message.obj; - startTethering(available); - transitionTo(mTetheredState); + if (startTethering(available)) { + transitionTo(mTetheredState); + } break; default: return NOT_HANDLED; |