Merge tag 'android-13.0.0_r32' into int/13/fp3

Android 13.0.0 release 32

* tag 'android-13.0.0_r32':
  Support to capture wifi logs via PixelLogger

Change-Id: Ia35c4867f5cc89ee18585a17bc88ed2863782f33
diff --git a/acts_tests/acts_contrib/test_utils/wifi/WifiBaseTest.py b/acts_tests/acts_contrib/test_utils/wifi/WifiBaseTest.py
index 1f80858..6fc39e0 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/WifiBaseTest.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/WifiBaseTest.py
@@ -55,15 +55,8 @@
         if hasattr(self, 'attenuators') and self.attenuators:
             for attenuator in self.attenuators:
                 attenuator.set_atten(0)
-        opt_param = ["pixel_models", "cnss_diag_file", "country_code_file"]
+        opt_param = ["country_code_file"]
         self.unpack_userparams(opt_param_names=opt_param)
-        if hasattr(self, "cnss_diag_file"):
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
         if self.enable_packet_log and hasattr(self, "packet_capture"):
             self.packet_logger = self.packet_capture[0]
             self.packet_logger.configure_monitor_mode("2G", self.packet_log_2g)
@@ -83,11 +76,8 @@
                     wutils.set_wifi_country_code(ad, self.country_code)
 
     def setup_test(self):
-        if (hasattr(self, "android_devices")
-                and hasattr(self, "cnss_diag_file")
-                and hasattr(self, "pixel_models")):
-            wutils.start_cnss_diags(self.android_devices, self.cnss_diag_file,
-                                    self.pixel_models)
+        if (hasattr(self, "android_devices")):
+            wutils.start_all_wlan_logs(self.android_devices)
         self.tcpdump_proc = []
         if hasattr(self, "android_devices"):
             for ad in self.android_devices:
@@ -98,10 +88,8 @@
                                                     self.test_name)
 
     def teardown_test(self):
-        if (hasattr(self, "android_devices")
-                and hasattr(self, "cnss_diag_file")
-                and hasattr(self, "pixel_models")):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        if (hasattr(self, "android_devices")):
+            wutils.stop_all_wlan_logs(self.android_devices)
             for proc in self.tcpdump_proc:
                 nutils.stop_tcpdump(proc[0],
                                     proc[1],
@@ -120,11 +108,9 @@
                 ad.take_bug_report(test_name, begin_time)
                 ad.cat_adb_log(test_name, begin_time)
                 wutils.get_ssrdumps(ad)
-            if (hasattr(self, "cnss_diag_file")
-                    and hasattr(self, "pixel_models")):
-                wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
-                for ad in self.android_devices:
-                    wutils.get_cnss_diag_log(ad)
+            wutils.stop_all_wlan_logs(self.android_devices)
+            for ad in self.android_devices:
+                wutils.get_wlan_logs(ad)
             for proc in self.tcpdump_proc:
                 nutils.stop_tcpdump(proc[0], proc[1], self.test_name)
             self.tcpdump_proc = []
diff --git a/acts_tests/acts_contrib/test_utils/wifi/aware/AwareBaseTest.py b/acts_tests/acts_contrib/test_utils/wifi/aware/AwareBaseTest.py
index 14c5c0e..4a51ff7 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/aware/AwareBaseTest.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/aware/AwareBaseTest.py
@@ -36,24 +36,15 @@
     device_startup_offset = 2
 
     def setup_class(self):
-        opt_param = ["pixel_models", "cnss_diag_file", "ranging_role_concurrency_flexible_models"]
+        opt_param = ["ranging_role_concurrency_flexible_models"]
         self.unpack_userparams(opt_param_names=opt_param)
-        if hasattr(self, "cnss_diag_file"):
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def setup_test(self):
         required_params = ("aware_default_power_mode",
                            "dbs_supported_models",)
         self.unpack_userparams(required_params)
 
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
+        wutils.start_all_wlan_logs(self.android_devices)
         self.tcpdump_proc = []
         if hasattr(self, "android_devices"):
             for ad in self.android_devices:
@@ -86,8 +77,7 @@
             ad.ed.clear_all_events()
 
     def teardown_test(self):
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        wutils.stop_all_wlan_logs(self.android_devices)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(
                     proc[0], proc[1], self.test_name, pull_dump=False)
@@ -144,10 +134,9 @@
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
             wutils.get_ssrdumps(ad)
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
-            for ad in self.android_devices:
-                wutils.get_cnss_diag_log(ad)
+        wutils.stop_all_wlan_logs(self.android_devices)
+        for ad in self.android_devices:
+            wutils.get_wlan_logs(ad)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(proc[0], proc[1], self.test_name)
         self.tcpdump_proc = []
diff --git a/acts_tests/acts_contrib/test_utils/wifi/p2p/WifiP2pBaseTest.py b/acts_tests/acts_contrib/test_utils/wifi/p2p/WifiP2pBaseTest.py
index c0b18ae..ebc1e6b 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/p2p/WifiP2pBaseTest.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/p2p/WifiP2pBaseTest.py
@@ -40,7 +40,7 @@
             ad.droid.wakeLockAcquireBright()
             ad.droid.wakeUpNow()
         required_params = ()
-        optional_params = ("skip_read_factory_mac", "pixel_models", "cnss_diag_file")
+        optional_params = ("skip_read_factory_mac")
         self.unpack_userparams(required_params,
                                optional_params,
                                skip_read_factory_mac=0)
@@ -87,13 +87,6 @@
                 "DUT3's p2p should be initialized but it didn't")
             self.dut3.name = "Android_" + self.dut3.serial
             self.dut3.droid.wifiP2pSetDeviceName(self.dut3.name)
