summaryrefslogtreecommitdiffstats
path: root/recovery_main.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-04-23 20:46:25 +0200
committerTao Bao <tbao@google.com>2019-04-28 21:14:16 +0200
commit75321ade8733317bfe7bf0b1850c94b055c8a1c1 (patch)
treeb0e3acf9305aec92ab4f388b6948caeccb05a8f7 /recovery_main.cpp
parentminadbd: Support `adb reboot` under sideload/rescue modes. (diff)
downloadandroid_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar.gz
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar.bz2
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar.lz
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar.xz
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.tar.zst
android_bootable_recovery-75321ade8733317bfe7bf0b1850c94b055c8a1c1.zip
Diffstat (limited to '')
-rw-r--r--recovery_main.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/recovery_main.cpp b/recovery_main.cpp
index 18abff765..de8ac1f42 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -155,9 +155,11 @@ static std::vector<std::string> get_args(const int argc, char** const argv) {
}
// Finally, if no arguments were specified, check whether we should boot
- // into fastboot.
+ // into fastboot or rescue mode.
if (args.size() == 1 && boot_command == "boot-fastboot") {
args.emplace_back("--fastboot");
+ } else if (args.size() == 1 && boot_command == "boot-rescue") {
+ args.emplace_back("--rescue");
}
return args;
@@ -470,6 +472,7 @@ int main(int argc, char** argv) {
switch (ret) {
case Device::SHUTDOWN:
ui->Print("Shutting down...\n");
+ // TODO: Move all the reboots to reboot(), which should conditionally set quiescent flag.
android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown,");
break;
@@ -478,11 +481,32 @@ int main(int argc, char** argv) {
android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,bootloader");
break;
- case Device::REBOOT_RESCUE:
- ui->Print("Rebooting to rescue...\n");
- android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,rescue");
+ case Device::REBOOT_FASTBOOT:
+ ui->Print("Rebooting to recovery/fastboot...\n");
+ android::base::SetProperty(ANDROID_RB_PROPERTY, "reboot,fastboot");
break;
+ case Device::REBOOT_RECOVERY:
+ ui->Print("Rebooting to recovery...\n");
+ reboot("reboot,recovery");
+ break;
+
+ case Device::REBOOT_RESCUE: {
+ // Not using `reboot("reboot,rescue")`, as it requires matching support in kernel and/or
+ // bootloader.
+ bootloader_message boot = {};
+ strlcpy(boot.command, "boot-rescue", sizeof(boot.command));
+ std::string err;
+ if (!write_bootloader_message(boot, &err)) {
+ LOG(ERROR) << "Failed to write bootloader message: " << err;
+ // Stay under recovery on failure.
+ continue;
+ }
+ ui->Print("Rebooting to recovery/rescue...\n");
+ reboot("reboot,recovery");
+ break;
+ }
+
case Device::ENTER_FASTBOOT:
if (logical_partitions_mapped()) {
ui->Print("Partitions may be mounted - rebooting to enter fastboot.");