diff options
author | Randy Pan <zpan@google.com> | 2016-06-08 10:01:53 -0700 |
---|---|---|
committer | Randy Pan <zpan@google.com> | 2016-06-08 11:18:49 -0700 |
commit | a68f3e359ac27285b10332ea2461469e5e03bfd4 (patch) | |
tree | 02bf5c2e369e2653a76d1d11443224d360557e65 | |
parent | ad0d0a48952e025838992b6a1b0cd143f1915ced (diff) |
WCM: No connectivity scan if auto roaming is off
When WiFi is already connected, WCM initiates connectivity scan
for roaming only if config 'EnableAutoJoinWhenAssociated" is
turned on. This config option is turned on by default. More
power sensitive devices can turn the config off to save battery.
Note, when this config option is turned off, only the WCM
initiated auto roaming is disabled. Wifi chipset firmware may
still perform a roaming on its own.
Bug: 29157340
Change-Id: I9a8f0df65d39412f242c064db5b3d6654d23634c
Test: Framework Unit Tests and manual tests
-rw-r--r-- | service/java/com/android/server/wifi/WifiConnectivityManager.java | 6 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 25 |
2 files changed, 31 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConnectivityManager.java b/service/java/com/android/server/wifi/WifiConnectivityManager.java index e6d285e96..078d48963 100644 --- a/service/java/com/android/server/wifi/WifiConnectivityManager.java +++ b/service/java/com/android/server/wifi/WifiConnectivityManager.java @@ -761,6 +761,12 @@ public class WifiConnectivityManager { private void startPeriodicScan(boolean scanImmediately) { mPnoScanListener.resetLowRssiNetworkRetryDelay(); + // No connectivity scan if auto roaming is disabled. + if (mWifiState == WIFI_STATE_CONNECTED + && !mConfigManager.getEnableAutoJoinWhenAssociated()) { + return; + } + // Due to b/28020168, timer based single scan will be scheduled // to provide periodic scan in an exponential backoff fashion. if (!ENABLE_BACKGROUND_SCAN) { diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java index 2434c2db7..c0a4a4598 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java @@ -215,6 +215,7 @@ public class WifiConnectivityManagerTest { WifiConfigManager wifiConfigManager = mock(WifiConfigManager.class); when(wifiConfigManager.getWifiConfiguration(anyInt())).thenReturn(null); + when(wifiConfigManager.getEnableAutoJoinWhenAssociated()).thenReturn(true); wifiConfigManager.mThresholdSaturatedRssi24 = new AtomicInteger( WifiQualifiedNetworkSelector.RSSI_SATURATION_2G_BAND); wifiConfigManager.mCurrentNetworkBoost = new AtomicInteger( @@ -321,6 +322,30 @@ public class WifiConnectivityManagerTest { } /** + * Screen turned on while WiFi in connected state but + * auto roaming is disabled. + * + * Expected behavior: WifiConnectivityManager doesn't invoke + * WifiStateMachine.autoConnectToNetwork() because roaming + * is turned off. + */ + @Test + public void turnScreenOnWhenWifiInConnectedStateRoamingDisabled() { + // Set WiFi to connected state + mWifiConnectivityManager.handleConnectionStateChanged( + WifiConnectivityManager.WIFI_STATE_CONNECTED); + + // Turn off auto roaming + when(mWifiConfigManager.getEnableAutoJoinWhenAssociated()).thenReturn(false); + + // Set screen to on + mWifiConnectivityManager.handleScreenStateChanged(true); + + verify(mWifiStateMachine, times(0)).autoConnectToNetwork( + CANDIDATE_NETWORK_ID, CANDIDATE_BSSID); + } + + /** * Multiple back to back connection attempts within the rate interval should be rate limited. * * Expected behavior: WifiConnectivityManager calls WifiStateMachine.autoConnectToNetwork() |