From ed9db0fd73f0368be354a65d7bdc3de5d01bdc88 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Tue, 18 Apr 2017 08:28:26 -0700 Subject: Adding support for quiescent reboot to recovery Bug: 37401320 Test: build and push OTA and hit adb reboot recovery,quiescent. The screen should remain off throughout the upgrade process. (cherry picked from commit 8706a98aa635236a95795f0a0c122bb3e591a50d) Change-Id: I79789a151f6faafda8ecc6198c2182cc2a91da70 --- common.h | 2 ++ recovery.cpp | 26 ++++++++++++++++++++------ ui.cpp | 2 +- updater/install.cpp | 5 ++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/common.h b/common.h index bda793599..62fb1324b 100644 --- a/common.h +++ b/common.h @@ -43,4 +43,6 @@ void ui_print(const char* format, ...); bool is_ro_debuggable(); +bool reboot(const std::string& command); + #endif // RECOVERY_COMMON_H diff --git a/recovery.cpp b/recovery.cpp index b24efa963..173baac16 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -209,6 +209,14 @@ bool is_ro_debuggable() { return android::base::GetBoolProperty("ro.debuggable", false); } +bool reboot(const std::string& command) { + std::string cmd = command; + if (android::base::GetBoolProperty("ro.boot.quiescent", false)) { + cmd += ",quiescent"; + } + return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd); +} + static void redirect_stdio(const char* filename) { int pipefd[2]; if (pipe(pipefd) == -1) { @@ -1449,12 +1457,18 @@ int main(int argc, char **argv) { printf("reason is [%s]\n", reason); Device* device = make_device(); - ui = device->GetUI(); + if (android::base::GetBoolProperty("ro.boot.quiescent", false)) { + printf("Quiescent recovery mode.\n"); + ui = new StubRecoveryUI(); + } else { + ui = device->GetUI(); - if (!ui->Init(locale)) { - printf("Failed to initialize UI, use stub UI instead."); - ui = new StubRecoveryUI(); + if (!ui->Init(locale)) { + printf("Failed to initialize UI, use stub UI instead.\n"); + ui = new StubRecoveryUI(); + } } + // Set background string to "installing security update" for security update, // otherwise set it to "installing system update". ui->SetSystemUpdateText(security_update); @@ -1526,7 +1540,7 @@ int main(int argc, char **argv) { ui->Print("Retry attempt %d\n", retry_count); // Reboot and retry the update - if (!android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,recovery")) { + if (!reboot("reboot,recovery")) { ui->Print("Reboot failed\n"); } else { while (true) { @@ -1623,7 +1637,7 @@ int main(int argc, char **argv) { default: ui->Print("Rebooting...\n"); - android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,"); + reboot("reboot,"); break; } while (true) { diff --git a/ui.cpp b/ui.cpp index 9194ae3df..cad744930 100644 --- a/ui.cpp +++ b/ui.cpp @@ -227,7 +227,7 @@ void RecoveryUI::ProcessKey(int key_code, int updown) { case RecoveryUI::REBOOT: if (reboot_enabled) { - android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,"); + reboot("reboot,"); while (true) { pause(); } } break; diff --git a/updater/install.cpp b/updater/install.cpp index f91f3fc9f..84cf5d6c0 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -890,7 +890,10 @@ Value* RebootNowFn(const char* name, State* state, const std::vector