Skip to content

Commit

Permalink
Consolidate the wait in recovery's reboot
Browse files Browse the repository at this point in the history
After a reboot function call, we should always wait for it to finish
without executing other instructions.

Bug: 151110322
Test: build
Change-Id: I1dda291a0835ff96df7eaf42eba1a38267a3beeb
(cherry picked from commit 00c4aba)
  • Loading branch information
Tianjie Xu committed Mar 18, 2020
1 parent 342e53d commit e8ca1b8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion otautil/include/otautil/sysutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MemMapping {

// Reboots the device into the specified target, by additionally handling quiescent reboot mode.
// All unknown targets reboot into Android.
bool Reboot(std::string_view target);
[[noreturn]] void Reboot(std::string_view target);

// Triggers a shutdown.
bool Shutdown(std::string_view target);
Expand Down
8 changes: 6 additions & 2 deletions otautil/sysutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,18 @@ MemMapping::~MemMapping() {
ranges_.clear();
}

bool Reboot(std::string_view target) {
void Reboot(std::string_view target) {
std::string cmd = "reboot," + std::string(target);
// Honor the quiescent mode if applicable.
if (target != "bootloader" && target != "fastboot" &&
android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
if (!android::base::SetProperty(ANDROID_RB_PROPERTY, cmd)) {
LOG(FATAL) << "Reboot failed";
}

while (true) pause();
}

bool Shutdown(std::string_view target) {
Expand Down
8 changes: 1 addition & 7 deletions recovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
ui->Print("Retry attempt %d\n", retry_count);

// Reboot back into recovery to retry the update.
if (!Reboot("recovery")) {
ui->Print("Reboot failed\n");
} else {
while (true) {
pause();
}
}
Reboot("recovery");
}
// If this is an eng or userdebug build, then automatically
// turn the text display on if the script fails so the error
Expand Down
3 changes: 0 additions & 3 deletions recovery_ui/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,6 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
case RecoveryUI::REBOOT:
if (reboot_enabled) {
Reboot("userrequested,recovery,ui");
while (true) {
pause();
}
}
break;

Expand Down
1 change: 0 additions & 1 deletion updater/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,6 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique

Reboot(property);

sleep(5);
return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name);
}

Expand Down

0 comments on commit e8ca1b8

Please sign in to comment.