summaryrefslogtreecommitdiffstats
path: root/bootloader_message
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-12-15 23:32:36 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2016-12-15 23:32:37 +0100
commit26d972c9d2d75a2a96d63123f0313e5c9e70a73f (patch)
tree92da6e8d0b0d4a799a8849d99c17a10b108378f6 /bootloader_message
parentMerge "tests: Add tests for bootloader_message." (diff)
parentAdd update_bootloader_message() to fix two-step OTAs. (diff)
downloadandroid_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.gz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.bz2
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.lz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.xz
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.tar.zst
android_bootable_recovery-26d972c9d2d75a2a96d63123f0313e5c9e70a73f.zip
Diffstat (limited to 'bootloader_message')
-rw-r--r--bootloader_message/bootloader_message.cpp21
-rw-r--r--bootloader_message/include/bootloader_message/bootloader_message.h7
2 files changed, 27 insertions, 1 deletions
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index 9a5671843..b873d3dc3 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -176,6 +176,27 @@ bool write_bootloader_message(const std::vector<std::string>& options, std::stri
return write_bootloader_message(boot, err);
}
+bool update_bootloader_message(const std::vector<std::string>& options, std::string* err) {
+ bootloader_message boot;
+ if (!read_bootloader_message(&boot, err)) {
+ return false;
+ }
+
+ // Zero out the entire fields.
+ memset(boot.command, 0, sizeof(boot.command));
+ memset(boot.recovery, 0, sizeof(boot.recovery));
+
+ strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
+ strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
+ for (const auto& s : options) {
+ strlcat(boot.recovery, s.c_str(), sizeof(boot.recovery));
+ if (s.back() != '\n') {
+ strlcat(boot.recovery, "\n", sizeof(boot.recovery));
+ }
+ }
+ return write_bootloader_message(boot, err);
+}
+
bool write_reboot_bootloader(std::string* err) {
bootloader_message boot;
if (!read_bootloader_message(&boot, err)) {
diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h
index ec47facf6..bc5104ddf 100644
--- a/bootloader_message/include/bootloader_message/bootloader_message.h
+++ b/bootloader_message/include/bootloader_message/bootloader_message.h
@@ -194,9 +194,14 @@ bool write_bootloader_message(const bootloader_message& boot, std::string* err);
bool write_bootloader_message_to(const bootloader_message& boot,
const std::string& misc_blk_device, std::string* err);
-// Write bootloader message (boots into recovery with the options) to BCB.
+// Write bootloader message (boots into recovery with the options) to BCB. Will
+// set the command and recovery fields, and reset the rest.
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err);
+// Update bootloader message (boots into recovery with the options) to BCB. Will
+// only update the command and recovery fields.
+bool update_bootloader_message(const std::vector<std::string>& options, std::string* err);
+
// Clear BCB.
bool clear_bootloader_message(std::string* err);