summaryrefslogtreecommitdiff
path: root/tests
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 /tests
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 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java24
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java29
2 files changed, 51 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
index 9db553f3b..52a28eafe 100644
--- a/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/HostapdHalTest.java
@@ -34,6 +34,7 @@ import android.hidl.manager.V1_0.IServiceNotification;
import android.net.MacAddress;
import android.net.wifi.SoftApConfiguration;
import android.net.wifi.SoftApConfiguration.Builder;
+import android.net.wifi.WifiManager;
import android.net.wifi.nl80211.WifiNl80211Manager;
import android.os.Handler;
import android.os.IHwBinder;
@@ -820,10 +821,28 @@ public class HostapdHalTest extends WifiBaseTest {
when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort()))
.thenReturn(mStatusSuccess12);
- assertTrue(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, 0));
+ assertTrue(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER));
verify(mIHostapdMockV12).forceClientDisconnect(any(), any(), anyShort());
}
+ @Test
+ public void testForceClientDisconnectFailureDueToInvalidArg() throws Exception {
+ executeAndValidateInitializationSequence();
+ when(mServiceManagerMock.getTransport(anyString(), anyString()))
+ .thenReturn(IServiceManager.Transport.HWBINDER);
+ MacAddress test_client = MacAddress.fromString("da:a1:19:0:0:0");
+ mIHostapdMockV12 = mock(android.hardware.wifi.hostapd.V1_2.IHostapd.class);
+ when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort()))
+ .thenReturn(mStatusSuccess12);
+
+ try {
+ mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, -1);
+ fail();
+ } catch (IllegalArgumentException e) {
+ }
+ }
+
/**
* Verifies the failure handling in forceClientDisconnect.
*/
@@ -837,7 +856,8 @@ public class HostapdHalTest extends WifiBaseTest {
when(mIHostapdMockV12.forceClientDisconnect(any(), any(), anyShort()))
.thenReturn(mStatusFailure12);
- assertFalse(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client, 0));
+ assertFalse(mHostapdHal.forceClientDisconnect(IFACE_NAME, test_client,
+ WifiManager.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER));
verify(mIHostapdMockV12).forceClientDisconnect(any(), any(), anyShort());
}
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index a7e21c996..ca7bc627c 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -23,6 +23,7 @@ import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_MODE;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
import static android.net.wifi.WifiManager.IFACE_IP_MODE_LOCAL_ONLY;
+import static android.net.wifi.WifiManager.SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_DISABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
@@ -1106,6 +1107,34 @@ public class SoftApManagerTest extends WifiBaseTest {
}
@Test
+ public void stopDisconnectsConnectedClients() throws Exception {
+ InOrder order = inOrder(mCallback, mWifiMetrics);
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null,
+ mTestSoftApCapability);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ order.verify(mCallback).onConnectedClientsChanged(new ArrayList<>());
+
+ mSoftApListenerCaptor.getValue().onConnectedClientsChanged(
+ TEST_NATIVE_CLIENT, true);
+ mLooper.dispatchAll();
+
+ order.verify(mCallback).onConnectedClientsChanged(
+ Mockito.argThat((List<WifiClient> clients) ->
+ clients.contains(TEST_CONNECTED_CLIENT))
+ );
+ verify(mWifiMetrics).addSoftApNumAssociatedStationsChangedEvent(
+ 1, apConfig.getTargetMode());
+
+ mSoftApManager.stop();
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).forceClientDisconnect(TEST_INTERFACE_NAME, TEST_MAC_ADDRESS,
+ SAP_CLIENT_DISCONNECT_REASON_CODE_UNSPECIFIED);
+ }
+
+ @Test
public void handlesInvalidConnectedClients() throws Exception {
SoftApModeConfiguration apConfig =
new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null,