diff options
author | Roshan Pius <rpius@google.com> | 2018-04-26 13:33:00 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2018-04-26 16:57:13 -0700 |
commit | 72024817b555c872ef21cfbcca3b33851a406d29 (patch) | |
tree | 274d4b29040b790ecb48a4e43de4de9bec9f6f29 /service | |
parent | a0daf40587b185e4f65549964c465ba7489ad753 (diff) |
WifiScanningServiceImpl: Ignore duplicate scan available
Receiving duplicate SCAN_AVAILABLE broadcast currently puts WifiScanner
in a weird state. This is what happens:
a) WifiBackgroundScanStateMachine is already in StartedState.
b) WifiBackgroundScanStateMachine receives another CMD_DRIVER_LOADED
message.
c) CMD_DRIVER_LOADED is handled in the DefaultState which creates a new
mScannerImpl instance.
d) Handling of CMD_DRIVER_LOADED also asks the
WifiBackgroundScanStateMachine to transition to StartedState.
e) This causes WifiBackgroundScanStateMachine to transition out of
StartedState and back into StartedState.
(This transition to the same state should probably have been ignored
by the base StateMachine class)
f) In the above transition, exit() of StartedState invokes
mScannerImpl.cleanup().
So, we end up with a new mScannerImpl instance on which we invoked
mScannerImpl.cleanup() and hence no more scans work.
Note: We may still need to debug why WSM is sending out back to back
scan available notification. But, we should fix the handling in
WifiScanner regardless.
Bug: 78549365
Test: Unit tests
Test: Ran WifiManager ACTS tests locally
Test: Toggled wifi a bunch of times and ensured scanning still works.
Change-Id: I2cf606ecf2d2d261d3354be30135c4ec93f278ff
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java index b64d364cf..efeafc7bd 100644 --- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java +++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java @@ -431,7 +431,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { /** * State machine that holds the state of single scans. Scans should only be active in the - * ScanningState. The pending scans and active scans maps are swaped when entering + * ScanningState. The pending scans and active scans maps are swapped when entering * ScanningState. Any requests queued while scanning will be placed in the pending queue and * executed after transitioning back to IdleState. */ @@ -576,7 +576,7 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { /** * State representing when the driver is running. This state is not meant to be transitioned - * directly, but is instead indented as a parent state of ScanningState and IdleState + * directly, but is instead intended as a parent state of ScanningState and IdleState * to hold common functionality and handle cleaning up scans when the driver is shut down. */ class DriverStartedState extends State { @@ -597,6 +597,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { ClientInfo ci = mClients.get(msg.replyTo); switch (msg.what) { + case CMD_DRIVER_LOADED: + // Ignore if we're already in driver loaded state. + return HANDLED; case WifiScanner.CMD_START_SINGLE_SCAN: mWifiMetrics.incrementOneshotScanCount(); int handler = msg.arg2; @@ -1151,7 +1154,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { switch (msg.what) { case CMD_DRIVER_LOADED: - return NOT_HANDLED; + Log.e(TAG, "wifi driver loaded received while already loaded"); + // Ignore if we're already in driver loaded state. + return HANDLED; case CMD_DRIVER_UNLOADED: return NOT_HANDLED; case WifiScanner.CMD_START_BACKGROUND_SCAN: { @@ -1530,6 +1535,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub { public boolean processMessage(Message msg) { ClientInfo ci = mClients.get(msg.replyTo); switch (msg.what) { + case CMD_DRIVER_LOADED: + // Ignore if we're already in driver loaded state. + return HANDLED; case WifiScanner.CMD_START_PNO_SCAN: Bundle pnoParams = (Bundle) msg.obj; if (pnoParams == null) { |