Merge AOSP android-9.0.0_r3
Fix conflicts and make it build in 5.1, 6.0, 7.1, 8.1, and 9.0 Change-Id: Ida0a64c29ff27d339b7f42a18d820930964ac6e4
This commit is contained in:
@@ -17,7 +17,10 @@
|
||||
cc_library_static {
|
||||
name: "libbootloader_message",
|
||||
srcs: ["bootloader_message.cpp"],
|
||||
cppflags: ["-Werror"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
],
|
||||
static_libs: [
|
||||
"libbase",
|
||||
"libfs_mgr",
|
||||
@@ -186,14 +186,8 @@ bool clear_bootloader_message(std::string* err) {
|
||||
|
||||
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err) {
|
||||
bootloader_message boot = {};
|
||||
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));
|
||||
}
|
||||
}
|
||||
update_bootloader_message_in_struct(&boot, options);
|
||||
|
||||
return write_bootloader_message(boot, err);
|
||||
}
|
||||
|
||||
@@ -202,20 +196,27 @@ bool update_bootloader_message(const std::vector<std::string>& options, std::str
|
||||
if (!read_bootloader_message(&boot, err)) {
|
||||
return false;
|
||||
}
|
||||
update_bootloader_message_in_struct(&boot, options);
|
||||
|
||||
// Zero out the entire fields.
|
||||
memset(boot.command, 0, sizeof(boot.command));
|
||||
memset(boot.recovery, 0, sizeof(boot.recovery));
|
||||
return write_bootloader_message(boot, err);
|
||||
}
|
||||
|
||||
strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
|
||||
strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
|
||||
bool update_bootloader_message_in_struct(bootloader_message* boot,
|
||||
const std::vector<std::string>& options) {
|
||||
if (!boot) return false;
|
||||
// Replace the command & recovery 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));
|
||||
strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery));
|
||||
if (s.back() != '\n') {
|
||||
strlcat(boot.recovery, "\n", sizeof(boot.recovery));
|
||||
strlcat(boot->recovery, "\n", sizeof(boot->recovery));
|
||||
}
|
||||
}
|
||||
return write_bootloader_message(boot, err);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool write_reboot_bootloader(std::string* err) {
|
||||
|
||||
@@ -114,13 +114,17 @@ static_assert(sizeof(struct bootloader_message) == 2048,
|
||||
* implementations are free to use all 32 bytes and may store private
|
||||
* data past the first NUL-byte in this field. It is encouraged, but
|
||||
* not mandatory, to use 'struct bootloader_control' described below.
|
||||
*
|
||||
* The update_channel field is used to store the Omaha update channel
|
||||
* if update_engine is compiled with Omaha support.
|
||||
*/
|
||||
struct bootloader_message_ab {
|
||||
struct bootloader_message message;
|
||||
char slot_suffix[32];
|
||||
char update_channel[128];
|
||||
|
||||
// Round up the entire struct to 4096-byte.
|
||||
char reserved[2016];
|
||||
char reserved[1888];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -218,6 +222,11 @@ bool write_bootloader_message(const std::vector<std::string>& options, std::stri
|
||||
// only update the command and recovery fields.
|
||||
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err);
|
||||
|
||||
// Update bootloader message (boots into recovery with the |options|) in |boot|. Will only update
|
||||
// the command and recovery fields.
|
||||
bool update_bootloader_message_in_struct(bootloader_message* boot,
|
||||
const std::vector<std::string>& options);
|
||||
|
||||
// Clear BCB.
|
||||
bool clear_bootloader_message(std::string* err);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user