Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 882f99a8 authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Migrate pullSystemElapsedRealtime

Test: atest ValueMetricTests
Test: No cts test. Ran adb shell cmd pull-source 10014
Change-Id: I89c673cb2337405dbe1aa4e3a5756bdf9410927a
parent 7f9fe502
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -714,14 +714,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        }
    }

    private void pullSystemElapsedRealtime(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
        StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
        e.writeLong(SystemClock.elapsedRealtime());
        pulledData.add(e);
    }

    // read high watermark for section
    private long readProcStatsHighWaterMark(int section) {
        try {
@@ -1158,11 +1150,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        long wallClockNanos = SystemClock.currentTimeMicro() * 1000L;
        switch (tagId) {

            case StatsLog.SYSTEM_ELAPSED_REALTIME: {
                pullSystemElapsedRealtime(tagId, elapsedNanos, wallClockNanos, ret);
                break;
            }

            case StatsLog.PROC_STATS: {
                pullProcessStats(ProcessStats.REPORT_ALL, tagId, elapsedNanos, wallClockNanos, ret);
                break;
+0 −7
Original line number Diff line number Diff line
@@ -68,13 +68,6 @@ std::map<PullerKey, PullAtomInfo> StatsPullerManager::kAllPullAtomInfo = {
        {{.atomTag = android::util::ON_DEVICE_POWER_MEASUREMENT},
         {.puller = new PowerStatsPuller()}},

        // system_elapsed_realtime
        {{.atomTag = android::util::SYSTEM_ELAPSED_REALTIME},
         {.coolDownNs = NS_PER_SEC,
          .puller = new StatsCompanionServicePuller(android::util::SYSTEM_ELAPSED_REALTIME),
          .pullTimeoutNs = NS_PER_SEC / 2,
         }},

        // remaining_battery_capacity
        {{.atomTag = android::util::REMAINING_BATTERY_CAPACITY},
         {.puller = new ResourceHealthManagerPuller(android::util::REMAINING_BATTERY_CAPACITY)}},
+20 −3
Original line number Diff line number Diff line
@@ -989,12 +989,29 @@ public class StatsPullAtomService extends SystemService {
        return StatsManager.PULL_SUCCESS;
    }

    private static final long NS_PER_SEC = 1000000000;

    private void registerSystemElapsedRealtime() {
        // No op.
        int tagId = StatsLog.SYSTEM_ELAPSED_REALTIME;
        PullAtomMetadata metadata = PullAtomMetadata.newBuilder()
                .setCoolDownNs(NS_PER_SEC)
                .setTimeoutNs(NS_PER_SEC / 2)
                .build();
        mStatsManager.registerPullAtomCallback(
                tagId,
                metadata,
                (atomTag, data) -> pullSystemElapsedRealtime(atomTag, data),
                BackgroundThread.getExecutor()
        );
    }

    private void pullSystemElapsedRealtime() {
        // No op.
    private int pullSystemElapsedRealtime(int atomTag, List<StatsEvent> pulledData) {
        StatsEvent e = StatsEvent.newBuilder()
                .setAtomId(atomTag)
                .writeLong(SystemClock.elapsedRealtime())
                .build();
        pulledData.add(e);
        return StatsManager.PULL_SUCCESS;
    }

    private void registerSystemUptime() {