From 40e0ec918e728911c0dc3fb3f76d5c0de83dd702 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 5 Jan 2017 18:01:01 -0800 Subject: [PATCH] adb: Fix the 'adb reboot sideload' for A/B devices. We used to write the command file (/cache/recovery/command) to trigger the sideload mode. A/B devices don't support that (may not have /cache paritition). This CL switches to using libbootloader_message which writes the command to BCB (bootloader control block) instead. Test: "adb root && adb reboot sideload" reboots sailfish into recovery sideload mode. Change-Id: I158fd7cbcfa9a5d0609f1f684a2d03675217628f --- adb/Android.mk | 1 + adb/services.cpp | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/adb/Android.mk b/adb/Android.mk index 16ed9911c..fab8c8780 100644 --- a/adb/Android.mk +++ b/adb/Android.mk @@ -330,6 +330,7 @@ LOCAL_STRIP_MODULE := keep_symbols LOCAL_STATIC_LIBRARIES := \ libadbd \ libbase \ + libbootloader_message \ libfs_mgr \ libfec \ libfec_rs \ diff --git a/adb/services.cpp b/adb/services.cpp index 2fbc15a26..df1b134bf 100644 --- a/adb/services.cpp +++ b/adb/services.cpp @@ -39,6 +39,7 @@ #if !ADB_HOST #include +#include #include #include #endif @@ -133,17 +134,12 @@ static bool reboot_service_impl(int fd, const char* arg) { return false; } - const char* const recovery_dir = "/cache/recovery"; - const char* const command_file = "/cache/recovery/command"; - // Ensure /cache/recovery exists. - if (adb_mkdir(recovery_dir, 0770) == -1 && errno != EEXIST) { - D("Failed to create directory '%s': %s", recovery_dir, strerror(errno)); - return false; - } - - bool write_status = android::base::WriteStringToFile( - auto_reboot ? "--sideload_auto_reboot" : "--sideload", command_file); - if (!write_status) { + const std::vector options = { + auto_reboot ? "--sideload_auto_reboot" : "--sideload" + }; + std::string err; + if (!write_bootloader_message(options, &err)) { + D("Failed to set bootloader message: %s", err.c_str()); return false; }