Loading recovery_ui/screen_ui.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -962,6 +962,8 @@ void ScreenRecoveryUI::BattMonitorThreadLoop() { auto batt_monitor = std::make_unique<android::BatteryMonitor>(); batt_monitor->init(config.get()); bool is_first_call = true; while (!batt_monitor_thread_stopped_) { bool redraw = false; { Loading @@ -978,7 +980,21 @@ void ScreenRecoveryUI::BattMonitorThreadLoop() { } android::BatteryProperty prop; android::status_t status = batt_monitor->getProperty(android::BATTERY_PROP_CAPACITY, &prop); android::base::Timer t; android::status_t status; while (t.duration() < 5s) { status = batt_monitor->getProperty(android::BATTERY_PROP_CAPACITY, &prop); if (status == android::OK || !is_first_call) { break; } LOG(WARNING) << "Trying again for reinitializing battery info"; if (redraw) update_screen_locked(); batt_monitor->init(config.get()); std::this_thread::sleep_for(100ms); } is_first_call = false; // If we can't read battery percentage, it may be a device without battery. In this // situation, use 100 as a fake battery percentage. if (status != android::OK) { Loading Loading
recovery_ui/screen_ui.cpp +17 −1 Original line number Diff line number Diff line Loading @@ -962,6 +962,8 @@ void ScreenRecoveryUI::BattMonitorThreadLoop() { auto batt_monitor = std::make_unique<android::BatteryMonitor>(); batt_monitor->init(config.get()); bool is_first_call = true; while (!batt_monitor_thread_stopped_) { bool redraw = false; { Loading @@ -978,7 +980,21 @@ void ScreenRecoveryUI::BattMonitorThreadLoop() { } android::BatteryProperty prop; android::status_t status = batt_monitor->getProperty(android::BATTERY_PROP_CAPACITY, &prop); android::base::Timer t; android::status_t status; while (t.duration() < 5s) { status = batt_monitor->getProperty(android::BATTERY_PROP_CAPACITY, &prop); if (status == android::OK || !is_first_call) { break; } LOG(WARNING) << "Trying again for reinitializing battery info"; if (redraw) update_screen_locked(); batt_monitor->init(config.get()); std::this_thread::sleep_for(100ms); } is_first_call = false; // If we can't read battery percentage, it may be a device without battery. In this // situation, use 100 as a fake battery percentage. if (status != android::OK) { Loading