summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaggie White <maggiewhite@google.com>2019-05-29 15:48:31 -0700
committerMaggie White <maggiewhite@google.com>2019-06-05 18:31:17 +0000
commitdd72b6ed6744ae34093015a56b6f1600872208a6 (patch)
tree2835fed2edd5b53892fedb8316573f5c0691198e
parent8d5c9526f93c01fe6f542589497af8d580307761 (diff)
downloadpixel-dd72b6ed6744ae34093015a56b6f1600872208a6.tar.gz
pixelstats: Clear charge stats after reporting them
Clears charge stats after reporting them by writing '0' to the sysfs file. Bug: 120801632 Test: Ran manual discharge + charge and observed statsd logs Change-Id: I9c5f92dd93869a2be99413495808c6965da69a54 Signed-off-by: Maggie White <maggiewhite@google.com>
-rw-r--r--pixelstats/UeventListener.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/pixelstats/UeventListener.cpp b/pixelstats/UeventListener.cpp
index 312a8e5d..4614293c 100644
--- a/pixelstats/UeventListener.cpp
+++ b/pixelstats/UeventListener.cpp
@@ -32,6 +32,7 @@
using android::sp;
using android::base::ReadFileToString;
+using android::base::WriteStringToFile;
using android::frameworks::stats::V1_0::HardwareFailed;
using android::frameworks::stats::V1_0::IStats;
using android::frameworks::stats::V1_0::UsbPortOverheatEvent;
@@ -231,6 +232,10 @@ void UeventListener::ReportChargeMetricsEvent(const char *driver) {
return;
}
+ if (!WriteStringToFile(kChargeMetricsPath.c_str(), std::to_string(0))) {
+ ALOGE("Couldn't clear %s", kChargeMetricsPath.c_str());
+ }
+
sp<IStats> stats_client = IStats::tryGetService();
if (!stats_client) {
ALOGE("Couldn't connect to IStats service");