summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorPurushottam Kushwaha <quic_pkushwah@quicinc.com>2020-04-17 09:44:05 +0530
committerRoshan Pius <rpius@google.com>2020-04-20 10:08:22 -0700
commit2ca3fb29b5a4ff4d6aee905884c8e1c82fa147ea (patch)
tree466de9876100a5e95b8ff2c4a73c3aa1b290ebad /service
parent1c93299eed327259785fd3a747d8abdec08397eb (diff)
Softap: Disconnect all connected clients during Softap turn-off.
This commit uses existing forceClientDisconnect() API to disconnect all connected stations during softap turn off. This helps legacy stations to disconnect immidiately during softap turn-off. Bug: 154286607 Test: atest com.android.server.wifi Change-Id: I5f2440916ed817115f061f8564924489b3413bdd
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/HostapdHal.java5
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java14
2 files changed, 18 insertions, 1 deletions
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java
index 418fde66f..6ef0a7f86 100644
--- a/service/java/com/android/server/wifi/HostapdHal.java
+++ b/service/java/com/android/server/wifi/HostapdHal.java
@@ -584,9 +584,12 @@ public class HostapdHal {
case WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_NO_MORE_STAS:
disconnectReason = Ieee80211ReasonCode.WLAN_REASON_DISASSOC_AP_BUSY;
break;
- default:
+ case WifiManager.SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED:
disconnectReason = Ieee80211ReasonCode.WLAN_REASON_UNSPECIFIED;
break;
+ default:
+ throw new IllegalArgumentException(
+ "Unknown disconnect reason code:" + reasonCode);
}
android.hardware.wifi.hostapd.V1_2.HostapdStatus status =
iHostapdV1_2.forceClientDisconnect(ifaceName,
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 44bbc73c4..3bf12ca34 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -16,6 +16,8 @@
package com.android.server.wifi;
+import static android.net.wifi.WifiManager.SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED;
+
import static com.android.server.wifi.util.ApConfigUtil.ERROR_GENERIC;
import static com.android.server.wifi.util.ApConfigUtil.ERROR_NO_CHANNEL;
import static com.android.server.wifi.util.ApConfigUtil.ERROR_UNSUPPORTED_CONFIGURATION;
@@ -433,9 +435,21 @@ public class SoftApManager implements ActiveModeManager {
}
/**
+ * Disconnect all connected clients on active softap interface(s).
+ * This is usually done just before stopSoftAp().
+ */
+ private void disconnectAllClients() {
+ for (WifiClient client : mConnectedClients) {
+ mWifiNative.forceClientDisconnect(mApInterfaceName, client.getMacAddress(),
+ SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED);
+ }
+ }
+
+ /**
* Teardown soft AP and teardown the interface.
*/
private void stopSoftAp() {
+ disconnectAllClients();
mWifiDiagnostics.stopLogging(mApInterfaceName);
mWifiNative.teardownInterface(mApInterfaceName);
Log.d(TAG, "Soft AP is stopped");