From 8101fbcec04d1301ac4fc552817afbc1e338252f Mon Sep 17 00:00:00 2001 From: Denny cy Lee Date: Tue, 18 May 2021 14:50:01 +0800 Subject: [PATCH] Pixestat: add battery info Bug: 171947164 Test: manually, no read fail found Change-Id: I35bbca1aec39e6fb6133386b96efd727a9f74099 Signed-off-by: Denny cy Lee --- pixelstats/service.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/pixelstats/service.cpp b/pixelstats/service.cpp index 2bc19b85..cc96789c 100644 --- a/pixelstats/service.cpp +++ b/pixelstats/service.cpp @@ -17,35 +17,37 @@ #define LOG_TAG "pixelstats" #include -#include - #include #include +#include + using android::hardware::google::pixel::SysfsCollector; using android::hardware::google::pixel::UeventListener; #define UFSHC_PATH(filename) "/dev/sys/block/bootdevice/" #filename const struct SysfsCollector::SysfsPaths sysfs_paths = { - .SlowioReadCntPath = UFSHC_PATH(slowio_read_cnt), - .SlowioWriteCntPath = UFSHC_PATH(slowio_write_cnt), - .SlowioUnmapCntPath = UFSHC_PATH(slowio_unmap_cnt), - .SlowioSyncCntPath = UFSHC_PATH(slowio_sync_cnt), - .UFSLifetimeA = UFSHC_PATH(health_descriptor/life_time_estimation_a), - .UFSLifetimeB = UFSHC_PATH(health_descriptor/life_time_estimation_b), - .UFSLifetimeC = UFSHC_PATH(health_descriptor/life_time_estimation_c), - .UFSHostResetPath = UFSHC_PATH(err_stats/dev_reset_count), - .F2fsStatsPath = "/sys/fs/f2fs/", - .ImpedancePath = "/sys/devices/platform/audiometrics/speaker_impedance", - .CodecPath = "/sys/devices/platform/audiometrics/codec_state", -}; + .SlowioReadCntPath = UFSHC_PATH(slowio_read_cnt), + .SlowioWriteCntPath = UFSHC_PATH(slowio_write_cnt), + .SlowioUnmapCntPath = UFSHC_PATH(slowio_unmap_cnt), + .SlowioSyncCntPath = UFSHC_PATH(slowio_sync_cnt), + .CycleCountBinsPath = "/sys/class/power_supply/battery/cycle_counts", + .UFSLifetimeA = UFSHC_PATH(health_descriptor/life_time_estimation_a), + .UFSLifetimeB = UFSHC_PATH(health_descriptor/life_time_estimation_b), + .UFSLifetimeC = UFSHC_PATH(health_descriptor/life_time_estimation_c), + .UFSHostResetPath = UFSHC_PATH(err_stats/dev_reset_count), + .F2fsStatsPath = "/sys/fs/f2fs/", + .ImpedancePath = "/sys/devices/platform/audiometrics/speaker_impedance", + .CodecPath = "/sys/devices/platform/audiometrics/codec_state", + .EEPROMPath = "/dev/battery_history"}; const char *const kAudioUevent = "/devices/virtual/amcs/amcs"; +const char *const kSSOCDetailsPath = "/sys/class/power_supply/battery/ssoc_details"; int main() { LOG(INFO) << "starting PixelStats"; - UeventListener ueventListener(kAudioUevent); + UeventListener ueventListener(kAudioUevent, kSSOCDetailsPath); std::thread listenThread(&UeventListener::ListenForever, &ueventListener); listenThread.detach();