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
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 9c85eb2..9b759dc 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1112,15 +1112,21 @@
// 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 @@
}
}
- if (mLocalOnlyHotspotRequests.isEmpty()) {
- startForFirstRequestLocked(request);
- }
mLocalOnlyHotspotRequests.put(pid, request);
-
return LocalOnlyHotspotCallback.REQUEST_REGISTERED;
}
}