From d8b3d7c285b24a1b1e22721631c7bdb3c31ef3e1 Mon Sep 17 00:00:00 2001 From: Patrik Fimml Date: Wed, 6 Nov 2019 17:55:11 +0100 Subject: Configurable SoftAP: Fix exclusivity logic. mActiveConfig isn't cleared on shutdown; use the same conditions used in other locations to determine if LOHS is active. Bug: 132705022 Test: run twice in a row: atest android.net.wifi.cts.WifiManagerTest#testStartLocalOnlyHotspotWithConfig Change-Id: Id93a34eb97727f69b20f69fbab998f7eed026bcf --- .../java/com/android/server/wifi/WifiServiceImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 9c85eb2c8..9b759dc11 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1112,15 +1112,21 @@ public class WifiServiceImpl extends BaseWifiService { // Never accept exclusive requests (with custom configuration) at the same time as // shared requests. - if (mActiveConfig != null) { + if (!mLocalOnlyHotspotRequests.isEmpty()) { boolean requestIsExclusive = request.getCustomConfig() != null; if (mIsExclusive || requestIsExclusive) { + mLog.trace("Cannot share with existing LOHS request due to custom config") + .flush(); return LocalOnlyHotspotCallback.ERROR_GENERIC; } } - // If a local-only AP is already active, send the current config. - if (mLohsInterfaceMode == WifiManager.IFACE_IP_MODE_LOCAL_ONLY) { + // At this point, the request is accepted. + if (mLocalOnlyHotspotRequests.isEmpty()) { + startForFirstRequestLocked(request); + } else if (mLohsInterfaceMode == WifiManager.IFACE_IP_MODE_LOCAL_ONLY) { + // LOHS has already started up for an earlier request, so we can send the + // current config to the incoming request right away. try { mLog.trace("LOHS already up, trigger onStarted callback").flush(); request.sendHotspotStartedMessage(mActiveConfig.getWifiConfiguration()); @@ -1129,11 +1135,7 @@ public class WifiServiceImpl extends BaseWifiService { } } - if (mLocalOnlyHotspotRequests.isEmpty()) { - startForFirstRequestLocked(request); - } mLocalOnlyHotspotRequests.put(pid, request); - return LocalOnlyHotspotCallback.REQUEST_REGISTERED; } } -- cgit v1.2.3