Consolidate the wait in recovery's reboot

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 00c4aba9bf428717fc00e26a03e97401eca76ee8)
This commit is contained in:
Tianjie Xu
2020-03-13 14:25:02 -07:00
committed by Tianjie
parent 342e53d045
commit e8ca1b8634
5 changed files with 8 additions and 14 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ class MemMapping {
// Reboots the device into the specified target, by additionally handling quiescent reboot mode. // Reboots the device into the specified target, by additionally handling quiescent reboot mode.
// All unknown targets reboot into Android. // All unknown targets reboot into Android.
bool Reboot(std::string_view target); [[noreturn]] void Reboot(std::string_view target);
// Triggers a shutdown. // Triggers a shutdown.
bool Shutdown(std::string_view target); bool Shutdown(std::string_view target);
+6 -2
View File
@@ -219,14 +219,18 @@ MemMapping::~MemMapping() {
ranges_.clear(); ranges_.clear();
} }
bool Reboot(std::string_view target) { void Reboot(std::string_view target) {
std::string cmd = "reboot," + std::string(target); std::string cmd = "reboot," + std::string(target);
// Honor the quiescent mode if applicable. // Honor the quiescent mode if applicable.
if (target != "bootloader" && target != "fastboot" && if (target != "bootloader" && target != "fastboot" &&
android::base::GetBoolProperty("ro.boot.quiescent", false)) { android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent"; 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) { bool Shutdown(std::string_view target) {
+1 -7
View File
@@ -781,13 +781,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
ui->Print("Retry attempt %d\n", retry_count); ui->Print("Retry attempt %d\n", retry_count);
// Reboot back into recovery to retry the update. // Reboot back into recovery to retry the update.
if (!Reboot("recovery")) { Reboot("recovery");
ui->Print("Reboot failed\n");
} else {
while (true) {
pause();
}
}
} }
// If this is an eng or userdebug build, then automatically // If this is an eng or userdebug build, then automatically
// turn the text display on if the script fails so the error // turn the text display on if the script fails so the error
-3
View File
@@ -375,9 +375,6 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
case RecoveryUI::REBOOT: case RecoveryUI::REBOOT:
if (reboot_enabled) { if (reboot_enabled) {
Reboot("userrequested,recovery,ui"); Reboot("userrequested,recovery,ui");
while (true) {
pause();
}
} }
break; break;
-1
View File
@@ -733,7 +733,6 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique
Reboot(property); Reboot(property);
sleep(5);
return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name); return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name);
} }