diff options
Diffstat (limited to 'recovery.cpp')
-rw-r--r-- | recovery.cpp | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/recovery.cpp b/recovery.cpp index c4b36557b..98148af0a 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -44,7 +44,6 @@ #include <android-base/parseint.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> -#include <bootloader_message/bootloader_message.h> #include <cutils/android_reboot.h> #include <cutils/properties.h> #include <log/logger.h> /* Android Log packet format */ @@ -53,6 +52,7 @@ #include <healthd/BatteryMonitor.h> #include "adb_install.h" +#include "bootloader.h" #include "common.h" #include "device.h" #include "error_code.h" @@ -303,13 +303,9 @@ static void redirect_stdio(const char* filename) { // - the contents of COMMAND_FILE (one per line) static void get_args(int *argc, char ***argv) { - bootloader_message boot = {}; - std::string err; - if (!read_bootloader_message(&boot, &err)) { - LOGE("%s\n", err.c_str()); - // If fails, leave a zeroed bootloader_message. - memset(&boot, 0, sizeof(boot)); - } + struct bootloader_message boot; + memset(&boot, 0, sizeof(boot)); + get_bootloader_message(&boot); // this may fail, leaving a zeroed structure stage = strndup(boot.stage, sizeof(boot.stage)); if (boot.command[0] != 0 && boot.command[0] != 255) { @@ -371,20 +367,16 @@ get_args(int *argc, char ***argv) { strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery)); strlcat(boot.recovery, "\n", sizeof(boot.recovery)); } - if (!write_bootloader_message(boot, &err)) { - LOGE("%s\n", err.c_str()); - } + set_bootloader_message(&boot); } static void set_sdcard_update_bootloader_message() { - bootloader_message boot = {}; + struct bootloader_message boot; + memset(&boot, 0, sizeof(boot)); strlcpy(boot.command, "boot-recovery", sizeof(boot.command)); strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery)); - std::string err; - if (!write_bootloader_message(boot, &err)) { - LOGE("%s\n", err.c_str()); - } + set_bootloader_message(&boot); } // Read from kernel log into buffer and write out to file. @@ -545,11 +537,9 @@ finish_recovery(const char *send_intent) { copy_logs(); // Reset to normal system boot so recovery won't cycle indefinitely. - bootloader_message boot = {}; - std::string err; - if (!write_bootloader_message(boot, &err)) { - LOGE("%s\n", err.c_str()); - } + struct bootloader_message boot; + memset(&boot, 0, sizeof(boot)); + set_bootloader_message(&boot); // Remove the command file, so recovery won't repeat indefinitely. if (has_cache) { @@ -926,9 +916,8 @@ static bool check_wipe_package(size_t wipe_package_size) { return false; } std::string wipe_package; - std::string err_str; - if (!read_wipe_package(&wipe_package, wipe_package_size, &err_str)) { - LOGE("Failed to read wipe package: %s\n", err_str.c_str()); + if (!read_wipe_package(wipe_package_size, &wipe_package)) { + LOGE("Failed to read wipe package.\n"); return false; } if (!verify_package(reinterpret_cast<const unsigned char*>(wipe_package.data()), @@ -1380,7 +1369,7 @@ static bool is_battery_ok() { } static void set_retry_bootloader_message(int retry_count, int argc, char** argv) { - bootloader_message boot = {}; + struct bootloader_message boot {}; strlcpy(boot.command, "boot-recovery", sizeof(boot.command)); strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery)); @@ -1399,10 +1388,7 @@ static void set_retry_bootloader_message(int retry_count, int argc, char** argv) snprintf(buffer, sizeof(buffer), "--retry_count=%d\n", retry_count+1); strlcat(boot.recovery, buffer, sizeof(boot.recovery)); } - std::string err; - if (!write_bootloader_message(boot, &err)) { - LOGE("%s\n", err.c_str()); - } + set_bootloader_message(&boot); } static ssize_t logbasename( |