From b4310e6934936616eceaa9501f2f93b8726ac78d Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 20 Apr 2023 08:16:36 +0000 Subject: [PATCH] Prevent hotspot from being affected by the wifi retention feature To prevent WiFi-to-WiFi interruption while entering APM: - If WiFi is retained while entering APM, hotspot will also remain enabled. - If WiFi is off before APM or disabled while entering APM, hotspot will be disabled. To make sure hotspot always be disabled while entering APM, disable wifi before enable hotspot. Bug: 278150162 Test: 1. turn on wifi while airplan mode on, then turn off airplan mode 2. atest ConnectivityManagerTest#testFactoryReset (cherry picked from https://android-review.googlesource.com/q/commit:8f49a826ad4a0ff1ae57c394eeb89e086d09b4aa) Merged-In: Ic48ba63deab02683280543516228104be928a6a2 Change-Id: Ic48ba63deab02683280543516228104be928a6a2 --- .../net/src/android/net/cts/ConnectivityManagerTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java index 9d234d31e1..a14714765f 100644 --- a/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java +++ b/tests/cts/net/src/android/net/cts/ConnectivityManagerTest.java @@ -2552,6 +2552,14 @@ public class ConnectivityManagerTest { tetherUtils.registerTetheringEventCallback(); try { tetherEventCallback.assumeWifiTetheringSupported(mContext); + // To prevent WiFi-to-WiFi interruption while entering APM: + // - If WiFi is retained while entering APM, hotspot will also remain enabled. + // - If WiFi is off before APM or disabled while entering APM, hotspot will be + // disabled. + // + // To ensure hotspot always be disabled after enabling APM, disable wifi before + // enabling the hotspot. + mCtsNetUtils.disableWifi(); tetherUtils.startWifiTethering(tetherEventCallback); // Update setting to verify the behavior. @@ -2585,6 +2593,7 @@ public class ConnectivityManagerTest { ConnectivitySettingsManager.setPrivateDnsMode(mContext, curPrivateDnsMode); tetherUtils.unregisterTetheringEventCallback(tetherEventCallback); tetherUtils.stopAllTethering(); + mCtsNetUtils.ensureWifiConnected(); } }