From 542582689d53fc3a1c9d8297e42b7aa92291b7fe Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Wed, 19 Sep 2018 21:14:18 -0700 Subject: [PATCH] Support 'adb reboot fastboot' command conditionally. Devices not supporting logical partitions do not require the command. Bug: 78793464 Test: 'adb reboot fastboot' reboots to bootloader for a device not supporting logical partitions. Change-Id: I0a7b6d4335040e24efbf461e2dd2d56ab1985b7f --- adb/daemon/services.cpp | 4 +++- init/reboot.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/adb/daemon/services.cpp b/adb/daemon/services.cpp index 841769043..2bac48653 100644 --- a/adb/daemon/services.cpp +++ b/adb/daemon/services.cpp @@ -103,7 +103,9 @@ void reboot_service(unique_fd fd, const std::string& arg) { if (reboot_arg.empty()) reboot_arg = "adb"; std::string reboot_string = android::base::StringPrintf("reboot,%s", reboot_arg.c_str()); - if (reboot_arg == "fastboot" && access("/dev/socket/recovery", F_OK) == 0) { + if (reboot_arg == "fastboot" && + android::base::GetBoolProperty("ro.boot.logical_partitions", false) && + access("/dev/socket/recovery", F_OK) == 0) { LOG(INFO) << "Recovery specific reboot fastboot"; /* * The socket is created to allow switching between recovery and diff --git a/init/reboot.cpp b/init/reboot.cpp index 2f88121b7..b84bfd3d6 100644 --- a/init/reboot.cpp +++ b/init/reboot.cpp @@ -464,6 +464,12 @@ bool HandlePowerctlMessage(const std::string& command) { cmd = ANDROID_RB_RESTART2; if (cmd_params.size() >= 2) { reboot_target = cmd_params[1]; + // adb reboot fastboot should boot into bootloader for devices not + // supporting logical partitions. + if (reboot_target == "fastboot" && + !android::base::GetBoolProperty("ro.boot.logical_partitions", false)) { + reboot_target = "bootloader"; + } // When rebooting to the bootloader notify the bootloader writing // also the BCB. if (reboot_target == "bootloader") {