summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp44
1 files changed, 29 insertions, 15 deletions
diff --git a/recovery.cpp b/recovery.cpp
index e9ded7178..c0f5a386a 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -45,6 +45,7 @@
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
+#include <bootloader_message/bootloader_message.h>
#include <cutils/android_reboot.h>
#include <cutils/properties.h>
#include <healthd/BatteryMonitor.h>
@@ -54,7 +55,6 @@
#include <selinux/selinux.h>
#include "adb_install.h"
-#include "bootloader.h"
#include "common.h"
#include "device.h"
#include "error_code.h"
@@ -300,9 +300,13 @@ static void redirect_stdio(const char* filename) {
// - the contents of COMMAND_FILE (one per line)
static void
get_args(int *argc, char ***argv) {
- struct bootloader_message boot;
- memset(&boot, 0, sizeof(boot));
- get_bootloader_message(&boot); // this may fail, leaving a zeroed structure
+ 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));
+ }
stage = strndup(boot.stage, sizeof(boot.stage));
if (boot.command[0] != 0 && boot.command[0] != 255) {
@@ -364,16 +368,20 @@ get_args(int *argc, char ***argv) {
strlcat(boot.recovery, (*argv)[i], sizeof(boot.recovery));
strlcat(boot.recovery, "\n", sizeof(boot.recovery));
}
- set_bootloader_message(&boot);
+ if (!write_bootloader_message(boot, &err)) {
+ LOGE("%s\n", err.c_str());
+ }
}
static void
set_sdcard_update_bootloader_message() {
- struct bootloader_message boot;
- memset(&boot, 0, sizeof(boot));
+ bootloader_message boot = {};
strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
- set_bootloader_message(&boot);
+ std::string err;
+ if (!write_bootloader_message(boot, &err)) {
+ LOGE("%s\n", err.c_str());
+ }
}
// Read from kernel log into buffer and write out to file.
@@ -522,9 +530,11 @@ finish_recovery() {
copy_logs();
// Reset to normal system boot so recovery won't cycle indefinitely.
- struct bootloader_message boot;
- memset(&boot, 0, sizeof(boot));
- set_bootloader_message(&boot);
+ bootloader_message boot = {};
+ std::string err;
+ if (!write_bootloader_message(boot, &err)) {
+ LOGE("%s\n", err.c_str());
+ }
// Remove the command file, so recovery won't repeat indefinitely.
if (has_cache) {
@@ -901,8 +911,9 @@ static bool check_wipe_package(size_t wipe_package_size) {
return false;
}
std::string wipe_package;
- if (!read_wipe_package(wipe_package_size, &wipe_package)) {
- LOGE("Failed to read wipe package.\n");
+ 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());
return false;
}
if (!verify_package(reinterpret_cast<const unsigned char*>(wipe_package.data()),
@@ -1354,7 +1365,7 @@ static bool is_battery_ok() {
}
static void set_retry_bootloader_message(int retry_count, int argc, char** argv) {
- struct bootloader_message boot {};
+ bootloader_message boot = {};
strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
@@ -1373,7 +1384,10 @@ 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));
}
- set_bootloader_message(&boot);
+ std::string err;
+ if (!write_bootloader_message(boot, &err)) {
+ LOGE("%s\n", err.c_str());
+ }
}
static ssize_t logbasename(