From 38ef8d70821d18607ddf508a2da6117559597db6 Mon Sep 17 00:00:00 2001 From: Ajay Dudani Date: Tue, 25 Jul 2017 19:20:13 -0700 Subject: [PATCH] dumpstate: Add battery cycle count to bugreport Bug: 63841211 Test: Verify cycle count metrics are present in bugreport Change-Id: I7c6a3af3ef687c99f88de5ee1c4d7433b618772e --- dumpstate/DumpstateDevice.cpp | 1 + init.hardware.rc | 4 ++++ sepolicy/vendor/hal_dumpstate_impl.te | 1 + 3 files changed, 6 insertions(+) diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp index 63db6fc8..1200ca41 100755 --- a/dumpstate/DumpstateDevice.cpp +++ b/dumpstate/DumpstateDevice.cpp @@ -207,6 +207,7 @@ Return DumpstateDevice::dumpstateBoard(const hidl_handle& handle) { RunCommandToFd(fd, "FP LOGS", {"qsee_logger", "-d"}); } + RunCommandToFd(fd, "Battery cycle count", {"/vendor/bin/sh", "-c", "for f in 1 2 3 4 5 6 7 8 ; do echo $f > /sys/class/power_supply/bms/cycle_count_id; count=`cat /sys/class/power_supply/bms/cycle_count`; echo \"$f: $count\"; done"}); return Void(); }; diff --git a/init.hardware.rc b/init.hardware.rc index 5472fd91..563e1f14 100644 --- a/init.hardware.rc +++ b/init.hardware.rc @@ -437,6 +437,10 @@ on boot # Wifi firmware reload path chown wifi wifi /sys/module/wlan/parameters/fwpath + # Allow system to write to cycle_count_id to iterate and get stats + chown system system /sys/class/power_supply/bms/cycle_count_id + chmod 0660 /sys/class/power_supply/bms/cycle_count_id + # default country code setprop ro.boot.wificountrycode 00 diff --git a/sepolicy/vendor/hal_dumpstate_impl.te b/sepolicy/vendor/hal_dumpstate_impl.te index 994046b8..6d37925c 100644 --- a/sepolicy/vendor/hal_dumpstate_impl.te +++ b/sepolicy/vendor/hal_dumpstate_impl.te @@ -23,6 +23,7 @@ userdebug_or_eng(` allow hal_dumpstate_impl debugfs_ipc:file r_file_perms; allow hal_dumpstate_impl sysfs_usb_device:dir r_dir_perms; allow hal_dumpstate_impl sysfs_usb_device:file r_file_perms; + allow hal_dumpstate_impl sysfs_msm_subsys:file write; set_prop(hal_dumpstate_impl, modem_diag_prop) ')