wifi: Add unit API in ACTS for bridged AP test

Also: Fix the boolean configuration variable with False doesn't work
when setSoftApConfiguration.

Bug: 168305604
Test: Manual test, event pass to ACTS correctly
Test: act.py -tc WifiSoftApTest:test_softap_configuration_update
Change-Id: I09483a82bc6a8c70862525861b34ec6aff247736
diff --git a/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py b/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py
index 1f67ab5..06e4ff8 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py
@@ -46,15 +46,23 @@
 WIFI_AP_ENABLED_STATE = 13
 WIFI_AP_FAILED_STATE = 14
 
+SOFTAP_RANDOMIZATION_NONE = 0
+SOFTAP_RANDOMIZATION_PERSISTENT = 1
+
 # Callback Event for client number change:
 # WifiManagerSoftApCallback-[callbackId]-OnNumClientsChanged
+SOFTAP_NUMBER_CLIENTS_CHANGED_WITH_INFO = "-OnConnectedClientsChangedWithInfo"
 SOFTAP_NUMBER_CLIENTS_CHANGED = "-OnNumClientsChanged"
 SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY = "NumClients"
 SOFTAP_CLIENTS_MACS_CALLBACK_KEY = "MacAddresses"
 # Callback Event for softap info change
 SOFTAP_INFO_CHANGED = "-OnInfoChanged"
+SOFTAP_INFOLIST_CHANGED = "-OnInfoListChanged"
 SOFTAP_INFO_FREQUENCY_CALLBACK_KEY = "frequency"
 SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY = "bandwidth"
+SOFTAP_INFO_WIFISTANDARD_CALLBACK_KEY = "wifiStandard"
+SOFTAP_INFO_AUTO_SHUTDOWN_CALLBACK_KEY = "autoShutdownTimeoutMillis"
+SOFTAP_INFO_BSSID_CALLBACK_KEY = "bssid"
 # Callback Event for softap client blocking
 SOFTAP_BLOCKING_CLIENT_CONNECTING = "-OnBlockedClientConnecting"
 SOFTAP_BLOCKING_CLIENT_REASON_KEY = "BlockedReason"
@@ -65,9 +73,18 @@
 # Callback Event for softap capability
 SOFTAP_CAPABILITY_CHANGED = "-OnCapabilityChanged"
 SOFTAP_CAPABILITY_MAX_SUPPORTED_CLIENTS = "maxSupportedClients"
+SOFTAP_CAPABILITY_24GHZ_SUPPORTED_CHANNEL_LIST = "supported2GHzChannellist"
+SOFTAP_CAPABILITY_5GHZ_SUPPORTED_CHANNEL_LIST = "supported5GHzChannellist"
+SOFTAP_CAPABILITY_6GHZ_SUPPORTED_CHANNEL_LIST = "supported6GHzChannellist"
+SOFTAP_CAPABILITY_60GHZ_SUPPORTED_CHANNEL_LIST = "supported60GHzChannellist"
 SOFTAP_CAPABILITY_FEATURE_ACS = "acsOffloadSupported"
 SOFTAP_CAPABILITY_FEATURE_CLIENT_CONTROL = "clientForceDisconnectSupported"
 SOFTAP_CAPABILITY_FEATURE_WPA3_SAE = "wpa3SaeSupported"
+SOFTAP_CAPABILITY_FEATURE_IEEE80211AX = "ieee80211axSupported"
+SOFTAP_CAPABILITY_FEATURE_24GHZ = "24gSupported"
+SOFTAP_CAPABILITY_FEATURE_5GHZ = "5gSupported"
+SOFTAP_CAPABILITY_FEATURE_6GHZ = "6gSupported"
+SOFTAP_CAPABILITY_FEATURE_60GHZ = "60gSupported"
 
 DEFAULT_SOFTAP_TIMEOUT_S = 600 # 10 minutes
 
diff --git a/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py b/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
index 9615d33..a644a85 100755
--- a/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/wifi_test_utils.py
@@ -81,6 +81,11 @@
     # Used for SoftAp
     AP_BAND_KEY = "apBand"
     AP_CHANNEL_KEY = "apChannel"
