summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/ActiveModeWarden.java11
-rw-r--r--service/res/values/config.xml3
-rw-r--r--service/res/values/overlayable.xml1
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java29
4 files changed, 43 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/ActiveModeWarden.java b/service/java/com/android/server/wifi/ActiveModeWarden.java
index 69f614ee8..19b64b0cb 100644
--- a/service/java/com/android/server/wifi/ActiveModeWarden.java
+++ b/service/java/com/android/server/wifi/ActiveModeWarden.java
@@ -71,6 +71,7 @@ public class ActiveModeWarden {
private final BatteryStatsManager mBatteryStatsManager;
private final ScanRequestProxy mScanRequestProxy;
private final WifiController mWifiController;
+ private final boolean mScanHiddenNetworksScanOnlyMode;
private WifiManager.SoftApCallback mSoftApCallback;
private WifiManager.SoftApCallback mLohsCallback;
@@ -114,6 +115,8 @@ public class ActiveModeWarden {
mBatteryStatsManager = batteryStatsManager;
mScanRequestProxy = wifiInjector.getScanRequestProxy();
mWifiController = new WifiController();
+ mScanHiddenNetworksScanOnlyMode = context.getResources().getBoolean(
+ R.bool.config_wifiScanHiddenNetworksScanOnlyMode);
wifiNative.registerStatusListener(isReady -> {
if (!isReady) {
@@ -468,7 +471,13 @@ public class ActiveModeWarden {
// Update the scan state based on all active mode managers.
private void updateClientScanMode() {
boolean scanEnabled = hasAnyClientModeManager();
- boolean scanningForHiddenNetworksEnabled = hasAnyClientModeManagerInConnectivityRole();
+ boolean scanningForHiddenNetworksEnabled;
+
+ if (mScanHiddenNetworksScanOnlyMode) {
+ scanningForHiddenNetworksEnabled = hasAnyClientModeManager();
+ } else {
+ scanningForHiddenNetworksEnabled = hasAnyClientModeManagerInConnectivityRole();
+ }
mScanRequestProxy.enableScanning(scanEnabled, scanningForHiddenNetworksEnabled);
}
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index eb9928b52..e35fcf074 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -220,4 +220,7 @@
<item>80</item>
<item>160</item>
</integer-array>
+
+ <!-- Indicates that hidden networks are to be scanned during scan only mode -->
+ <bool translatable="false" name="config_wifiScanHiddenNetworksScanOnlyMode">false</bool>
</resources>
diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml
index 8fc141017..8e418e61a 100644
--- a/service/res/values/overlayable.xml
+++ b/service/res/values/overlayable.xml
@@ -80,6 +80,7 @@
<item type="array" name="config_wifiRssiLevelThresholds" />
<item type="array" name="config_wifiDisconnectedScanIntervalScheduleSec" />
<item type="array" name="config_wifiConnectedScanIntervalScheduleSec" />
+ <item type="bool" name="config_wifiScanHiddenNetworksScanOnlyMode" />
<!-- Params from config.xml that can be overlayed -->
<!-- Params from strings.xml that can be overlayed -->
diff --git a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
index 4ec6b8575..e681534ca 100644
--- a/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ActiveModeWardenTest.java
@@ -141,6 +141,8 @@ public class ActiveModeWardenTest extends WifiBaseTest {
.thenReturn("AndroidShare");
when(mResources.getInteger(R.integer.config_wifi_framework_recovery_timeout_delay))
.thenReturn(TEST_WIFI_RECOVERY_DELAY_MS);
+ when(mResources.getBoolean(R.bool.config_wifiScanHiddenNetworksScanOnlyMode))
+ .thenReturn(false);
when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false);
when(mSettingsStore.isAirplaneModeOn()).thenReturn(false);
@@ -449,6 +451,33 @@ public class ActiveModeWardenTest extends WifiBaseTest {
}
/**
+ * Test that ActiveModeWarden enables hidden network scanning in scan-only-mode
+ * if configured to do.
+ */
+ @Test
+ public void testScanOnlyModeScanHiddenNetworks() throws Exception {
+ when(mResources.getBoolean(R.bool.config_wifiScanHiddenNetworksScanOnlyMode))
+ .thenReturn(true);
+
+ mActiveModeWarden = createActiveModeWarden();
+ mActiveModeWarden.start();
+ mLooper.dispatchAll();
+
+ when(mClientModeManager.getRole()).thenReturn(ROLE_CLIENT_SCAN_ONLY);
+ when(mSettingsStore.isScanAlwaysAvailable()).thenReturn(true);
+ when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false);
+ mActiveModeWarden.wifiToggled();
+ mLooper.dispatchAll();
+ mClientListener.onStarted();
+ mLooper.dispatchAll();
+
+ assertInEnabledState();
+ verify(mClientModeManager).start();
+ verify(mClientModeManager).setRole(ROLE_CLIENT_SCAN_ONLY);
+ verify(mScanRequestProxy).enableScanning(true, true);
+ }
+
+ /**
* Test that ActiveModeWarden properly starts the SoftApManager from the
* DisabledState state.
*/