Add update_bootloader_message() to fix two-step OTAs.
This is a retry of commit7e31f421a5. Commitbd56f1590cswitches to calling write_bootloader_message(<options>) in get_args(), which unintentionally resets the stage field thus breaks two-step OTAs. This CL adds update_bootloader_message(<options>), which only sets the command field (to "boot-recovery") and the recovery field (with the specified options). Bug: 33534933 Test: Apply a two-step package. Test: recovery_component_test passes. Change-Id: Ie0b1ed4053d2d3c97d9cb84310d616b28fcfc72e
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user