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 <battery_mitigation/BatteryMitigation.h>
|
||||||
#include <android/binder_process.h>
|
#include <android/binder_process.h>
|
||||||
|
|
||||||
|
#define COUNT_LIMIT 10
|
||||||
|
|
||||||
using android::hardware::google::pixel::BatteryMitigation;
|
using android::hardware::google::pixel::BatteryMitigation;
|
||||||
using android::hardware::google::pixel::MitigationConfig;
|
using android::hardware::google::pixel::MitigationConfig;
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ int main(int /*argc*/, char ** /*argv*/) {
|
|||||||
bool isBatteryMitigationReady = false;
|
bool isBatteryMitigationReady = false;
|
||||||
std::string ready_str;
|
std::string ready_str;
|
||||||
int val = 0;
|
int val = 0;
|
||||||
while (!isBatteryMitigationReady) {
|
for (int i = 0; i < COUNT_LIMIT; i++) {
|
||||||
if (!android::base::ReadFileToString(kReadyFilePath, &ready_str)) {
|
if (!android::base::ReadFileToString(kReadyFilePath, &ready_str)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -104,9 +106,12 @@ int main(int /*argc*/, char ** /*argv*/) {
|
|||||||
}
|
}
|
||||||
if (val == 1) {
|
if (val == 1) {
|
||||||
isBatteryMitigationReady = true;
|
isBatteryMitigationReady = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
android::base::SetProperty(kReadyProperty, "1");
|
if (isBatteryMitigationReady) {
|
||||||
|
android::base::SetProperty(kReadyProperty, "1");
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
pause();
|
pause();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user