From 8c98b3d35e187b476f9669b183c957ddd738fdfd Mon Sep 17 00:00:00 2001 From: Mark Chien Date: Wed, 15 Apr 2020 17:28:27 +0000 Subject: [PATCH] Do not stop IpServer when recieve wifi ap disabling state. This is used to fix the race when quickly OFF/ON wifi tethering. When IpServer is started/stopped, there is callback update tethering interface status. Before this change, IpServer is stopped when wifi ap is disabling. Then the next startTethering may fail in wifi because wifi is in disabling state. Error pattern: WifiService: Tethering is already active. No unitest for this CL but it fixed the CtsTetheringTest flakty rate than around 30% to 0 for more than 100 runs. Bug: 153925821 Test: atest CtsTetheringTest --iteration 100 Merged-In: I8b65f621abe20799a3a0d410ba1f06368746ee49 Change-Id: I8b65f621abe20799a3a0d410ba1f06368746ee49 --- .../src/com/android/networkstack/tethering/Tethering.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tethering/src/com/android/networkstack/tethering/Tethering.java b/Tethering/src/com/android/networkstack/tethering/Tethering.java index f3cead92be..bae54a5c76 100644 --- a/Tethering/src/com/android/networkstack/tethering/Tethering.java +++ b/Tethering/src/com/android/networkstack/tethering/Tethering.java @@ -922,8 +922,10 @@ public class Tethering { case WifiManager.WIFI_AP_STATE_ENABLED: enableWifiIpServingLocked(ifname, ipmode); break; - case WifiManager.WIFI_AP_STATE_DISABLED: case WifiManager.WIFI_AP_STATE_DISABLING: + // We can see this state on the way to disabled. + break; + case WifiManager.WIFI_AP_STATE_DISABLED: case WifiManager.WIFI_AP_STATE_FAILED: default: disableWifiIpServingLocked(ifname, curState);