Snap tm-dev to android13-tests-dev am: 9513b9d0b1

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/StatsD/+/20514288

Change-Id: I6680b6ef0778b706d352f1972c04edfb11338158
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/tests/src/android/cts/statsd/atom/AtomTestCase.java b/tests/src/android/cts/statsd/atom/AtomTestCase.java
index 1f33c20..83ca2a2 100644
--- a/tests/src/android/cts/statsd/atom/AtomTestCase.java
+++ b/tests/src/android/cts/statsd/atom/AtomTestCase.java
@@ -125,6 +125,8 @@
     public static final String FEATURE_INCREMENTAL_DELIVERY =
             "android.software.incremental_delivery";
 
+    public static final int SHELL_UID = 2000;
+
     // Telephony phone types
     public static final int PHONE_TYPE_GSM = 1;
     public static final int PHONE_TYPE_CDMA = 2;
@@ -300,13 +302,14 @@
         getDevice().pushFile(configFile, remotePath);
         getDevice().executeShellCommand(
                 String.join(" ", "cat", remotePath, "|", UPDATE_CONFIG_CMD,
-                        String.valueOf(CONFIG_ID)));
+                        String.valueOf(SHELL_UID), String.valueOf(CONFIG_ID)));
         getDevice().executeShellCommand("rm " + remotePath);
     }
 
     protected void removeConfig(long configId) throws Exception {
         getDevice().executeShellCommand(
-                String.join(" ", REMOVE_CONFIG_CMD, String.valueOf(configId)));
+                String.join(" ", REMOVE_CONFIG_CMD,
+                        String.valueOf(SHELL_UID), String.valueOf(configId)));
     }
 
     /** Gets the statsd report and sorts it. Note that this also deletes that report from statsd. */
@@ -521,8 +524,8 @@
     protected ConfigMetricsReportList getReportList() throws Exception {
         try {
             ConfigMetricsReportList reportList = getDump(ConfigMetricsReportList.parser(),
-                    String.join(" ", DUMP_REPORT_CMD, String.valueOf(CONFIG_ID),
-                            "--include_current_bucket", "--proto"));
+                    String.join(" ", DUMP_REPORT_CMD, String.valueOf(SHELL_UID),
+                            String.valueOf(CONFIG_ID), "--include_current_bucket", "--proto"));
             return reportList;
         } catch (com.google.protobuf.InvalidProtocolBufferException e) {
             LogUtil.CLog.e("Failed to fetch and parse the statsd output report. "
@@ -872,21 +875,9 @@
         data.subList(lastStateIdx+1, data.size()).clear();
     }
 
-    /** Returns the UID of the host, which should always either be SHELL (2000) or ROOT (0). */
+    /** Returns the UID of the host, which should always either be SHELL (2000). */
     protected int getHostUid() throws DeviceNotAvailableException {
-        String strUid = "";
-        try {
-            strUid = getDevice().executeShellCommand("id -u");
-            return Integer.parseInt(strUid.trim());
-        } catch (NumberFormatException e) {
-            LogUtil.CLog.e("Failed to get host's uid via shell command. Found " + strUid);
-            // Fall back to alternative method...
-            if (getDevice().isAdbRoot()) {
-                return 0; // ROOT
-            } else {
-                return 2000; // SHELL
-            }
-        }
+        return SHELL_UID;
     }
 
     protected String getProperty(String prop) throws Exception {
@@ -990,7 +981,7 @@
 
     public void doAppBreadcrumbReported(int label, int state) throws Exception {
         getDevice().executeShellCommand(String.format(
-                "cmd stats log-app-breadcrumb %d %d", label, state));
+                "cmd stats log-app-breadcrumb %d %d %d", SHELL_UID, label, state));
     }
 
     protected void setBatteryLevel(int level) throws Exception {
diff --git a/tests/src/android/cts/statsd/atom/DeviceAtomTestCase.java b/tests/src/android/cts/statsd/atom/DeviceAtomTestCase.java
index dacbac9..99df717 100644
--- a/tests/src/android/cts/statsd/atom/DeviceAtomTestCase.java
+++ b/tests/src/android/cts/statsd/atom/DeviceAtomTestCase.java
@@ -302,9 +302,9 @@
 
     protected void rebootDeviceAndWaitUntilReady() throws Exception {
         rebootDevice();
-        // Wait for 2 mins.
+        // Wait for 3 mins.
         assertWithMessage("Device failed to boot")
-            .that(getDevice().waitForBootComplete(120_000)).isTrue();
+            .that(getDevice().waitForBootComplete(180_000)).isTrue();
         assertWithMessage("Stats service failed to start")
             .that(waitForStatsServiceStart(60_000)).isTrue();
         Thread.sleep(2_000);
diff --git a/tests/src/android/cts/statsd/metric/ValueMetricsTests.java b/tests/src/android/cts/statsd/metric/ValueMetricsTests.java
index 0cf5bbb..d0370e1 100644
--- a/tests/src/android/cts/statsd/metric/ValueMetricsTests.java
+++ b/tests/src/android/cts/statsd/metric/ValueMetricsTests.java
@@ -319,11 +319,6 @@
     LogUtil.CLog.d("Got the following value metric data: " + metricReport.toString());
     assertThat(metricReport.getMetricId()).isEqualTo(MetricsUtils.VALUE_METRIC_ID);
     assertThat(metricReport.getValueMetrics().getDataList()).isEmpty();
-    // Bucket is skipped because metric is not activated.
-    assertThat(metricReport.getValueMetrics().getSkippedList()).isNotEmpty();
-    assertThat(metricReport.getValueMetrics().getSkipped(0).getDropEventList()).isNotEmpty();
-    assertThat(metricReport.getValueMetrics().getSkipped(0).getDropEvent(0).getDropReason())
-            .isEqualTo(BucketDropReason.NO_DATA);
   }
 
     public void testValueMetricWithConditionAndActivation() throws Exception {