Add UeventListener to pixelstats in gs101
Bug: 171793497
Test: Ensure that uevent listener reports data to statsd
Change-Id: I9e90f8483298934a78320f37dbf5eb1ac38e8f97
diff --git a/conf/init.gs101.rc b/conf/init.gs101.rc
index 27a3c7b..4545189 100644
--- a/conf/init.gs101.rc
+++ b/conf/init.gs101.rc
@@ -186,6 +186,9 @@
# Loading common kernel modules in background
start insmod_sh_common
+ # Charge stats (write 0)
+ chown system system /sys/class/power_supply/battery/charge_stats
+
# start watchdogd
start watchdogd
diff --git a/pixelstats/service.cpp b/pixelstats/service.cpp
index 33d885f..5c381eb 100644
--- a/pixelstats/service.cpp
+++ b/pixelstats/service.cpp
@@ -17,10 +17,13 @@
#define LOG_TAG "pixelstats"
#include <android-base/logging.h>
+#include <thread>
#include <pixelstats/SysfsCollector.h>
+#include <pixelstats/UeventListener.h>
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 = {
@@ -38,6 +41,10 @@
int main() {
LOG(INFO) << "starting PixelStats";
+ UeventListener ueventListener("");
+ std::thread listenThread(&UeventListener::ListenForever, &ueventListener);
+ listenThread.detach();
+
SysfsCollector collector(sysfs_paths);
collector.collect(); // This blocks forever.