Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99f99342 authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-21.0' into v1-u

parents 08d620ae 7a3d4953
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -982,6 +982,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;
    {
@@ -998,7 +1000,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) {