Snap for 11399958 from 586fabb805b517d0b2e7876d30fb3e6df71bd395 to 24Q2-release

Change-Id: Idd63ce2b14118e75c4be66b4d1f93e3a949dfcf2
diff --git a/report/src/com/android/catbox/result/JsonResultReporter.java b/report/src/com/android/catbox/result/JsonResultReporter.java
index 9363f9d..035cc6a 100644
--- a/report/src/com/android/catbox/result/JsonResultReporter.java
+++ b/report/src/com/android/catbox/result/JsonResultReporter.java
@@ -79,6 +79,12 @@
     private Map<String, String> mReportTestNameMap = new HashMap<String, String>();
 
     @Option(
+            name = "exclude-metric-from-test-name",
+            description = "Exclude metric from test name in report.")
+    private Map<String, String> mExcludeMetricTestNameMap = new HashMap<String, String>();
+
+
+    @Option(
             name = "report-all-metrics",
             description = "Report all the generated metrics. Default to 'true'.")
     private boolean mReportAllMetrics = true;
@@ -209,7 +215,7 @@
             writeAllMetrics(reportLog, metrics);
         } else {
             // Write metrics for given keys to the report
-            writeMetricsForGivenKeys(reportLog, metrics);
+            writeMetricsForGivenKeys(reportLog, metrics, streamName);
         }
 
         // Submit Report Log
@@ -237,7 +243,7 @@
 
     /** Write given set of metrics to JSON Report */
     private void writeMetricsForGivenKeys(
-            MetricsReportLog reportLog, Map<String, String> metrics) {
+            MetricsReportLog reportLog, Map<String, String> metrics, String streamName) {
         CLog.logAndDisplay(LogLevel.INFO, "Writing given set of metrics to JSON report.");
         if (mReportMetricKeyMap == null || mReportMetricKeyMap.isEmpty()) {
             CLog.logAndDisplay(
@@ -249,6 +255,10 @@
                 CLog.logAndDisplay(LogLevel.WARN, String.format("%s metric key is missing.", key));
                 continue;
             }
+            if(mExcludeMetricTestNameMap != null && mExcludeMetricTestNameMap.get(key) !=null && mExcludeMetricTestNameMap.get(key).equals(streamName)){
+                CLog.logAndDisplay(LogLevel.WARN, String.format("Excluding %s metric key from %s test.", key, streamName));
+                continue;
+            }
             try {
                 double value = Double.parseDouble(metrics.get(key));
                 reportLog.addValue(
diff --git a/tools/catbox-common/res/config/catbox-performance-base.xml b/tools/catbox-common/res/config/catbox-performance-base.xml
index 1b1bec5..01a0d97 100644
--- a/tools/catbox-common/res/config/catbox-performance-base.xml
+++ b/tools/catbox-common/res/config/catbox-performance-base.xml
@@ -45,6 +45,8 @@
     </target_preparer>
 
     <!-- Enable perfetto host side metric collector -->
-    <include name="perfetto-puller"/>
-
+    <metrics_collector class="com.android.tradefed.device.metric.PerfettoPullerMetricCollector">
+        <option name="collect-on-run-ended-only" value="false" />
+        <option name="pull-pattern-keys" value="perfetto_file_path" />
+    </metrics_collector>
 </configuration>
diff --git a/tools/catbox-common/res/config/catbox-performance-postprocessors.xml b/tools/catbox-common/res/config/catbox-performance-postprocessors.xml
index edbaddf..0fcebad 100644
--- a/tools/catbox-common/res/config/catbox-performance-postprocessors.xml
+++ b/tools/catbox-common/res/config/catbox-performance-postprocessors.xml
@@ -20,4 +20,7 @@
     <option name="test-iteration-separator" value="$" />
     <option name="enable-per-test-log" value="false" />
   </metric_post_processor>
+  <metric_post_processor class="com.android.tradefed.postprocessor.PerfettoGenericPostProcessor">
+    <option name="perfetto-proto-file-prefix" value="metric_perfetto" />
+  </metric_post_processor>
 </configuration>
diff --git a/tools/catbox-common/res/config/perfetto-puller.xml b/tools/catbox-common/res/config/perfetto-puller.xml
deleted file mode 100644
index a29cf72..0000000
--- a/tools/catbox-common/res/config/perfetto-puller.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  ~ Copyright (C) 2023 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-<configuration description="Pull the files from the device and add it to the test logs.">
-    <!-- Pulls the perfetto files from the device and collects the metrics from the trace files -->
-    <metrics_collector class="com.android.tradefed.device.metric.PerfettoPullerMetricCollector" />
-</configuration>
\ No newline at end of file
diff --git a/tools/catbox-tradefed/res/config/catbox-performance-cold-app-start-up-settings.xml b/tools/catbox-tradefed/res/config/catbox-performance-cold-app-start-up-settings.xml
index 21cb686..df05367 100644
--- a/tools/catbox-tradefed/res/config/catbox-performance-cold-app-start-up-settings.xml
+++ b/tools/catbox-tradefed/res/config/catbox-performance-cold-app-start-up-settings.xml
@@ -49,4 +49,4 @@
   <option name="report-test-name-mapping" key="android.platform.test.scenario.settings.OpenAppMicrobenchmark#testOpen" value="settings_app_start_up" />
   <option name="report-all-metrics" value="false" />
   <option name="report-metric-key-mapping" key="cold_startup_com.android.car.settings-median" value="cold_start_up" />
-</configuration>
+</configuration>
\ No newline at end of file