[Tests]Enable option for hidden network on the dynamic AP

Provided an option to configure hidden networks on the dynamicAP.
Added tests that exercise hidden networks and connection.

Bug: 72182206
Test: Tested locally
Change-Id: I30b91fd489e413f1081cb66d7415645aef059b42
diff --git a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
index a048906..bd62853 100755
--- a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py
@@ -37,12 +37,13 @@
 class WifiBaseTest(BaseTestClass):
     def __init__(self, controllers):
         BaseTestClass.__init__(self, controllers)
-        if self.attenuators:
+        if hasattr(self, 'attenuators'):
             for attenuator in self.attenuators:
                 attenuator.set_atten(0)
 
     def get_wpa2_network(
             self,
+            hidden=False,
             ap_count=1,
             ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G,
             ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G,
@@ -74,17 +75,33 @@
         ref_5g_ssid = '5g_%s' % utils.rand_ascii_str(ssid_length_5g)
         ref_5g_passphrase = utils.rand_ascii_str(passphrase_length_5g)
 
-        network_dict_2g = {
-            "SSID": ref_2g_ssid,
-            "security": ref_2g_security,
-            "password": ref_2g_passphrase
-        }
+        if hidden:
+           network_dict_2g = {
+              "SSID": ref_2g_ssid,
+              "security": ref_2g_security,
+              "password": ref_2g_passphrase,
+              "hiddenSSID": true
+           }
 
-        network_dict_5g = {
-            "SSID": ref_5g_ssid,
-            "security": ref_5g_security,
-            "password": ref_5g_passphrase
-        }
+           network_dict_5g = {
+              "SSID": ref_5g_ssid,
+              "security": ref_5g_security,
+              "password": ref_5g_passphrase,
+              "hiddenSSID": true
+           }
+        else:
+            network_dict_2g = {
+                "SSID": ref_2g_ssid,
+                "security": ref_2g_security,
+                "password": ref_2g_passphrase
+            }
+
+            network_dict_5g = {
+                "SSID": ref_5g_ssid,
+                "security": ref_5g_security,
+                "password": ref_5g_passphrase
+            }
+
         ap = 0
         for ap in range(ap_count):
             self.user_params["reference_networks"].append({
@@ -97,6 +114,7 @@
         return {"2g": network_dict_2g, "5g": network_dict_5g}
 
     def get_open_network(self,
+                         hidden=False,
                          ap_count=1,
                          ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G,
                          ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G):
@@ -116,8 +134,29 @@
         self.user_params["open_network"] = []
         open_2g_ssid = '2g_%s' % utils.rand_ascii_str(ssid_length_2g)
         open_5g_ssid = '5g_%s' % utils.rand_ascii_str(ssid_length_5g)
-        network_dict_2g = {"SSID": open_2g_ssid, "security": 'none'}
-        network_dict_5g = {"SSID": open_5g_ssid, "security": 'none'}
+        if hidden:
+            network_dict_2g = {
+            "SSID": open_2g_ssid,
+            "security": 'none',
+            "hiddenSSID": true
+            }
+
+            network_dict_5g = {
+            "SSID": open_5g_ssid,
+            "security": 'none',
+            "hiddenSSID": true
+            }
+        else:
+            network_dict_2g = {
+                "SSID": open_2g_ssid,
+                "security": 'none'
+            }
+
+            network_dict_5g = {
+                "SSID": open_5g_ssid,
+                "security": 'none'
+            }
+
         ap = 0
         for ap in range(ap_count):
             self.user_params["open_network"].append({
@@ -166,6 +205,7 @@
             ap_passphrase_length_2g=hostapd_constants.AP_PASSPHRASE_LENGTH_2G,
             ap_ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G,
             ap_passphrase_length_5g=hostapd_constants.AP_PASSPHRASE_LENGTH_5G,
+            hidden=False,
             ap_count=1):
         asserts.assert_true(
             len(self.user_params["AccessPoint"]) == 2,
@@ -214,7 +254,16 @@
         # build config based on the bss_Settings alone.
         hostapd_config_settings = network_list.pop(0)
         for network in network_list:
-            if "password" in network:
+            if "password" in network and "hiddenSSID" in network:
+                bss_settings.append(
+                    hostapd_bss_settings.BssSettings(
+                        name=network["SSID"],
+                        ssid=network["SSID"],
+                        hidden=True,
+                        security=hostapd_security.Security(
+                            security_mode=network["security"],
+                            password=network["password"])))
+            elif "password" in network and not "hiddenSSID" in network:
                 bss_settings.append(
                     hostapd_bss_settings.BssSettings(
                         name=network["SSID"],
@@ -222,10 +271,17 @@
                         security=hostapd_security.Security(
                             security_mode=network["security"],
                             password=network["password"])))
-            else:
+            elif not "password" in network and "hiddenSSID" in network:
                 bss_settings.append(
                     hostapd_bss_settings.BssSettings(
-                        name=network["SSID"], ssid=network["SSID"]))
+                        name=network["SSID"],
+                        ssid=network["SSID"],
+                        hidden=True))
+            elif not "password" in network and not "hiddenSSID" in network:
+                bss_settings.append(
+                    hostapd_bss_settings.BssSettings(
+                        name=network["SSID"],
+                        ssid=network["SSID"]))
         if "password" in hostapd_config_settings:
             config = hostapd_ap_preset.create_ap_preset(
                 channel=ap_settings["channel"],