bm: Exit loop to check for BCL after 10 tries
battery_mitigation may be kept in forever loop to read sysfs node. This makes sure that the loop is exited after 10 tries. Bug: 275028861 Test: Local boot up and ensure battery_mitigation comes up Change-Id: I02936f4426519b2c9fbc776cdb2614fdeba872c0 Signed-off-by: George Lee <geolee@google.com>
This commit is contained in:
parent
833ae34288
commit
6c25d5a7fd
@ -19,6 +19,8 @@
|
||||
#include <battery_mitigation/BatteryMitigation.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
#define COUNT_LIMIT 10
|
||||
|
||||
using android::hardware::google::pixel::BatteryMitigation;
|
||||
using android::hardware::google::pixel::MitigationConfig;
|
||||
|
||||
@ -94,7 +96,7 @@ int main(int /*argc*/, char ** /*argv*/) {
|
||||
bool isBatteryMitigationReady = false;
|
||||
std::string ready_str;
|
||||
int val = 0;
|
||||
while (!isBatteryMitigationReady) {
|
||||
for (int i = 0; i < COUNT_LIMIT; i++) {
|
||||
if (!android::base::ReadFileToString(kReadyFilePath, &ready_str)) {
|
||||
continue;
|
||||
}
|
||||
@ -104,9 +106,12 @@ int main(int /*argc*/, char ** /*argv*/) {
|
||||
}
|
||||
if (val == 1) {
|
||||
isBatteryMitigationReady = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
android::base::SetProperty(kReadyProperty, "1");
|
||||
if (isBatteryMitigationReady) {
|
||||
android::base::SetProperty(kReadyProperty, "1");
|
||||
}
|
||||
while (true) {
|
||||
pause();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user