From 56379d23971baafa0e6987fe2b18d7a1ffea439d Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Tue, 4 Oct 2011 16:45:22 -0700 Subject: [PATCH] Handle unexpected interface up/down events WEXT on crespo has an issue where the interface up/down events can happen in an unexpected fashion. At a driver start, we can go from interface disabled to interface enabled, back to interface disabled and then eventually into an interface enabled state. Earlier, we were just expecting a single interface enable event that would trigger driver specific commands. Now, we just handle these events as individual driver stop and driver start situations so that we do appropriate things eventually Bug: 5239853 Change-Id: I6bd5d844edf9fadfdca4e8eb753c2ba738aa6ad5 --- .../android/net/wifi/WifiStateMachine.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 5ca7aff4d773e..1e45f684d459a 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -2597,6 +2597,15 @@ public class WifiStateMachine extends StateMachine { public boolean processMessage(Message message) { if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { + case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: + StateChangeResult stateChangeResult = (StateChangeResult) message.obj; + SupplicantState state = stateChangeResult.state; + // A WEXT bug means that we can be back to driver started state + // unexpectedly + if (SupplicantState.isDriverActive(state)) { + transitionTo(mDriverStartedState); + } + break; case CMD_START_DRIVER: mWakeLock.acquire(); WifiNative.startDriverCommand(); @@ -2667,8 +2676,18 @@ public class WifiStateMachine extends StateMachine { sendErrorBroadcast(WifiManager.WPS_OVERLAP_ERROR); break; case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: - handleSupplicantStateChange(message); - break; + SupplicantState state = handleSupplicantStateChange(message); + // Due to a WEXT bug, during the time of driver start/stop + // we can go into a driver stopped state in an unexpected way. + // The sequence eventually puts interface + // up and we should be back to a connected state + if (!SupplicantState.isDriverActive(state)) { + if (mNetworkInfo.getState() != NetworkInfo.State.DISCONNECTED) { + handleNetworkDisconnect(); + } + transitionTo(mDriverStoppedState); + } + break; /* Do a redundant disconnect without transition */ case CMD_DISCONNECT: WifiNative.disconnectCommand();