[AWARE] Disable MAC randomization during testing

NMI MAC addresses are configured by default to be randomized every
30 minutes. While this is a large interval it can happen during a test
run and may cause a test failure if happening at the wrong time.

Disable the randomization (by setting the interval to 0). Make sure
to re-enable when testing for MAC randomization.

Bug: 72145330
Test: MacRandomTest, AttachTest
Change-Id: I619aad4bedcba40a65e6bf7bc400744d7b8d6052
diff --git a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
index 1e8f9d0..c928acf 100644
--- a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
+++ b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py
@@ -56,6 +56,9 @@
       self.set_power_mode_parameters(ad)
       utils.set_regulatory_domain(ad, "US")
       autils.configure_ndp_allow_any_override(ad, True)
+      # set randomization interval to 0 (disable) to reduce likelihood of
+      # interference in tests
+      autils.configure_mac_random_interval(ad, 0)
 
   def teardown_test(self):
     for ad in self.android_devices:
diff --git a/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py b/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py
index 4be392e..05ba784 100644
--- a/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py
+++ b/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py
@@ -404,6 +404,18 @@
   device.adb.shell(
     "cmd wifiaware native_api set-power %s %s %d" % (mode, name, value))
 
+def configure_mac_random_interval(device, interval_sec):
+  """Use the command-line API to configure the MAC address randomization
+  interval.
+
+  Args:
+    device: Device on which to perform configuration
+    interval_sec: The MAC randomization interval in seconds. A value of 0
+                  disables all randomization.
+  """
+  device.adb.shell(
+    "cmd wifiaware native_api set mac_random_interval_sec %d" % interval_sec)
+
 def configure_ndp_allow_any_override(device, override_api_check):
   """Use the command-line API to configure whether an NDP Responder may be
   configured to accept an NDP request from ANY peer.
diff --git a/acts/tests/google/wifi/aware/functional/MacRandomTest.py b/acts/tests/google/wifi/aware/functional/MacRandomTest.py
index 329ead4..af1503b 100644
--- a/acts/tests/google/wifi/aware/functional/MacRandomTest.py
+++ b/acts/tests/google/wifi/aware/functional/MacRandomTest.py
@@ -57,6 +57,10 @@
     (NAN data-interface) on each enable/disable cycle"""
     dut = self.android_devices[0]
 
+    # re-enable randomization interval (since if disabled it may also disable
+    # the 'randomize on enable' feature).
+    autils.configure_mac_random_interval(dut, 1800)
+
     # DUT: attach and wait for confirmation & identity 10 times
     mac_addresses = {}
     for i in range(self.NUM_ITERATIONS):
@@ -108,9 +112,8 @@
 
     dut = self.android_devices[0]
 
-    # set randomization interval to 5 seconds
-    dut.adb.shell("cmd wifiaware native_api set mac_random_interval_sec %d" %
-                  RANDOM_INTERVAL)
+    # set randomization interval to 120 seconds
+    autils.configure_mac_random_interval(dut, RANDOM_INTERVAL)
 
     # attach and wait for first identity
     id = dut.droid.wifiAwareAttach(True)