Battery Mitigation: Use Brownout Reason

Brownout Reason replaces startup_bugreport_requested.  Battery
Mitigation needs to be updated.

Bug: 237287659
Test: Ensure lastmeal.txt is properly generated.
Merged-In: If80954497a75da0d41c8d75126e42eaae1330003
Change-Id: Ie06da78b7b9435d134c99627de53d6292def58b1
Signed-off-by: George Lee <geolee@google.com>
This commit is contained in:
George Lee 2022-12-01 16:14:35 -08:00
parent 4a94625bce
commit 2a2ebf1d78

View file

@ -67,7 +67,7 @@ const struct MitigationConfig::Config cfg = {
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 char kBRRequestedProperty[] = "vendor.brownout_reason";
const std::regex kTimestampRegex("^\\S+\\s[0-9]+:[0-9]+:[0-9]+\\S+$");
int main(int /*argc*/, char ** /*argv*/) {
@ -80,8 +80,8 @@ int main(int /*argc*/, char ** /*argv*/) {
cfg.LogFilePath,
cfg.TimestampFormat,
kTimestampRegex);
int startupBugreport = android::base::GetIntProperty(kBRRequestedProperty, 0);
if (startupBugreport && mitigationLogTimeValid) {
std::string reason = android::base::GetProperty(kBRRequestedProperty, "");
if (!reason.empty() && mitigationLogTimeValid) {
std::ifstream src(cfg.LogFilePath, std::ios::in);
std::ofstream dst(kLastMealPath, std::ios::out);
dst << src.rdbuf();