diff options
author | Prasanna Prapancham <prapancham@google.com> | 2022-07-07 20:22:28 +0000 |
---|---|---|
committer | Prasanna Prapancham <prapancham@google.com> | 2022-07-22 00:21:22 +0000 |
commit | 8a9d4c99427670636e41bcfb99b47da2ef1cd61b (patch) | |
tree | 4c41eed7637999178f539796a3958696fecc90a1 /pixelstats/ChargeStatsReporter.cpp | |
parent | ae8c3b6306f439a4421591455f61d98e90827abf (diff) |
Add user space logic to read charge_stats vtier from google_charger
Test: Tested with tablet with dock
1. Put on dock
2. Remove from dock and monitor logcat | grep pixelstats
Bug: 218802317
Signed-off-by: Prasanna Prapancham <prapancham@google.com>
Change-Id: I34994e9471c91b89f9f76fdc509e173a0fb8b9b8
Diffstat (limited to 'pixelstats/ChargeStatsReporter.cpp')
-rw-r--r-- | pixelstats/ChargeStatsReporter.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/pixelstats/ChargeStatsReporter.cpp b/pixelstats/ChargeStatsReporter.cpp index 8bc2720..9892668 100644 --- a/pixelstats/ChargeStatsReporter.cpp +++ b/pixelstats/ChargeStatsReporter.cpp @@ -201,11 +201,12 @@ void ChargeStatsReporter::ReportVoltageTierStats(const std::shared_ptr<IStats> & void ChargeStatsReporter::checkAndReport(const std::shared_ptr<IStats> &stats_client, const std::string &path) { std::string file_contents, line, wfile_contents, wline_at, wline_ac, pca_file_contents, - pca_line, thermal_file_contents; + pca_line, thermal_file_contents, gcharger_file_contents; std::istringstream ss; bool has_wireless = wireless_charge_stats_.CheckWirelessContentsAndAck(&wfile_contents); bool has_pca = pca_charge_stats_.CheckPcaContentsAndAck(&pca_file_contents); - bool has_thermal = checkThermalContentsAndAck(&thermal_file_contents); + bool has_thermal = checkContentsAndAck(&thermal_file_contents, kThermalChargeMetricsPath); + bool has_gcharger = checkContentsAndAck(&gcharger_file_contents, kGChargerMetricsPath); if (!ReadFileToString(path.c_str(), &file_contents)) { ALOGE("Unable to read %s - %s", path.c_str(), strerror(errno)); @@ -255,15 +256,23 @@ void ChargeStatsReporter::checkAndReport(const std::shared_ptr<IStats> &stats_cl ReportVoltageTierStats(stats_client, line.c_str()); } } + + if (has_gcharger) { + std::istringstream wss; + wss.str(gcharger_file_contents); + while (std::getline(wss, line)) { + ReportVoltageTierStats(stats_client, line.c_str()); + } + } } -bool ChargeStatsReporter::checkThermalContentsAndAck(std::string *file_contents) { - if (!ReadFileToString(kThermalChargeMetricsPath.c_str(), file_contents)) { +bool ChargeStatsReporter::checkContentsAndAck(std::string *file_contents, const std::string &path) { + if (!ReadFileToString(path.c_str(), file_contents)) { return false; } - if (!WriteStringToFile("0", kThermalChargeMetricsPath.c_str())) { - ALOGE("Couldn't clear %s - %s", kThermalChargeMetricsPath.c_str(), strerror(errno)); + if (!WriteStringToFile("0", path.c_str())) { + ALOGE("Couldn't clear %s - %s", path.c_str(), strerror(errno)); return false; } return true; |