-        if hasattr(self, "cnss_diag_file"):
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def teardown_class(self):
         self.dut1.droid.wifiP2pClose()
@@ -109,9 +102,7 @@
             ad.droid.goToSleepNow()
 
     def setup_test(self):
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
+        wutils.start_all_wlan_logs(self.android_devices)
         self.tcpdump_proc = []
         if hasattr(self, "android_devices"):
             for ad in self.android_devices:
@@ -122,8 +113,7 @@
             ad.ed.clear_all_events()
 
     def teardown_test(self):
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        wutils.stop_all_wlan_logs(self.android_devices)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(
                     proc[0], proc[1], self.test_name, pull_dump=False)
@@ -143,10 +133,9 @@
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
             wutils.get_ssrdumps(ad)
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
-            for ad in self.android_devices:
-                wutils.get_cnss_diag_log(ad)
+        wutils.stop_all_wlan_logs(self.android_devices)
+        for ad in self.android_devices:
+            wutils.get_wlan_logs(ad)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(proc[0], proc[1], self.test_name)
         self.tcpdump_proc = []
diff --git a/acts_tests/acts_contrib/test_utils/wifi/rtt/RttBaseTest.py b/acts_tests/acts_contrib/test_utils/wifi/rtt/RttBaseTest.py
index c11f66a..b9abd49 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/rtt/RttBaseTest.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/rtt/RttBaseTest.py
@@ -29,15 +29,8 @@
 class RttBaseTest(BaseTestClass):
 
     def setup_class(self):
-        opt_param = ["pixel_models", "cnss_diag_file", "ranging_role_concurrency_flexible_models"]
+        opt_param = ["ranging_role_concurrency_flexible_models"]
         self.unpack_userparams(opt_param_names=opt_param)
