battery_mitigation: Fix lastmeal timestamp
Lastmeal.txt may be generated from after device rebooted from IRQ triggering. By applying limit on the time when it generates, lastmeal.txt will not be generated after device rebooted. Bug: 246817058 Test: Trigger brownout and confirm lastmeal.txt has correct timestamp Signed-off-by: George Lee <geolee@google.com> Change-Id: I8b52f44fdc64f5ef74e0059720ed58c845e5bf60
This commit is contained in:
parent
9afa58f656
commit
7f2a1321a2
2 changed files with 102 additions and 16 deletions
|
@ -61,13 +61,31 @@ const struct MitigationConfig::Config cfg = {
|
|||
"voltage_now", "current_now",
|
||||
},
|
||||
.LogFilePath = "/data/vendor/mitigation/thismeal.txt",
|
||||
.TimestampFormat = "%Y-%m-%d %H:%M:%S",
|
||||
};
|
||||
|
||||
const char kReadyFilePath[] = "/sys/devices/virtual/pmic/mitigation/instruction/ready";
|
||||
const char kReadyProperty[] = "vendor.brownout.mitigation.ready";
|
||||
const char kLastMealPath[] = "/data/vendor/mitigation/lastmeal.txt";
|
||||
const char kBRRequestedProperty[] = "vendor.startup_bugreport_requested";
|
||||
const std::regex kTimestampRegex("^\\S+\\s[0-9]+:[0-9]+:[0-9]+\\S+$");
|
||||
|
||||
int main(int /*argc*/, char ** /*argv*/) {
|
||||
auto batteryMitigationStartTime = std::chrono::system_clock::now();
|
||||
bmSp = new BatteryMitigation(cfg);
|
||||
if (!bmSp) {
|
||||
return 0;
|
||||
}
|
||||
bool mitigationLogTimeValid = bmSp->isMitigationLogTimeValid(batteryMitigationStartTime,
|
||||
cfg.LogFilePath,
|
||||
cfg.TimestampFormat,
|
||||
kTimestampRegex);
|
||||
int startupBugreport = android::base::GetIntProperty(kBRRequestedProperty, 0);
|
||||
if (startupBugreport && mitigationLogTimeValid) {
|
||||
std::ifstream src(cfg.LogFilePath, std::ios::in);
|
||||
std::ofstream dst(kLastMealPath, std::ios::out);
|
||||
dst << src.rdbuf();
|
||||
}
|
||||
bool isBatteryMitigationReady = false;
|
||||
std::string ready_str;
|
||||
int val = 0;
|
||||
|
|
|
@ -1,24 +1,92 @@
|
|||
on property:sys.boot_completed=1 && property:ro.boot.bootreason=reboot,ocp,pmic,if
|
||||
copy data/vendor/mitigation/thismeal.txt data/vendor/mitigation/lastmeal.txt
|
||||
chown system system data/vendor/mitigation/lastmeal.txt
|
||||
|
||||
on property:sys.boot_completed=1 && property:ro.boot.bootreason=reboot,uvlo,pmic,if
|
||||
copy data/vendor/mitigation/thismeal.txt data/vendor/mitigation/lastmeal.txt
|
||||
chown system system data/vendor/mitigation/lastmeal.txt
|
||||
|
||||
on property:sys.boot_completed=1 && property:ro.boot.bootreason=reboot,uvlo,pmic,main
|
||||
copy data/vendor/mitigation/thismeal.txt data/vendor/mitigation/lastmeal.txt
|
||||
chown system system data/vendor/mitigation/lastmeal.txt
|
||||
|
||||
on property:sys.boot_completed=1 && property:ro.boot.bootreason=reboot,uvlo,pmic,sub
|
||||
copy data/vendor/mitigation/thismeal.txt data/vendor/mitigation/lastmeal.txt
|
||||
chown system system data/vendor/mitigation/lastmeal.txt
|
||||
|
||||
on property:vendor.thermal.link_ready=1
|
||||
mkdir /data/vendor/mitigation 0755 system system
|
||||
chown system system /data/vendor/mitigation
|
||||
start vendor.battery_mitigation
|
||||
|
||||
on property:ro.boot.bootreason=reboot,uvlo,pmic,if
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,pmic,if
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,uvlo,pmic,main
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,uvlo,pmic,sub
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck1m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck2m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck3m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck4m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck5m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck6m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck7m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck8m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck9m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck10m
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck1s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck2s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck3s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck4s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck5s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck6s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck7s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck8s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck9s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buck10s
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buckds
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buckas
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buckcs
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
on property:ro.boot.bootreason=reboot,ocp,buckbs
|
||||
setprop vendor.startup_bugreport_requested 1
|
||||
|
||||
service vendor.battery_mitigation /vendor/bin/hw/battery_mitigation
|
||||
user system
|
||||
group system
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue