summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/SoftApManager.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java20
2 files changed, 24 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java
index 64f4a1494..d4a1ea508 100644
--- a/service/java/com/android/server/wifi/SoftApManager.java
+++ b/service/java/com/android/server/wifi/SoftApManager.java
@@ -161,12 +161,16 @@ public class SoftApManager implements ActiveModeManager {
int encryptionType = getIApInterfaceEncryptionType(localConfig);
+ if (localConfig.hiddenSSID) {
+ Log.d(TAG, "SoftAP is a hidden network");
+ }
+
try {
// Note that localConfig.SSID is intended to be either a hex string or "double quoted".
// However, it seems that whatever is handing us these configurations does not obey
// this convention.
boolean success = mApInterface.writeHostapdConfig(
- localConfig.SSID.getBytes(StandardCharsets.UTF_8), false,
+ localConfig.SSID.getBytes(StandardCharsets.UTF_8), localConfig.hiddenSSID,
localConfig.apChannel, encryptionType,
(localConfig.preSharedKey != null)
? localConfig.preSharedKey.getBytes(StandardCharsets.UTF_8)
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);