From 5c5b37f9cc52daff34b8509dbda68e754fbbcacb Mon Sep 17 00:00:00 2001 From: Rebecca Silberstein Date: Thu, 29 Jun 2017 14:37:55 -0700 Subject: SoftApManager: support hidden ap configs WifiConfigurations for hostapd may set the hiddenSSID flag to true, intending to start softap without advertising the network. While this is not a valid option through the UI, it can be very useful in a test environment. This CL adds support to start hostapd with the hidden network flag set. Note: an integration test will be added to verify the behavior, but this requires additional plumbing in the test code. Tracking that work with Bug 63141761. Bug: 34209778 Test: ran modified integration test to verify the ssid is not broadcast Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: If5fef73bc069f155572257e4a9c81efd00dccacf --- .../com/android/server/wifi/SoftApManagerTest.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index 900e6a61a..892b5975c 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -137,6 +137,20 @@ public class SoftApManagerTest { startSoftApAndVerifyEnabled(config); } + + /** + * Verifies startSoftAp will start with the hiddenSSID param set when it is set to true in the + * supplied config. + */ + @Test + public void startSoftApWithHiddenSsidTrueInConfig() throws Exception { + WifiConfiguration config = new WifiConfiguration(); + config.apBand = WifiConfiguration.AP_BAND_2GHZ; + config.SSID = TEST_SSID; + config.hiddenSSID = true; + startSoftApAndVerifyEnabled(config); + } + /** Tests softap startup if default config fails to load. **/ @Test public void startSoftApDefaultConfigFailedToLoad() throws Exception { @@ -200,6 +214,7 @@ public class SoftApManagerTest { /** Starts soft AP and verifies that it is enabled successfully. */ protected void startSoftApAndVerifyEnabled(WifiConfiguration config) throws Exception { String expectedSSID; + boolean expectedHiddenSsid; InOrder order = inOrder(mListener, mApInterfaceBinder, mApInterface, mNmService); when(mWifiNative.isHalStarted()).thenReturn(false); @@ -210,16 +225,19 @@ public class SoftApManagerTest { if (config == null) { when(mWifiApConfigStore.getApConfiguration()).thenReturn(mDefaultApConfig); expectedSSID = mDefaultApConfig.SSID; + expectedHiddenSsid = mDefaultApConfig.hiddenSSID; } else { expectedSSID = config.SSID; + expectedHiddenSsid = config.hiddenSSID; } + mSoftApManager.start(); mLooper.dispatchAll(); order.verify(mListener).onStateChanged(WifiManager.WIFI_AP_STATE_ENABLING, 0); order.verify(mApInterfaceBinder).linkToDeath(mDeathListenerCaptor.capture(), eq(0)); order.verify(mNmService).registerObserver(mNetworkObserverCaptor.capture()); order.verify(mApInterface).writeHostapdConfig( - eq(expectedSSID.getBytes(StandardCharsets.UTF_8)), anyBoolean(), + eq(expectedSSID.getBytes(StandardCharsets.UTF_8)), eq(expectedHiddenSsid), anyInt(), anyInt(), any()); order.verify(mApInterface).startHostapd(); mNetworkObserverCaptor.getValue().interfaceLinkStateChanged(TEST_INTERFACE_NAME, true); -- cgit v1.2.3