Snap for 4826885 from f14adb8123c9d7aa8b88960c2042f5fc271b65bf to pi-release

Change-Id: Ie3bc7c65d5ebbd499e988ed0dc841faead263bb7
diff --git a/src/com/android/media/tests/Camera2FrameworkStressTest.java b/src/com/android/media/tests/Camera2FrameworkStressTest.java
index a6fb7ad..b275fe2 100644
--- a/src/com/android/media/tests/Camera2FrameworkStressTest.java
+++ b/src/com/android/media/tests/Camera2FrameworkStressTest.java
@@ -20,9 +20,11 @@
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.IFileEntry;
 import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
 import com.android.tradefed.result.ITestInvocationListener;
 import com.android.tradefed.result.TestDescription;
 import com.android.tradefed.util.FileUtil;
+import com.android.tradefed.util.proto.TfMetricProtoUtil;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -90,14 +92,15 @@
         }
 
         @Override
-        public void testEnded(TestDescription test, long endTime, Map<String, String> testMetrics) {
+        public void testEnded(
+                TestDescription test, long endTime, HashMap<String, Metric> testMetrics) {
             if (hasTestRunFatalError()) {
                 CLog.v("The instrumentation result not found. Fall back to get the metrics from a "
                         + "log file. errorMsg: %s", getCollectingListener().getErrorMessage());
             }
 
             // For stress test, parse the metrics from a log file.
-            testMetrics = parseLog(test.getTestName());
+            testMetrics = TfMetricProtoUtil.upgradeConvert(parseLog(test.getTestName()));
             super.testEnded(test, endTime, testMetrics);
         }
 
diff --git a/src/com/android/media/tests/Camera2StressTest.java b/src/com/android/media/tests/Camera2StressTest.java
index b7e88b0..7b770fe 100644
--- a/src/com/android/media/tests/Camera2StressTest.java
+++ b/src/com/android/media/tests/Camera2StressTest.java
@@ -20,6 +20,7 @@
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.device.IFileEntry;
 import com.android.tradefed.log.LogUtil.CLog;
+import com.android.tradefed.metrics.proto.MetricMeasurement.Metric;
 import com.android.tradefed.result.FileInputStreamSource;
 import com.android.tradefed.result.ITestInvocationListener;
 import com.android.tradefed.result.LogDataType;
@@ -75,7 +76,8 @@
         }
 
         @Override
-        public void testEnded(TestDescription test, long endTime, Map<String, String> testMetrics) {
+        public void testEnded(
+                TestDescription test, long endTime, HashMap<String, Metric> testMetrics) {
             if (hasTestRunFatalError()) {
                 CLog.v("The instrumentation result not found. Fall back to get the metrics from a "
                         + "log file. errorMsg: %s", getCollectingListener().getErrorMessage());
@@ -89,8 +91,10 @@
 
             // add testMethod name to the metric
             Map<String, String> namedTestMetrics = new HashMap<>();
-            for (Entry<String, String> entry : testMetrics.entrySet()) {
-                namedTestMetrics.put(test.getTestName() + entry.getKey(), entry.getValue());
+            for (Entry<String, Metric> entry : testMetrics.entrySet()) {
+                namedTestMetrics.put(
+                        test.getTestName() + entry.getKey(),
+                        entry.getValue().getMeasurements().getSingleString());
             }
 
             // parse the iterations metrics from the stress log files
diff --git a/src/com/android/media/tests/CameraTestBase.java b/src/com/android/media/tests/CameraTestBase.java
index f077bbb..8196fa5 100644
--- a/src/com/android/media/tests/CameraTestBase.java
+++ b/src/com/android/media/tests/CameraTestBase.java
@@ -282,11 +282,12 @@
          * @param testMetrics a {@link Map} of the metrics emitted
          */
         @Override
-        public void testEnded(TestDescription test, long endTime, Map<String, String> testMetrics) {
+        public void testEnded(
+                TestDescription test, long endTime, HashMap<String, Metric> testMetrics) {
             super.testEnded(test, endTime, testMetrics);
-            handleMetricsOnTestEnded(test, testMetrics);
+            handleMetricsOnTestEnded(test, TfMetricProtoUtil.compatibleConvert(testMetrics));
             stopDumping(test);
-            mListener.testEnded(test, endTime, TfMetricProtoUtil.upgradeConvert(testMetrics));
+            mListener.testEnded(test, endTime, testMetrics);
         }
 
         @Override