+    AP_BANDS_KEY = "apBands"
+    AP_CHANNEL_FREQUENCYS_KEY = "apChannelFrequencies"
+    AP_MAC_RANDOMIZATION_SETTING_KEY = "MacRandomizationSetting"
+    AP_BRIDGED_OPPORTUNISTIC_SHUTDOWN_ENABLE_KEY = "BridgedModeOpportunisticShutdownEnabled"
+    AP_IEEE80211AX_ENABLED_KEY = "Ieee80211axEnabled"
     AP_MAXCLIENTS_KEY = "MaxNumberOfClients"
     AP_SHUTDOWNTIMEOUT_KEY = "ShutdownTimeoutMillis"
     AP_SHUTDOWNTIMEOUTENABLE_KEY = "AutoShutdownEnabled"
@@ -1004,7 +1009,12 @@
                              shutdown_timeout_millis=None,
                              client_control_enable=None,
                              allowedList=None,
-                             blockedList=None):
+                             blockedList=None,
+                             bands=None,
+                             channel_frequencys=None,
+                             mac_randomization_setting=None,
+                             bridged_opportunistic_shutdown_enabled=None,
+                             ieee80211ax_enabled=None):
     """ Save a soft ap configuration and verified
     Args:
         ad: android_device to set soft ap configuration.
@@ -1020,30 +1030,49 @@
         client_control_enable: specifies the client control enable or not.
         allowedList: specifies allowed clients list.
         blockedList: specifies blocked clients list.
+        bands: specifies the band list for the soft ap.
+        channel_frequencys: specifies the channel frequency list for soft ap.
+        mac_randomization_setting: specifies the mac randomization setting.
+        bridged_opportunistic_shutdown_enabled: specifies the opportunistic
+                shutdown enable or not.
+        ieee80211ax_enabled: specifies the ieee80211ax enable or not.
     """
     if security and password:
         wifi_config[WifiEnums.SECURITY] = security
         wifi_config[WifiEnums.PWD_KEY] = password
-    if band:
-        wifi_config[WifiEnums.AP_BAND_KEY] = band
-    if hidden:
+    if hidden is not None:
         wifi_config[WifiEnums.HIDDEN_KEY] = hidden
-    if channel and band:
-        wifi_config[WifiEnums.AP_BAND_KEY] = band
-        wifi_config[WifiEnums.AP_CHANNEL_KEY] = channel
-    if max_clients:
+    if max_clients is not None:
         wifi_config[WifiEnums.AP_MAXCLIENTS_KEY] = max_clients
-    if shutdown_timeout_enable:
+    if shutdown_timeout_enable is not None:
         wifi_config[
             WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY] = shutdown_timeout_enable
-    if shutdown_timeout_millis:
+    if shutdown_timeout_millis is not None:
         wifi_config[WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] = shutdown_timeout_millis
-    if client_control_enable:
+    if client_control_enable is not None:
         wifi_config[WifiEnums.AP_CLIENTCONTROL_KEY] = client_control_enable
-    if allowedList:
+    if allowedList is not None:
         wifi_config[WifiEnums.AP_ALLOWEDLIST_KEY] = allowedList
-    if blockedList:
+    if blockedList is not None:
         wifi_config[WifiEnums.AP_BLOCKEDLIST_KEY] = blockedList
