diff options
author | Oscar Shu <xshu@google.com> | 2024-04-11 00:36:03 +0000 |
---|---|---|
committer | Quang Anh Luong <qal@google.com> | 2024-05-01 16:01:56 +0900 |
commit | 021342b4d7789458d0de591cf220e2e0292ee21e (patch) | |
tree | 37aa511d94455b0034cd184c4e8db7ffe0625391 | |
parent | 381fe431cc75fe11462d5b25d0f0867bec621f3c (diff) | |
download | cts-021342b4d7789458d0de591cf220e2e0292ee21e.tar.gz |
[CTS] Restart wifi before disabling always-on scanning
disabling scanning and then restarting wifi causes a race that results
in incorrect worksource being assigned to the entity that starts wifi
due to the inability to figure out when the disable always-on scanning
actually completed.
So reverse the order instead to prevent the race from happening.
Bug: 322134292
Test: atest WifiManagerTest#testStartLocalOnlyHotspotSingleRequestByApps
Change-Id: Ib16cf29031a3043a96b8e1d47f0de7e4f35e8a04
(cherry picked from commit 5838e73b46870d00290bb4b49b5a2127e4ece3ce)
Merged-In: Ib16cf29031a3043a96b8e1d47f0de7e4f35e8a04
-rw-r--r-- | tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java index bed0933d6e3..21e156c8d1a 100644 --- a/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java +++ b/tests/tests/wifi/src/android/net/wifi/cts/WifiManagerTest.java @@ -1171,19 +1171,19 @@ public class WifiManagerTest extends WifiJUnit4TestBase { if (!sWifiManager.isPortableHotspotSupported()) { return; } + boolean wifiEnabled = sWifiManager.isWifiEnabled(); + if (wifiEnabled) { + // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's + // no STA+AP concurrency. + ShellIdentityUtils.invokeWithShellPermissions(() -> + sWifiManager.setWifiEnabled(false)); + PollingCheck.check("Wifi turn off failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, + () -> !sWifiManager.isWifiEnabled()); + SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); + PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, + () -> sWifiManager.isWifiEnabled()); + } runWithScanning(() -> { - boolean wifiEnabled = sWifiManager.isWifiEnabled(); - if (wifiEnabled) { - // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's - // no STA+AP concurrency. - ShellIdentityUtils.invokeWithShellPermissions(() -> - sWifiManager.setWifiEnabled(false)); - PollingCheck.check("Wifi turn off failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, - () -> !sWifiManager.isWifiEnabled()); - SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); - PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, - () -> sWifiManager.isWifiEnabled()); - } TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot(); // add sleep to avoid calling stopLocalOnlyHotspot before TetherController @@ -1956,21 +1956,21 @@ public class WifiManagerTest extends WifiJUnit4TestBase { // check that softap mode is supported by the device assumeTrue(sWifiManager.isPortableHotspotSupported()); + boolean wifiEnabled = sWifiManager.isWifiEnabled(); + if (wifiEnabled) { + // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's + // no STA+AP concurrency. + ShellIdentityUtils.invokeWithShellPermissions(() -> + sWifiManager.setWifiEnabled(false)); + PollingCheck.check("Wifi turn off failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, + () -> !sWifiManager.isWifiEnabled()); + SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); + PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, + () -> sWifiManager.isWifiEnabled()); + } + runWithScanning(() -> { boolean caughtException = false; - boolean wifiEnabled = sWifiManager.isWifiEnabled(); - if (wifiEnabled) { - // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's - // no STA+AP concurrency. - ShellIdentityUtils.invokeWithShellPermissions(() -> - sWifiManager.setWifiEnabled(false)); - PollingCheck.check("Wifi turn off failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, - () -> !sWifiManager.isWifiEnabled()); - SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); - PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, - () -> sWifiManager.isWifiEnabled()); - } - TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot(); // now make a second request - this should fail. @@ -3707,15 +3707,15 @@ public class WifiManagerTest extends WifiJUnit4TestBase { // check that softap mode is supported by the device assumeTrue(sWifiManager.isPortableHotspotSupported()); - runWithScanning(() -> { - // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's no - // STA+AP concurrency. - ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(false)); - PollingCheck.check("Wifi turn off failed!", 2_000, () -> !sWifiManager.isWifiEnabled()); - SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); - PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, - () -> sWifiManager.isWifiEnabled()); + // Re-enabled Wi-Fi as shell for HalDeviceManager legacy LOHS behavior when there's no + // STA+AP concurrency. + ShellIdentityUtils.invokeWithShellPermissions(() -> sWifiManager.setWifiEnabled(false)); + PollingCheck.check("Wifi turn off failed!", 2_000, () -> !sWifiManager.isWifiEnabled()); + SystemUtil.runShellCommand("cmd wifi set-wifi-enabled enabled"); + PollingCheck.check("Wifi turn on failed!", WIFI_OFF_ON_TIMEOUT_MILLIS, + () -> sWifiManager.isWifiEnabled()); + runWithScanning(() -> { boolean isStaApConcurrencySupported = sWifiManager.isStaApConcurrencySupported(); // start local only hotspot. TestLocalOnlyHotspotCallback callback = startLocalOnlyHotspot(); |