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

Commit 082bea63 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "recovery: fastbootd: retry opening graphics"

parents 78c41b64 30017e78
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include <unordered_map>
#include <vector>

#include <android-base/chrono_utils.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
@@ -881,10 +882,28 @@ bool ScreenRecoveryUI::LoadWipeDataMenuText() {
  return true;
}

static bool InitGraphics() {
  // Timeout is same as init wait for file default of 5 seconds and is arbitrary
  const unsigned timeout = 500;  // 10ms increments
  for (auto retry = timeout; retry > 0; --retry) {
    if (gr_init() == 0) {
      if (retry < timeout) {
        // Log message like init wait for file completion log for consistency.
        LOG(WARNING) << "wait for 'graphics' took " << ((timeout - retry) * 10) << "ms";
      }
      return true;
    }
    std::this_thread::sleep_for(10ms);
  }
  // Log message like init wait for file timeout log for consistency.
  LOG(ERROR) << "timeout wait for 'graphics' took " << (timeout * 10) << "ms";
  return false;
}

bool ScreenRecoveryUI::Init(const std::string& locale) {
  RecoveryUI::Init(locale);

  if (gr_init() == -1) {
  if (!InitGraphics()) {
    return false;
  }