-        if hasattr(self, "cnss_diag_file"):
-            if isinstance(self.cnss_diag_file, list):
-                self.cnss_diag_file = self.cnss_diag_file[0]
-            if not os.path.isfile(self.cnss_diag_file):
-                self.cnss_diag_file = os.path.join(
-                    self.user_params[Config.key_config_path.value],
-                    self.cnss_diag_file)
 
     def setup_test(self):
         required_params = ("lci_reference", "lcr_reference",
@@ -54,9 +47,7 @@
         self.rtt_max_margin_exceeded_rate_one_sided_rtt_percentage = 50
         self.rtt_min_expected_rssi_dbm = -100
 
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.start_cnss_diags(
-                self.android_devices, self.cnss_diag_file, self.pixel_models)
+        wutils.start_all_wlan_logs(self.android_devices)
         self.tcpdump_proc = []
         if hasattr(self, "android_devices"):
             for ad in self.android_devices:
@@ -80,8 +71,7 @@
             ad.rtt_capabilities = rutils.get_rtt_capabilities(ad)
 
     def teardown_test(self):
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
+        wutils.stop_all_wlan_logs(self.android_devices)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(
                     proc[0], proc[1], self.test_name, pull_dump=False)
@@ -98,10 +88,9 @@
             ad.take_bug_report(test_name, begin_time)
             ad.cat_adb_log(test_name, begin_time)
             wutils.get_ssrdumps(ad)
-        if hasattr(self, "cnss_diag_file") and hasattr(self, "pixel_models"):
-            wutils.stop_cnss_diags(self.android_devices, self.pixel_models)
-            for ad in self.android_devices:
-                wutils.get_cnss_diag_log(ad)
+        wutils.stop_all_wlan_logs(self.android_devices)
+        for ad in self.android_devices:
+            wutils.get_wlan_logs(ad)
         for proc in self.tcpdump_proc:
             nutils.stop_tcpdump(proc[0], proc[1], self.test_name)
         self.tcpdump_proc = []
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 6247643..3ff7599 100644
--- a/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py
+++ b/acts_tests/acts_contrib/test_utils/wifi/wifi_constants.py
@@ -93,11 +93,6 @@
 AP_AUX = "aux_AP"
 SSID = "SSID"
 
-# cnss_diag property related constants
-DEVICES_USING_LEGACY_PROP = ["sailfish", "marlin", "walleye", "taimen", "muskie"]
-CNSS_DIAG_PROP = "persist.vendor.sys.cnss.diag_txt"
-LEGACY_CNSS_DIAG_PROP = "persist.sys.cnss.diag_txt"
-
 # Delay before registering the match callback.
 NETWORK_REQUEST_CB_REGISTER_DELAY_SEC = 2
 
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 d9ed9c0..9ead7de 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
@@ -56,9 +56,6 @@
 
 DEFAULT_PING_ADDR = "https://www.google.com/robots.txt"
 
-CNSS_DIAG_CONFIG_PATH = "/data/vendor/wifi/cnss_diag/"
-CNSS_DIAG_CONFIG_FILE = "cnss_diag.conf"
-
 ROAMING_ATTN = {
     "AP1_on_AP2_off": [0, 0, 95, 95],
     "AP1_off_AP2_on": [95, 95, 0, 0],
@@ -2602,73 +2599,63 @@
     asserts.fail("Did not find MAC = %s in packet sniffer."
                  "for device %s" % (mac, ad.serial))
 
-
-def start_cnss_diags(ads, cnss_diag_file, pixel_models):
+def start_all_wlan_logs(ads):
     for ad in ads:
-        start_cnss_diag(ad, cnss_diag_file, pixel_models)
+        start_wlan_logs(ad)
 
-
-def start_cnss_diag(ad, cnss_diag_file, pixel_models):
-    """Start cnss_diag to record extra wifi logs
+def start_wlan_logs(ad):
+    """Start Pixel Logger to record extra wifi logs
 
     Args:
         ad: android device object.
-        cnss_diag_file: cnss diag config file to push to device.
-        pixel_models: pixel devices.
     """
-    if ad.model not in pixel_models:
-        ad.log.info("Device not supported to collect pixel logger")
+    if not ad.adb.shell("pm list package | grep com.android.pixellogger"):
+        ad.log.info("Device doesn't have Pixel Logger")
         return
-    if ad.model in wifi_constants.DEVICES_USING_LEGACY_PROP:
-        prop = wifi_constants.LEGACY_CNSS_DIAG_PROP
-    else:
-        prop = wifi_constants.CNSS_DIAG_PROP
-    if ad.adb.getprop(prop) != 'true':
-        if not int(
-                ad.adb.shell("ls -l %s%s | wc -l" %
-                             (CNSS_DIAG_CONFIG_PATH, CNSS_DIAG_CONFIG_FILE))):
-            ad.adb.push("%s %s" % (cnss_diag_file, CNSS_DIAG_CONFIG_PATH))
-        ad.adb.shell(
-            "find /data/vendor/wifi/cnss_diag/wlan_logs/ -type f -delete",
+
+    ad.adb.shell(
+            "find /sdcard/Android/data/com.android.pixellogger/files/logs"
+            "/wlan_logs/ -type f -delete",
             ignore_status=True)
-        ad.adb.shell("setprop %s true" % prop, ignore_status=True)
-
-
-def stop_cnss_diags(ads, pixel_models):
-    for ad in ads:
-        stop_cnss_diag(ad, pixel_models)
-
-
-def stop_cnss_diag(ad, pixel_models):
-    """Stops cnss_diag
-
-    Args:
-        ad: android device object.
-        pixel_models: pixel devices.
-    """
-    if ad.model not in pixel_models:
-        ad.log.info("Device not supported to collect pixel logger")
-        return
-    if ad.model in wifi_constants.DEVICES_USING_LEGACY_PROP:
-        prop = wifi_constants.LEGACY_CNSS_DIAG_PROP
+    if ad.file_exists("/vendor/bin/cnss_diag"):
+        ad.adb.shell("am startservice -a com.android.pixellogger.service"
+                ".logging.LoggingService.ACTION_START_LOGGING "
+                "-e intent_logger cnss_diag", ignore_status=True)
     else:
-        prop = wifi_constants.CNSS_DIAG_PROP
-    ad.adb.shell("setprop %s false" % prop, ignore_status=True)
+        ad.adb.shell("am startservice -a com.android.pixellogger.service"
+                ".logging.LoggingService.ACTION_START_LOGGING "
+                "-e intent_logger wlan_logs", ignore_status=True)
 
+def stop_all_wlan_logs(ads):
+    for ad in ads:
+        stop_wlan_logs(ad)
+    ad.log.info("Wait 30s for the createion of zip file for wlan logs")
+    time.sleep(30)
 
-def get_cnss_diag_log(ad):
-    """Pulls the cnss_diag logs in the wlan_logs dir
+def stop_wlan_logs(ad):
+    """Stops Pixel Logger
+
     Args:
         ad: android device object.
     """
-    logs = ad.get_file_names("/data/vendor/wifi/cnss_diag/wlan_logs/")
+    if not ad.adb.shell("pm list package | grep com.android.pixellogger"):
+        return
+
+    ad.adb.shell("am startservice -a com.android.pixellogger.service.logging"
+            ".LoggingService.ACTION_STOP_LOGGING", ignore_status=True)
+
+def get_wlan_logs(ad):
+    """Pull logs from Pixel Logger folder
+    Args:
+        ad: android device object.
+    """
+    logs = ad.get_file_names("/sdcard/Android/data/com.android.pixellogger/files/logs/wlan_logs")
     if logs:
-        ad.log.info("Pulling cnss_diag logs %s", logs)
-        log_path = os.path.join(ad.device_log_path, "CNSS_DIAG_%s" % ad.serial)
+        ad.log.info("Pulling Pixel Logger logs %s", logs)
+        log_path = os.path.join(ad.device_log_path, "WLAN_LOGS_%s" % ad.serial)
         os.makedirs(log_path, exist_ok=True)
         ad.pull_files(logs, log_path)
 
-
 LinkProbeResult = namedtuple(
     'LinkProbeResult',
     ('is_success', 'stdout', 'elapsed_time', 'failure_reason'))
diff --git a/acts_tests/tests/google/wifi/WifiBridgedApTest.py b/acts_tests/tests/google/wifi/WifiBridgedApTest.py
index 34a7d32..b00ddae 100644
--- a/acts_tests/tests/google/wifi/WifiBridgedApTest.py
+++ b/acts_tests/tests/google/wifi/WifiBridgedApTest.py
@@ -63,7 +63,7 @@
             raise signals.TestAbortClass("Legacy phone is not supported")
 
         req_params = ["dbs_supported_models"]
-        opt_param = ["cnss_diag_file", "pixel_models"]
+        opt_param = []
 
         self.unpack_userparams(
             req_param_names=req_params, opt_param_names=opt_param)
diff --git a/acts_tests/tests/google/wifi/WifiCountrySoftApAcsTest.py b/acts_tests/tests/google/wifi/WifiCountrySoftApAcsTest.py
index 0f7dd3f..fe80116 100644
--- a/acts_tests/tests/google/wifi/WifiCountrySoftApAcsTest.py
+++ b/acts_tests/tests/google/wifi/WifiCountrySoftApAcsTest.py
@@ -55,7 +55,7 @@
             self.openwrt.verify_wifi_status(timeout=60)
 
         req_params = []
-        opt_param = ["cnss_diag_file", "pixel_models"]
+        opt_param = []
 
         self.unpack_userparams(
             req_param_names=req_params, opt_param_names=opt_param)
diff --git a/acts_tests/tests/google/wifi/WifiWpa2PersonalTest.py b/acts_tests/tests/google/wifi/WifiWpa2PersonalTest.py
index 65b8235..062e66c 100644
--- a/acts_tests/tests/google/wifi/WifiWpa2PersonalTest.py
+++ b/acts_tests/tests/google/wifi/WifiWpa2PersonalTest.py
@@ -43,7 +43,7 @@
     super().setup_class()
     self.dut = self.android_devices[0]
     req_params = ["roaming_attn"]
-    opt_params = ["pixel_models", "cnss_diag_file"]
+    opt_params = []
     self.unpack_userparams(req_params, opt_params)
 
   def setup_test(self):
diff --git a/acts_tests/tests/google/wifi/WifiWpaPersonalTest.py b/acts_tests/tests/google/wifi/WifiWpaPersonalTest.py
index ad8856a..8d1bade 100644
--- a/acts_tests/tests/google/wifi/WifiWpaPersonalTest.py
+++ b/acts_tests/tests/google/wifi/WifiWpaPersonalTest.py
@@ -45,7 +45,7 @@
       self.configure_openwrt_ap_and_start(wpa1_network=True)
 
     req_params = ["OpenWrtAP", "roaming_attn"]
-    opt_params = ["pixel_models", "cnss_diag_file"]
+    opt_params = []
     self.unpack_userparams(req_params, opt_params)
     self.wpa_psk_2g = self.wpa1_networks[0]["2g"]
     self.wpa_psk_5g = self.wpa1_networks[0]["5g"]