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

Commit ccfcdf00 authored by Jeffrey Huang's avatar Jeffrey Huang
Browse files

Migrate pullCpuActiveTime

Test: No Cts Test. Ran adb shell cmd stats pull-source 10016
Change-Id: I7d959c939ada8b6b8782cbfde1e524d95803a20e
parent a9899304
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -776,17 +776,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
        });
    }

    private void pullKernelUidCpuActiveTime(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
        mCpuUidActiveTimeReader.readAbsolute((uid, cpuActiveTimesMs) -> {
            StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos);
            e.writeInt(uid);
            e.writeLong((long) cpuActiveTimesMs);
            pulledData.add(e);
        });
    }

    private void pullWifiActivityInfo(
            int tagId, long elapsedNanos, long wallClockNanos,
            List<StatsLogEventWrapper> pulledData) {
@@ -2085,11 +2074,6 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
                break;
            }

            case StatsLog.CPU_ACTIVE_TIME: {
                pullKernelUidCpuActiveTime(tagId, elapsedNanos, wallClockNanos, ret);
                break;
            }

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

        // cpu_active_time
        // the throttling is 3sec, handled in
        // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
        {{.atomTag = android::util::CPU_ACTIVE_TIME},
         {.additiveFields = {2},
          .puller = new StatsCompanionServicePuller(android::util::CPU_ACTIVE_TIME)}},

        // cpu_cluster_time
        // the throttling is 3sec, handled in
        // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
+24 −3
Original line number Diff line number Diff line
@@ -636,6 +636,8 @@ public class StatsPullAtomService extends SystemService {
            new KernelCpuUidUserSysTimeReader(false);
    private KernelCpuUidFreqTimeReader mCpuUidFreqTimeReader =
            new KernelCpuUidFreqTimeReader(false);
    private KernelCpuUidActiveTimeReader mCpuUidActiveTimeReader =
            new KernelCpuUidActiveTimeReader(false);

    private void registerCpuTimePerFreq() {
        int tagId = StatsLog.CPU_TIME_PER_FREQ;
@@ -728,11 +730,30 @@ public class StatsPullAtomService extends SystemService {
    }

    private void registerCpuActiveTime() {
        // No op.
        // the throttling is 3sec, handled in
        // frameworks/base/core/java/com/android/internal/os/KernelCpuProcReader
        int tagId = StatsLog.CPU_ACTIVE_TIME;
        PullAtomMetadata metadata = PullAtomMetadata.newBuilder()
                .setAdditiveFields(new int[] {2})
                .build();
        mStatsManager.registerPullAtomCallback(
                tagId,
                metadata,
                (atomTag, data) -> pullCpuActiveTime(atomTag, data),
                Executors.newSingleThreadExecutor()
        );
    }

    private void pullCpuActiveTime() {
        // No op.
    private int pullCpuActiveTime(int atomTag, List<StatsEvent> pulledData) {
        mCpuUidActiveTimeReader.readAbsolute((uid, cpuActiveTimesMs) -> {
            StatsEvent e = StatsEvent.newBuilder()
                    .setAtomId(atomTag)
                    .writeInt(uid)
                    .writeLong(cpuActiveTimesMs)
                    .build();
            pulledData.add(e);
        });
        return StatsManager.PULL_SUCCESS;
    }

    private void registerCpuClusterTime() {