+    if mac_randomization_setting is not None:
+        wifi_config[WifiEnums.AP_MAC_RANDOMIZATION_SETTING_KEY
+                ] = mac_randomization_setting
+    if bridged_opportunistic_shutdown_enabled is not None:
+        wifi_config[WifiEnums.AP_BRIDGED_OPPORTUNISTIC_SHUTDOWN_ENABLE_KEY
+                ] = bridged_opportunistic_shutdown_enabled
+    if ieee80211ax_enabled is not None:
+       wifi_config[WifiEnums.AP_IEEE80211AX_ENABLED_KEY]= ieee80211ax_enabled
+    if channel_frequencys is not None:
+        wifi_config[WifiEnums.AP_CHANNEL_FREQUENCYS_KEY] = channel_frequencys
+    elif bands is not None:
+        wifi_config[WifiEnums.AP_BANDS_KEY] = bands
+    elif band is not None:
+        if channel is not None:
+            wifi_config[WifiEnums.AP_BAND_KEY] = band
+            wifi_config[WifiEnums.AP_CHANNEL_KEY] = channel
+        else:
+             wifi_config[WifiEnums.AP_BAND_KEY] = band
 
     if WifiEnums.AP_CHANNEL_KEY in wifi_config and wifi_config[
             WifiEnums.AP_CHANNEL_KEY] == 0:
@@ -1075,10 +1104,6 @@
             wifi_ap[WifiEnums.HIDDEN_KEY] == wifi_config[WifiEnums.HIDDEN_KEY],
             "Hotspot hidden setting doesn't match")
 
-    if WifiEnums.AP_BAND_KEY in wifi_config:
-        asserts.assert_true(
-            wifi_ap[WifiEnums.AP_BAND_KEY] == wifi_config[
-                WifiEnums.AP_BAND_KEY], "Hotspot Band doesn't match")
     if WifiEnums.AP_CHANNEL_KEY in wifi_config:
         asserts.assert_true(
             wifi_ap[WifiEnums.AP_CHANNEL_KEY] == wifi_config[
@@ -1114,6 +1139,29 @@
                 WifiEnums.AP_BLOCKEDLIST_KEY],
             "Hotspot Blocked List doesn't match")
 
+    if WifiEnums.AP_MAC_RANDOMIZATION_SETTING_KEY in wifi_config:
+        asserts.assert_true(
+            wifi_ap[WifiEnums.AP_MAC_RANDOMIZATION_SETTING_KEY] == wifi_config[
+                  WifiEnums.AP_MAC_RANDOMIZATION_SETTING_KEY],
+            "Hotspot Mac randomization setting doesn't match")
+
+    if WifiEnums.AP_BRIDGED_OPPORTUNISTIC_SHUTDOWN_ENABLE_KEY in wifi_config:
+        asserts.assert_true(
+            wifi_ap[WifiEnums.AP_BRIDGED_OPPORTUNISTIC_SHUTDOWN_ENABLE_KEY] == wifi_config[
+                  WifiEnums.AP_BRIDGED_OPPORTUNISTIC_SHUTDOWN_ENABLE_KEY],
+            "Hotspot bridged shutdown enable setting doesn't match")
+
+    if WifiEnums.AP_IEEE80211AX_ENABLED_KEY in wifi_config:
+        asserts.assert_true(
+            wifi_ap[WifiEnums.AP_IEEE80211AX_ENABLED_KEY] == wifi_config[
+                  WifiEnums.AP_IEEE80211AX_ENABLED_KEY],
+            "Hotspot 80211 AX enable setting doesn't match")
+
+    if WifiEnums.AP_CHANNEL_FREQUENCYS_KEY in wifi_config:
+        asserts.assert_true(
+            wifi_ap[WifiEnums.AP_CHANNEL_FREQUENCYS_KEY] == wifi_config[
+                  WifiEnums.AP_CHANNEL_FREQUENCYS_KEY],
+            "Hotspot channels setting doesn't match")
 
 def start_wifi_tethering_saved_config(ad):
     """ Turn on wifi hotspot with a config that is already saved """
@@ -2335,20 +2383,20 @@
     return num_of_clients
 
 
-def get_current_softap_info(ad, callbackId, least_one):
+def get_current_softap_info(ad, callbackId, need_to_wait):
     """pop up all of softap info changed event from queue.
     Args:
         callbackId: Id of the callback associated with registering.
-        least_one: Wait for the info callback event before pop all.
+        need_to_wait: Wait for the info callback event before pop all.
     Returns:
         Returns last updated information of softap.
     """
     eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
         callbackId) + wifi_constants.SOFTAP_INFO_CHANGED
