Skip to content

Commit 284ccdc

Browse files
isheriffAndroid Git Automerger
authored andcommitted
am 3b6377b: Merge "Add supplication shut down recovery" into ics-factoryrom
* commit '3b6377b120bb507f93a8f1e7e25bc026de764dd6': Add supplication shut down recovery
2 parents f2ff20e + 3b6377b commit 284ccdc

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

wifi/java/android/net/wifi/WifiStateMachine.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ public class WifiStateMachine extends StateMachine {
154154
private static final int SUPPLICANT_RESTART_TRIES = 5;
155155

156156
private int mSupplicantRestartCount = 0;
157+
/* Tracks sequence number on stop failure message */
158+
private int mSupplicantStopFailureToken = 0;
157159

158160
private LinkProperties mLinkProperties;
159161

@@ -216,6 +218,8 @@ public class WifiStateMachine extends StateMachine {
216218
static final int CMD_STATIC_IP_SUCCESS = BASE + 15;
217219
/* Indicates Static IP failed */
218220
static final int CMD_STATIC_IP_FAILURE = BASE + 16;
221+
/* Indicates supplicant stop failed */
222+
static final int CMD_STOP_SUPPLICANT_FAILED = BASE + 17;
219223

220224
/* Start the soft access point */
221225
static final int CMD_START_AP = BASE + 21;
@@ -1735,6 +1739,7 @@ public boolean processMessage(Message message) {
17351739
case CMD_UNLOAD_DRIVER:
17361740
case CMD_START_SUPPLICANT:
17371741
case CMD_STOP_SUPPLICANT:
1742+
case CMD_STOP_SUPPLICANT_FAILED:
17381743
case CMD_START_DRIVER:
17391744
case CMD_STOP_DRIVER:
17401745
case CMD_START_AP:
@@ -2263,9 +2268,13 @@ public void enter() {
22632268
EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName());
22642269
Log.d(TAG, "stopping supplicant");
22652270
if (!WifiNative.stopSupplicant()) {
2266-
Log.e(TAG, "Failed to stop supplicant, issue kill");
2267-
WifiNative.killSupplicant();
2271+
Log.e(TAG, "Failed to stop supplicant");
22682272
}
2273+
2274+
/* Send ourselves a delayed message to indicate failure after a wait time */
2275+
sendMessageDelayed(obtainMessage(CMD_STOP_SUPPLICANT_FAILED,
2276+
++mSupplicantStopFailureToken, 0), SUPPLICANT_RESTART_INTERVAL_MSECS);
2277+
22692278
mNetworkInfo.setIsAvailable(false);
22702279
handleNetworkDisconnect();
22712280
setWifiState(WIFI_STATE_DISABLING);
@@ -2282,9 +2291,21 @@ public boolean processMessage(Message message) {
22822291
break;
22832292
case WifiMonitor.SUP_DISCONNECTION_EVENT:
22842293
Log.d(TAG, "Supplicant connection lost");
2294+
/* Socket connection can be lost when we do a graceful shutdown
2295+
* or when the driver is hung. Ensure supplicant is stopped here.
2296+
*/
2297+
WifiNative.killSupplicant();
22852298
WifiNative.closeSupplicantConnection();
22862299
transitionTo(mDriverLoadedState);
22872300
break;
2301+
case CMD_STOP_SUPPLICANT_FAILED:
2302+
if (message.arg1 == mSupplicantStopFailureToken) {
2303+
Log.e(TAG, "Timed out on a supplicant stop, kill and proceed");
2304+
WifiNative.killSupplicant();
2305+
WifiNative.closeSupplicantConnection();
2306+
transitionTo(mDriverLoadedState);
2307+
}
2308+
break;
22882309
case CMD_LOAD_DRIVER:
22892310
case CMD_UNLOAD_DRIVER:
22902311
case CMD_START_SUPPLICANT:

0 commit comments

Comments
 (0)