Merge "CtsStatsdHostTestCases--android.cts.statsd.metadata.MetadataTests#testConfigTtl-pass" into sc-v2-dev
diff --git a/framework/Android.bp b/framework/Android.bp
index 3c7597c..a1f33d4 100644
--- a/framework/Android.bp
+++ b/framework/Android.bp
@@ -77,6 +77,7 @@
     impl_library_visibility: [
         "//frameworks/base/apex/statsd/framework/test:__subpackages__",
         "//packages/modules/StatsD/framework/test:__subpackages__",
+        "//packages/modules/StatsD/service:__subpackages__",
     ],
 
     apex_available: [
diff --git a/service/Android.bp b/service/Android.bp
index da8db91..a0d281d 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -29,7 +29,9 @@
     sdk_version: "system_server_current",
     libs: [
         "framework-annotations-lib",
-        "framework-statsd",
+        // Use the implementation library directly.
+        // TODO(b/204183608): Remove when no longer necessary.
+        "framework-statsd.impl",
     ],
     static_libs: [
         "modules-utils-build",
diff --git a/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java b/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
index f2df530..69e626c 100644
--- a/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
+++ b/tests/src/android/cts/statsd/alert/AnomalyDetectionTests.java
@@ -36,7 +36,7 @@
 import com.android.os.AtomsProto.AnomalyDetected;
 import com.android.os.AtomsProto.AppBreadcrumbReported;
 import com.android.os.AtomsProto.Atom;
-import com.android.os.AtomsProto.KernelWakelock;
+import com.android.os.AtomsProto.CpuActiveTime;
 import com.android.os.StatsLog.EventMetricData;
 import com.android.tradefed.log.LogUtil.CLog;
 import java.util.List;
@@ -370,9 +370,10 @@
 
     // Test that anomaly detection for pulled metrics work.
     public void testPulledAnomalyDetection() throws Exception {
-        final int ATOM_ID = Atom.KERNEL_WAKELOCK_FIELD_NUMBER;  // A pulled atom
-        final int SLICE_BY_FIELD = KernelWakelock.NAME_FIELD_NUMBER;
-        final int VALUE_FIELD = KernelWakelock.VERSION_FIELD_NUMBER;  // Something that will be > 0.
+        final int ATOM_ID = Atom.CPU_ACTIVE_TIME_FIELD_NUMBER; // A pulled atom
+        final int SLICE_BY_FIELD = CpuActiveTime.UID_FIELD_NUMBER;
+        final int VALUE_FIELD =
+                CpuActiveTime.TIME_MILLIS_FIELD_NUMBER; // Something that will be > 0.
         final int ATOM_MATCHER_ID = 300;
 
         StatsdConfig.Builder config = getBaseConfig(10, 20, 0 /* threshold: value > 0 */)
diff --git a/tests/src/android/cts/statsd/atom/AtomTestCase.java b/tests/src/android/cts/statsd/atom/AtomTestCase.java
index 5f3d902..0380294 100644
--- a/tests/src/android/cts/statsd/atom/AtomTestCase.java
+++ b/tests/src/android/cts/statsd/atom/AtomTestCase.java
@@ -17,7 +17,6 @@
 
 import static android.cts.statsd.atom.DeviceAtomTestCase.DEVICE_SIDE_TEST_APK;
 import static android.cts.statsd.atom.DeviceAtomTestCase.DEVICE_SIDE_TEST_PACKAGE;
-
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth.assertWithMessage;
 
@@ -26,7 +25,6 @@
 import android.service.battery.BatteryServiceDumpProto;
 import android.service.batterystats.BatteryStatsServiceDumpProto;
 import android.service.procstats.ProcessStatsServiceDumpProto;
-
 import com.android.annotations.Nullable;
 import com.android.internal.os.StatsdConfigProto.AtomMatcher;
 import com.android.internal.os.StatsdConfigProto.EventMetric;
@@ -44,32 +42,30 @@
 import com.android.os.AtomsProto.ProcessStatsPackageProto;
 import com.android.os.AtomsProto.ProcessStatsProto;
 import com.android.os.AtomsProto.ProcessStatsStateProto;
+import com.android.os.StatsLog;
 import com.android.os.StatsLog.ConfigMetricsReport;
 import com.android.os.StatsLog.ConfigMetricsReportList;
+import com.android.os.StatsLog.CountMetricData;
 import com.android.os.StatsLog.DurationMetricData;
 import com.android.os.StatsLog.EventMetricData;
 import com.android.os.StatsLog.GaugeBucketInfo;
 import com.android.os.StatsLog.GaugeMetricData;
-import com.android.os.StatsLog.CountMetricData;
 import com.android.os.StatsLog.StatsLogReport;
+import com.android.os.StatsLog.StatsLogReport.GaugeMetricDataWrapper;
 import com.android.os.StatsLog.ValueMetricData;
 import com.android.tradefed.device.DeviceNotAvailableException;
 import com.android.tradefed.log.LogUtil;
 import com.android.tradefed.util.CommandResult;
 import com.android.tradefed.util.CommandStatus;
-
+import com.android.tradefed.util.Pair;
 import com.google.common.collect.Range;
 import com.google.common.io.Files;
 import com.google.protobuf.ByteString;
-
-import perfetto.protos.PerfettoConfig.DataSourceConfig;
-import perfetto.protos.PerfettoConfig.FtraceConfig;
-import perfetto.protos.PerfettoConfig.TraceConfig;
-
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
@@ -84,6 +80,9 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import perfetto.protos.PerfettoConfig.DataSourceConfig;
+import perfetto.protos.PerfettoConfig.FtraceConfig;
+import perfetto.protos.PerfettoConfig.TraceConfig;
 
 /**
  * Base class for testing Statsd atoms.
@@ -335,7 +334,14 @@
 
         List<EventMetricData> data = new ArrayList<>();
         for (StatsLogReport metric : report.getMetricsList()) {
-            data.addAll(metric.getEventMetrics().getDataList());
+          for (EventMetricData metricData :
+               metric.getEventMetrics().getDataList()) {
+            if (metricData.hasAtom()) {
+              data.add(metricData);
+            } else {
+              data.addAll(backfillAggregatedAtomsInEventMetric(metricData));
+            }
+          }
         }
         data.sort(Comparator.comparing(EventMetricData::getElapsedTimestampNanos));
 
@@ -363,11 +369,15 @@
                 report.getMetrics(0).getGaugeMetrics().getDataList()) {
             assertThat(gaugeMetricData.getBucketInfoCount()).isEqualTo(1);
             GaugeBucketInfo bucketInfo = gaugeMetricData.getBucketInfo(0);
-            for (Atom atom : bucketInfo.getAtomList()) {
-                data.add(atom);
+            if (bucketInfo.getAtomCount() != 0) {
+                for (Atom atom : bucketInfo.getAtomList()) {
+                    data.add(atom);
+                }
+            } else {
+                data.addAll(backFillGaugeBucketAtoms(bucketInfo.getAggregatedAtomInfoList()));
             }
             if (checkTimestampTruncated) {
-                for (long timestampNs: bucketInfo.getElapsedTimestampNanosList()) {
+                for (long timestampNs : bucketInfo.getElapsedTimestampNanosList()) {
                     assertTimestampIsTruncated(timestampNs);
                 }
             }
@@ -380,6 +390,55 @@
         return data;
     }
 
+    private List<Atom> backFillGaugeBucketAtoms(
+            List<StatsLog.AggregatedAtomInfo> atomInfoList) {
+        List<Pair<Atom, Long>> atomTimestamp = new ArrayList<>();
+        for (StatsLog.AggregatedAtomInfo atomInfo : atomInfoList) {
+            for (long timestampNs : atomInfo.getElapsedTimestampNanosList()) {
+                atomTimestamp.add(Pair.create(atomInfo.getAtom(), timestampNs));
+            }
+        }
+        atomTimestamp.sort(Comparator.comparing(o -> o.second));
+        return atomTimestamp.stream().map(p -> p.first).collect(Collectors.toList());
+    }
+
+    protected GaugeMetricDataWrapper backfillGaugeMetricData(GaugeMetricDataWrapper dataWrapper) {
+        GaugeMetricDataWrapper.Builder dataWrapperBuilder = dataWrapper.toBuilder();
+        List<GaugeMetricData> backfilledMetricData = new ArrayList<>();
+        for (GaugeMetricData gaugeMetricData : dataWrapperBuilder.getDataList()) {
+            GaugeMetricData.Builder gaugeMetricDataBuilder = gaugeMetricData.toBuilder();
+            List<GaugeBucketInfo> backfilledBuckets = new ArrayList<>();
+            for (GaugeBucketInfo bucketInfo : gaugeMetricData.getBucketInfoList()) {
+                backfilledBuckets.add(backfillGaugeBucket(bucketInfo.toBuilder()));
+            }
+            gaugeMetricDataBuilder.clearBucketInfo();
+            gaugeMetricDataBuilder.addAllBucketInfo(backfilledBuckets);
+            backfilledMetricData.add(gaugeMetricDataBuilder.build());
+        }
+        dataWrapperBuilder.clearData();
+        dataWrapperBuilder.addAllData(backfilledMetricData);
+        return dataWrapperBuilder.build();
+    }
+
+    private GaugeBucketInfo backfillGaugeBucket(GaugeBucketInfo.Builder bucketInfoBuilder) {
+        if (bucketInfoBuilder.getAtomCount() != 0) {
+            return bucketInfoBuilder.build();
+        }
+        List<Pair<Atom, Long>> atomTimestampData = new ArrayList<>();
+        for (StatsLog.AggregatedAtomInfo atomInfo : bucketInfoBuilder.getAggregatedAtomInfoList()) {
+            for (long timestampNs : atomInfo.getElapsedTimestampNanosList()) {
+                atomTimestampData.add(Pair.create(atomInfo.getAtom(), timestampNs));
+            }
+        }
+        atomTimestampData.sort(Comparator.comparing(o -> o.second));
+        bucketInfoBuilder.clearAggregatedAtomInfo();
+        for (Pair<Atom, Long> atomTimestamp : atomTimestampData) {
+            bucketInfoBuilder.addAtom(atomTimestamp.first);
+            bucketInfoBuilder.addElapsedTimestampNanos(atomTimestamp.second);
+        }
+        return bucketInfoBuilder.build();
+    }
+
     /**
      * Gets the statsd report and extract duration metric data.
      * Note that this also deletes that report from statsd.
@@ -1184,4 +1243,20 @@
         assertWithMessage("Timestamp is not truncated")
                 .that(timestampNs % fiveMinutesInNs).isEqualTo(0);
     }
+
+    protected List<EventMetricData> backfillAggregatedAtomsInEventMetric(
+            EventMetricData metricData) {
+      if (!metricData.hasAggregatedAtomInfo()) {
+        return Collections.singletonList(metricData);
+      }
+      List<EventMetricData> data = new ArrayList<>();
+      StatsLog.AggregatedAtomInfo atomInfo = metricData.getAggregatedAtomInfo();
+      for (long timestamp : atomInfo.getElapsedTimestampNanosList()) {
+        data.add(EventMetricData.newBuilder()
+                     .setAtom(atomInfo.getAtom())
+                     .setElapsedTimestampNanos(timestamp)
+                     .build());
+      }
+      return data;
+    }
 }
diff --git a/tests/src/android/cts/statsd/metric/GaugeMetricsTests.java b/tests/src/android/cts/statsd/metric/GaugeMetricsTests.java
index 2280e13..db6a818 100644
--- a/tests/src/android/cts/statsd/metric/GaugeMetricsTests.java
+++ b/tests/src/android/cts/statsd/metric/GaugeMetricsTests.java
@@ -122,6 +122,7 @@
       assertThat(metricReport.getMetricId()).isEqualTo(MetricsUtils.GAUGE_METRIC_ID);
       assertThat(metricReport.hasGaugeMetrics()).isTrue();
       StatsLogReport.GaugeMetricDataWrapper gaugeData = metricReport.getGaugeMetrics();
+      gaugeData = backfillGaugeMetricData(gaugeData);
       assertThat(gaugeData.getDataCount()).isEqualTo(1);
 
       int bucketCount = gaugeData.getData(0).getBucketInfoCount();
@@ -320,6 +321,7 @@
         assertThat(metricReport.getIsActive()).isFalse();
 
         StatsLogReport.GaugeMetricDataWrapper gaugeData = metricReport.getGaugeMetrics();
+        gaugeData = backfillGaugeMetricData(gaugeData);
         assertThat(gaugeData.getDataCount()).isEqualTo(1);
         assertThat(gaugeData.getData(0).getBucketInfoCount()).isEqualTo(2);
 
diff --git a/tests/src/android/cts/statsd/metric/MetricActivationTests.java b/tests/src/android/cts/statsd/metric/MetricActivationTests.java
index 339970a..25fa031 100644
--- a/tests/src/android/cts/statsd/metric/MetricActivationTests.java
+++ b/tests/src/android/cts/statsd/metric/MetricActivationTests.java
@@ -31,9 +31,11 @@
 import com.android.os.AtomsProto.Atom;
 import com.android.os.StatsLog.ConfigMetricsReport;
 import com.android.os.StatsLog.ConfigMetricsReportList;
+import com.android.os.StatsLog.EventMetricData;
 import com.android.os.StatsLog.StatsLogReport;
 import com.android.tradefed.log.LogUtil;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -557,9 +559,13 @@
         assertThat(metricReport.hasEventMetrics()).isEqualTo(dataCount > 0);
 
         StatsLogReport.EventMetricDataWrapper eventData = metricReport.getEventMetrics();
-        assertThat(eventData.getDataCount()).isEqualTo(dataCount);
-        for (int i = 0; i < eventData.getDataCount(); i++) {
-            AppBreadcrumbReported atom = eventData.getData(i).getAtom().getAppBreadcrumbReported();
+        List<EventMetricData> eventMetricDataList = new ArrayList<>();
+        for (EventMetricData eventMetricData : eventData.getDataList()) {
+            eventMetricDataList.addAll(backfillAggregatedAtomsInEventMetric(eventMetricData));
+        }
+        assertThat(eventMetricDataList).hasSize(dataCount);
+        for (EventMetricData eventMetricData : eventMetricDataList) {
+            AppBreadcrumbReported atom = eventMetricData.getAtom().getAppBreadcrumbReported();
             assertThat(atom.getLabel()).isEqualTo(metricMatcherLabel);
         }
     }
diff --git a/tests/src/android/cts/statsd/validation/BatteryStatsValidationTests.java b/tests/src/android/cts/statsd/validation/BatteryStatsValidationTests.java
deleted file mode 100644
index 125a32a..0000000
--- a/tests/src/android/cts/statsd/validation/BatteryStatsValidationTests.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-package android.cts.statsd.validation;
-
-import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
-
-import android.cts.statsd.atom.DeviceAtomTestCase;
-import android.os.BatteryStatsProto;
-import android.os.UidProto;
-import android.os.UidProto.Package;
-import android.os.UidProto.Package.Service;
-
-import com.android.internal.os.StatsdConfigProto.StatsdConfig;
-import com.android.os.AtomsProto.Atom;
-import com.android.os.AtomsProto.DeviceCalculatedPowerBlameUid;
-import com.android.os.StatsLog.DimensionsValue;
-import com.android.os.StatsLog.CountMetricData;
-import com.android.tradefed.log.LogUtil;
-import com.android.tradefed.log.LogUtil.CLog;
-
-import java.util.List;
-
-/**
- * Side-by-side comparison between statsd and batterystats.
- */
-public class BatteryStatsValidationTests extends DeviceAtomTestCase {
-
-    private static final String TAG = "Statsd.BatteryStatsValidationTests";
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        resetBatteryStatus();
-        unplugDevice();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        plugInUsb();
-        super.tearDown();
-    }
-
-    /*
-    public void testConnectivityStateChange() throws Exception {
-        if (!hasFeature(FEATURE_WIFI, true)) return;
-        if (!hasFeature(FEATURE_WATCH, false)) return;
-        if (!hasFeature(FEATURE_LEANBACK_ONLY, false)) return;
-        final String fileName = "BATTERYSTATS_CONNECTIVITY_STATE_CHANGE_COUNT.pbtxt";
-        StatsdConfig config = createValidationUtil().getConfig(fileName);
-        LogUtil.CLog.d("Updating the following config:\n" + config.toString());
-        uploadConfig(config);
-
-        Thread.sleep(WAIT_TIME_SHORT);
-
-        turnOnAirplaneMode();
-        turnOffAirplaneMode();
-        // wait for long enough for device to restore connection
-        Thread.sleep(13_000);
-
-        BatteryStatsProto batterystatsProto = getBatteryStatsProto();
-        List<CountMetricData> countMetricData = getCountMetricDataList();
-        assertThat(countMetricData).hasSize(1);
-        assertThat(countMetricData.get(0).getBucketInfoCount()).isEqualTo(1);
-        assertThat(countMetricData.get(0).getBucketInfo(0).getCount()).isAtLeast(2L);
-        assertThat(countMetricData.get(0).getBucketInfo(0).getCount()).isEqualTo(
-                (long) batterystatsProto.getSystem().getMisc().getNumConnectivityChanges());
-    }
-    */
-
-    public void testPowerUse() throws Exception {
-        if (!hasFeature(FEATURE_LEANBACK_ONLY, false)) return;
-        resetBatteryStats();
-        unplugDevice();
-
-        final double ALLOWED_FRACTIONAL_DIFFERENCE = 0.7; // ratio that statsd and bs can differ
-
-        StatsdConfig.Builder config = createConfigBuilder();
-        addGaugeAtomWithDimensions(config, Atom.DEVICE_CALCULATED_POWER_USE_FIELD_NUMBER, null);
-        uploadConfig(config);
-        unplugDevice();
-
-        Thread.sleep(WAIT_TIME_LONG);
-        runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".AtomTests", "testSimpleCpu");
-        Thread.sleep(WAIT_TIME_LONG);
-
-        setAppBreadcrumbPredicate();
-        BatteryStatsProto batterystatsProto = getBatteryStatsProto();
-        Thread.sleep(WAIT_TIME_LONG);
-        List<Atom> atomList = getGaugeMetricDataList();
-
-        // Extract statsd data
-        Atom atom = atomList.get(0);
-        long statsdPowerNas = atom.getDeviceCalculatedPowerUse().getComputedPowerNanoAmpSecs();
-        assertThat(statsdPowerNas).isGreaterThan(0L);
-
-        // Extract BatteryStats data
-        double bsPowerNas = batterystatsProto.getSystem().getPowerUseSummary().getComputedPowerMah()
-                * 1_000_000L * 3600L; /* mAh to nAs */
-        assertThat(bsPowerNas).isGreaterThan(0d);
-
-        assertThat((double) statsdPowerNas)
-                .isGreaterThan(ALLOWED_FRACTIONAL_DIFFERENCE * bsPowerNas);
-        assertThat(bsPowerNas).isGreaterThan(ALLOWED_FRACTIONAL_DIFFERENCE * statsdPowerNas);
-    }
-
-    public void testServiceStartCount() throws Exception {
-        final String fileName = "BATTERYSTATS_SERVICE_START_COUNT.pbtxt";
-        StatsdConfig config = createValidationUtil().getConfig(fileName);
-        LogUtil.CLog.d("Updating the following config:\n" + config.toString());
-        uploadConfig(config);
-
-        Thread.sleep(WAIT_TIME_SHORT);
-
-        runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".AtomTests", "testForegroundService");
-
-        BatteryStatsProto batterystatsProto = getBatteryStatsProto();
-        List<CountMetricData> countMetricData = getCountMetricDataList();
-        assertThat(countMetricData).isNotEmpty();
-        int uid = getUid();
-        long countFromStatsd = 0;
-        for (CountMetricData data : countMetricData) {
-            List<DimensionsValue> dims = data.getDimensionLeafValuesInWhatList();
-            if (dims.get(0).getValueInt() == uid) {
-                assertThat(dims.get(1).getValueStr()).isEqualTo(DEVICE_SIDE_TEST_PACKAGE);
-                assertThat(dims.get(2).getValueStr())
-                        .isEqualTo(DEVICE_SIDE_TEST_FOREGROUND_SERVICE_NAME);
-                countFromStatsd = data.getBucketInfo(0).getCount();
-                assertThat(countFromStatsd).isGreaterThan(0L);
-            }
-        }
-        long countFromBS = 0;
-        for (UidProto uidProto : batterystatsProto.getUidsList()) {
-            if (uidProto.getUid() == uid) {
-                for (Package pkg : uidProto.getPackagesList()) {
-                    if (pkg.getName().equals(DEVICE_SIDE_TEST_PACKAGE)) {
-                        for (Service svc : pkg.getServicesList()) {
-                            if (svc.getName().equals(DEVICE_SIDE_TEST_FOREGROUND_SERVICE_NAME)) {
-                                countFromBS = svc.getStartCount();
-                                assertThat(countFromBS).isGreaterThan(0L);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        assertThat(countFromStatsd).isGreaterThan(0L);
-        assertThat(countFromBS).isGreaterThan(0L);
-        assertThat(countFromBS).isEqualTo(countFromStatsd);
-    }
-
-    public void testServiceLaunchCount() throws Exception {
-        final String fileName = "BATTERYSTATS_SERVICE_LAUNCH_COUNT.pbtxt";
-        StatsdConfig config = createValidationUtil().getConfig(fileName);
-        LogUtil.CLog.d("Updating the following config:\n" + config.toString());
-        uploadConfig(config);
-
-        Thread.sleep(WAIT_TIME_SHORT);
-
-        runDeviceTests(DEVICE_SIDE_TEST_PACKAGE, ".AtomTests", "testForegroundService");
-
-        BatteryStatsProto batterystatsProto = getBatteryStatsProto();
-        List<CountMetricData> countMetricData = getCountMetricDataList();
-        assertThat(countMetricData).isNotEmpty();
-        int uid = getUid();
-        long countFromStatsd = 0;
-        for (CountMetricData data : countMetricData) {
-            List<DimensionsValue> dims = data.getDimensionLeafValuesInWhatList();
-            if (dims.get(0).getValueInt() == uid) {
-                assertThat(dims.get(1).getValueStr()).isEqualTo(DEVICE_SIDE_TEST_PACKAGE);
-                assertThat(dims.get(2).getValueStr())
-                        .isEqualTo(DEVICE_SIDE_TEST_FOREGROUND_SERVICE_NAME);
-                countFromStatsd = data.getBucketInfo(0).getCount();
-                assertThat(countFromStatsd).isGreaterThan(0L);
-            }
-        }
-        long countFromBS = 0;
-        for (UidProto uidProto : batterystatsProto.getUidsList()) {
-            if (uidProto.getUid() == uid) {
-                for (Package pkg : uidProto.getPackagesList()) {
-                    if (pkg.getName().equals(DEVICE_SIDE_TEST_PACKAGE)) {
-                        for (Service svc : pkg.getServicesList()) {
-                            if (svc.getName().equals(DEVICE_SIDE_TEST_FOREGROUND_SERVICE_NAME)) {
-                                countFromBS = svc.getLaunchCount();
-                                assertThat(countFromBS).isGreaterThan(0L);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        assertThat(countFromStatsd).isGreaterThan(0L);
-        assertThat(countFromBS).isGreaterThan(0L);
-        assertThat(countFromBS).isEqualTo(countFromStatsd);
-    }
-}
diff --git a/tests/src/android/cts/statsd/validation/ValidationTests.java b/tests/src/android/cts/statsd/validation/ValidationTests.java
index 90b8fb4..b10ff6d 100644
--- a/tests/src/android/cts/statsd/validation/ValidationTests.java
+++ b/tests/src/android/cts/statsd/validation/ValidationTests.java
@@ -111,8 +111,6 @@
         // Sorted list of events in order in which they occurred.
         List<EventMetricData> data = getEventMetricDataList();
 
-        BatteryStatsProto batterystatsProto = getBatteryStatsProto();
-
         //=================== verify that statsd is correct ===============//
         // Assert that the events happened in the expected order.
         assertStatesOccurred(stateSet, data, WAIT_TIME_SHORT,
@@ -124,18 +122,6 @@
             assertThat(tag).isEqualTo(EXPECTED_TAG);
             assertThat(type).isEqualTo(EXPECTED_LEVEL);
         }
-
-        //=================== verify that batterystats is correct ===============//
-        int uid = getUid();
-        android.os.TimerProto wl =
-                getBatteryStatsPartialWakelock(batterystatsProto, uid, EXPECTED_TAG);
-
-        assertThat(wl).isNotNull();
-        assertThat(wl.getDurationMs()).isGreaterThan(0L);
-        assertThat(wl.getMaxDurationMs()).isIn(Range.closedOpen(400L, 700L));
-        assertThat(wl.getTotalDurationMs()).isIn(Range.closedOpen(400L, 700L));
-
-        setAodState(aodState); // restores AOD to initial state.
     }
 
     @RestrictedBuildTest