-    ad.log.info("softap info dump from eventStr %s", eventStr)
+    ad.log.debug("softap info dump from eventStr %s", eventStr)
     frequency = 0
     bandwidth = 0
-    if (least_one):
+    if (need_to_wait):
         event = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)
         frequency = event['data'][
             wifi_constants.SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
@@ -2367,6 +2415,61 @@
                 bandwidth)
     return frequency, bandwidth
 
+def get_current_softap_infos(ad, callbackId, need_to_wait):
+    """pop up all of softap info list changed event from queue.
+    Args:
+        callbackId: Id of the callback associated with registering.
+        need_to_wait: Wait for the info callback event before pop all.
+    Returns:
+        Returns last updated informations of softap.
+    """
+    eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
+        callbackId) + wifi_constants.SOFTAP_INFOLIST_CHANGED
+    ad.log.debug("softap info dump from eventStr %s", eventStr)
+
+    if (need_to_wait):
+        event = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)
+        infos = event['data']
+
+    events = ad.ed.pop_all(eventStr)
+    for event in events:
+        infos = event['data']
+
+    for info in infos:
+        frequency = info[
+            wifi_constants.SOFTAP_INFO_FREQUENCY_CALLBACK_KEY]
+        bandwidth = info[
+            wifi_constants.SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY]
+        wifistandard = info[
+            wifi_constants.SOFTAP_INFO_WIFISTANDARD_CALLBACK_KEY]
+        bssid = info[
+            wifi_constants.SOFTAP_INFO_BSSID_CALLBACK_KEY]
+        ad.log.info(
+                "softap info, freq:%s, bw:%s, wifistandard:%s, bssid:%s",
+                frequency, bandwidth, wifistandard, bssid)
+
+    return infos
+
+def get_current_softap_capability(ad, callbackId, need_to_wait):
+    """pop up all of softap info list changed event from queue.
+    Args:
+        callbackId: Id of the callback associated with registering.
+        need_to_wait: Wait for the info callback event before pop all.
+    Returns:
+        Returns last updated capability of softap.
+    """
+    eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str(
+            callbackId) + wifi_constants.SOFTAP_CAPABILITY_CHANGED
+    ad.log.debug("softap capability dump from eventStr %s", eventStr)
+    if (need_to_wait):
+        event = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)
+        capability = event['data']
+
+    events = ad.ed.pop_all(eventStr)
+    for event in events:
+        capability = event['data']
+
+    return capability
 
 def get_ssrdumps(ad):
     """Pulls dumps in the ssrdump dir
diff --git a/acts_tests/tests/google/wifi/WifiSoftApTest.py b/acts_tests/tests/google/wifi/WifiSoftApTest.py
index 741b57a..db22550 100644
--- a/acts_tests/tests/google/wifi/WifiSoftApTest.py
+++ b/acts_tests/tests/google/wifi/WifiSoftApTest.py
@@ -992,7 +992,9 @@
         1. Get current softap configuration
         2. Update to Open Security configuration
         3. Update to WPA2_PSK configuration
-        4. Restore the configuration
+        4. Update to Multi-Channels, Mac Randomization off,
+           bridged_shutdown off, 11ax off configuration which are introduced in S.
+        5. Restore the configuration
       """
       # Backup config
       original_softap_config = self.dut.droid.wifiGetApConfiguration()
@@ -1010,6 +1012,13 @@
           shutdown_timeout_millis=10000, client_control_enable=False,
           allowedList=["aa:bb:cc:dd:ee:ff"], blockedList=["11:22:33:44:55:66"])
 
+
+      wutils.save_wifi_soft_ap_config(self.dut, {"SSID":"ACTS_TEST"},
+          channel_frequencys=[2412,5745],
+          mac_randomization_setting = wifi_constants.SOFTAP_RANDOMIZATION_NONE,
+          bridged_opportunistic_shutdown_enabled=False,
+          ieee80211ax_enabled=False)
+
       # Restore config
       wutils.save_wifi_soft_ap_config(self.dut, original_softap_config)