diff options
author | Ningyuan Wang <nywang@google.com> | 2017-09-18 13:33:36 -0700 |
---|---|---|
committer | Ningyuan Wang <nywang@google.com> | 2017-10-04 18:07:05 -0700 |
commit | 98842059a66adb61a1f27fd56d92c80a77066e83 (patch) | |
tree | cf1f68e03b1288c42334d857a7f7be41610bfb07 /service | |
parent | 470817b13e56d915805729ab4f51075f3fa2ec15 (diff) |
Do not trigger scan for reconnect() when wifi is connected
According to the document of WifiManager.reconnect(), we only
try to connect when wifi is disconnected.
This CL adds the handling of CMD_RECONNECT in WifiStateMachine
for L2ConnectedState to avoid unnecessary scans and connection
attempts.
This also adds the handling of CMD_RECONNECT for WpsRunningState,
which just logs and ignores this command because in WpsRunningSate
we are attempting to connect and when we leave and head to disconnected
state, we will trigger a scan anyway.
Bug: 65839442
Test: compile, unit tests
Test:
1. Write a simple cts test case WifiManagerTest#testWifiReconnect
only calling WifiManager.reconnect()
2. Make sure wifi is connected
3. Run cts test using:
cts-tradefed run cts -m CtsNetTestCases -t
android.net.wifi.cts.WifiManagerTest#testWifiReconnect
4. Grab bugreport
5. Verify the following log appears:
"Ignore CMD_RECONNECT request because wifi is already connected"
Change-Id: I7aa7842653aa4eaf8d70946dc8e120d3814ffc09
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index d6723cac3..1f6cada74 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -5995,6 +5995,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss case CMD_STOP_RSSI_MONITORING_OFFLOAD: stopRssiMonitoringOffload(); break; + case CMD_RECONNECT: + log(" Ignore CMD_RECONNECT request because wifi is already connected"); + break; case CMD_RESET_SIM_NETWORKS: if (message.arg1 == 0 // sim was removed && mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID) { @@ -6847,6 +6850,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss case WifiManager.CONNECT_NETWORK: case CMD_ENABLE_NETWORK: case CMD_RECONNECT: + log(" Ignore CMD_RECONNECT request because wps is running"); + return HANDLED; case CMD_REASSOCIATE: deferMessage(message); break; |