From 9f4ac2c565cbc1146792c6ddc3717bb6aa094341 Mon Sep 17 00:00:00 2001 From: Craig Dooley Date: Wed, 25 May 2022 21:21:04 +0000 Subject: [PATCH] Use libaoc to provide consistent timestamp calculations Bug: 233923713 Change-Id: Iacd541815f40adef879e05d9bd8ded056e9a760d --- powerstats/Android.bp | 1 + powerstats/AocStateResidencyDataProvider.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/powerstats/Android.bp b/powerstats/Android.bp index 74935c7..2dbf8db 100644 --- a/powerstats/Android.bp +++ b/powerstats/Android.bp @@ -20,5 +20,6 @@ cc_library { shared_libs: [ "android.hardware.power.stats-impl.pixel", + "libaoc", ], } diff --git a/powerstats/AocStateResidencyDataProvider.cpp b/powerstats/AocStateResidencyDataProvider.cpp index c64496d..6ab54db 100644 --- a/powerstats/AocStateResidencyDataProvider.cpp +++ b/powerstats/AocStateResidencyDataProvider.cpp @@ -18,6 +18,8 @@ #include +#include + namespace aidl { namespace android { namespace hardware { @@ -26,11 +28,8 @@ namespace stats { AocStateResidencyDataProvider::AocStateResidencyDataProvider(std::vector> ids, std::vector> states) { - // AoC stats are reported in ticks of 244.140625ns. The transform - // function converts ticks to milliseconds. - // 1000000 / 244.140625 = 4096. - static const uint64_t AOC_CLK = 4096; - std::function aocTickToMs = [](uint64_t a) { return a / AOC_CLK; }; + // AoC stats are reported in ticks + std::function aocTickToMs = [](uint64_t a) { return aoc_ticks_to_nanoseconds(a) / 1000000; }; GenericStateResidencyDataProvider::StateResidencyConfig config = { .entryCountSupported = true, .entryCountPrefix = "Counter:",