Skip to content

Commit 4494c90

Browse files
committed
Handle emergency call back mode correctly
Bug: 5726996 Change-Id: I5815dd402bd73c530b9ba6d545d8956064949aa2
1 parent 641a562 commit 4494c90

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

services/java/com/android/server/WifiService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ public void startWifi() {
840840
* of WifiLock & device idle status unless wifi enabled status is toggled
841841
*/
842842

843-
mWifiStateMachine.setDriverStart(true);
843+
mWifiStateMachine.setDriverStart(true, mEmergencyCallbackMode);
844844
mWifiStateMachine.reconnectCommand();
845845
}
846846

@@ -854,7 +854,7 @@ public void stopWifi() {
854854
* TODO: if a stop is issued, wifi is brought up only by startWifi
855855
* unless wifi enabled status is toggled
856856
*/
857-
mWifiStateMachine.setDriverStart(false);
857+
mWifiStateMachine.setDriverStart(false, mEmergencyCallbackMode);
858858
}
859859

860860

@@ -1074,11 +1074,11 @@ private void updateWifiState() {
10741074
mWifiStateMachine.setWifiEnabled(true);
10751075
mWifiStateMachine.setScanOnlyMode(
10761076
strongestLockMode == WifiManager.WIFI_MODE_SCAN_ONLY);
1077-
mWifiStateMachine.setDriverStart(true);
1077+
mWifiStateMachine.setDriverStart(true, mEmergencyCallbackMode);
10781078
mWifiStateMachine.setHighPerfModeEnabled(strongestLockMode
10791079
== WifiManager.WIFI_MODE_FULL_HIGH_PERF);
10801080
} else {
1081-
mWifiStateMachine.setDriverStart(false);
1081+
mWifiStateMachine.setDriverStart(false, mEmergencyCallbackMode);
10821082
}
10831083
} else {
10841084
mWifiStateMachine.setWifiEnabled(false);

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ public class WifiStateMachine extends StateMachine {
368368
private static final int SUCCESS = 1;
369369
private static final int FAILURE = -1;
370370

371+
/* Phone in emergency call back mode */
372+
private static final int IN_ECM_STATE = 1;
373+
private static final int NOT_IN_ECM_STATE = 0;
374+
371375
/**
372376
* The maximum number of times we will retry a connection to an access point
373377
* for which we have failed in acquiring an IP address from DHCP. A value of
@@ -778,11 +782,11 @@ public DhcpInfo syncGetDhcpInfo() {
778782
/**
779783
* TODO: doc
780784
*/
781-
public void setDriverStart(boolean enable) {
785+
public void setDriverStart(boolean enable, boolean ecm) {
782786
if (enable) {
783787
sendMessage(CMD_START_DRIVER);
784788
} else {
785-
sendMessage(CMD_STOP_DRIVER);
789+
sendMessage(obtainMessage(CMD_STOP_DRIVER, ecm ? IN_ECM_STATE : NOT_IN_ECM_STATE, 0));
786790
}
787791
}
788792

@@ -2576,16 +2580,25 @@ public boolean processMessage(Message message) {
25762580
WifiNative.setBluetoothCoexistenceScanModeCommand(mBluetoothConnectionActive);
25772581
break;
25782582
case CMD_STOP_DRIVER:
2579-
/* Already doing a delayed stop */
2580-
if (mInDelayedStop) {
2583+
int mode = message.arg1;
2584+
2585+
/* Already doing a delayed stop && not in ecm state */
2586+
if (mInDelayedStop && mode != IN_ECM_STATE) {
25812587
if (DBG) log("Already in delayed stop");
25822588
break;
25832589
}
25842590
mInDelayedStop = true;
25852591
mDelayedStopCounter++;
25862592
if (DBG) log("Delayed stop message " + mDelayedStopCounter);
2587-
sendMessageDelayed(obtainMessage(CMD_DELAYED_STOP_DRIVER, mDelayedStopCounter,
2588-
0), DELAYED_DRIVER_STOP_MS);
2593+
2594+
if (mode == IN_ECM_STATE) {
2595+
/* send a shut down immediately */
2596+
sendMessage(obtainMessage(CMD_DELAYED_STOP_DRIVER, mDelayedStopCounter, 0));
2597+
} else {
2598+
/* send regular delayed shut down */
2599+
sendMessageDelayed(obtainMessage(CMD_DELAYED_STOP_DRIVER,
2600+
mDelayedStopCounter, 0), DELAYED_DRIVER_STOP_MS);
2601+
}
25892602
break;
25902603
case CMD_START_DRIVER:
25912604
if (mInDelayedStop) {

0 commit comments

Comments
 (0)