Merge changes from topic "cuttlefish_misc"
* changes: libbootloader_message: host_supported. libbootloader_message: write recovery to any device
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
cc_library {
|
cc_library {
|
||||||
name: "libbootloader_message",
|
name: "libbootloader_message",
|
||||||
recovery_available: true,
|
recovery_available: true,
|
||||||
|
host_supported: true,
|
||||||
srcs: ["bootloader_message.cpp"],
|
srcs: ["bootloader_message.cpp"],
|
||||||
cflags: [
|
cflags: [
|
||||||
"-Wall",
|
"-Wall",
|
||||||
@@ -24,7 +25,22 @@ cc_library {
|
|||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libbase",
|
"libbase",
|
||||||
"libfs_mgr",
|
|
||||||
],
|
],
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
|
|
||||||
|
target: {
|
||||||
|
android: {
|
||||||
|
shared_libs: [
|
||||||
|
"libfs_mgr",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
host: {
|
||||||
|
shared_libs: [
|
||||||
|
"libcutils", // for strlcpy
|
||||||
|
],
|
||||||
|
static_libs: [
|
||||||
|
"libfstab",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <fstab/fstab.h>
|
#include <fstab/fstab.h>
|
||||||
|
|
||||||
|
#ifndef __ANDROID__
|
||||||
|
#include <cutils/memory.h> // for strlcpy
|
||||||
|
#endif
|
||||||
|
|
||||||
using android::fs_mgr::Fstab;
|
using android::fs_mgr::Fstab;
|
||||||
using android::fs_mgr::ReadDefaultFstab;
|
using android::fs_mgr::ReadDefaultFstab;
|
||||||
|
|
||||||
@@ -168,6 +172,14 @@ bool write_bootloader_message(const std::vector<std::string>& options, std::stri
|
|||||||
return write_bootloader_message(boot, err);
|
return write_bootloader_message(boot, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool write_bootloader_message_to(const std::vector<std::string>& options,
|
||||||
|
const std::string& misc_blk_device, std::string* err) {
|
||||||
|
bootloader_message boot = {};
|
||||||
|
update_bootloader_message_in_struct(&boot, options);
|
||||||
|
|
||||||
|
return write_bootloader_message_to(boot, misc_blk_device, err);
|
||||||
|
}
|
||||||
|
|
||||||
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err) {
|
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err) {
|
||||||
bootloader_message boot;
|
bootloader_message boot;
|
||||||
if (!read_bootloader_message(&boot, err)) {
|
if (!read_bootloader_message(&boot, err)) {
|
||||||
@@ -186,13 +198,15 @@ bool update_bootloader_message_in_struct(bootloader_message* boot,
|
|||||||
memset(boot->recovery, 0, sizeof(boot->recovery));
|
memset(boot->recovery, 0, sizeof(boot->recovery));
|
||||||
|
|
||||||
strlcpy(boot->command, "boot-recovery", sizeof(boot->command));
|
strlcpy(boot->command, "boot-recovery", sizeof(boot->command));
|
||||||
strlcpy(boot->recovery, "recovery\n", sizeof(boot->recovery));
|
|
||||||
|
std::string recovery = "recovery\n";
|
||||||
for (const auto& s : options) {
|
for (const auto& s : options) {
|
||||||
strlcat(boot->recovery, s.c_str(), sizeof(boot->recovery));
|
recovery += s;
|
||||||
if (s.back() != '\n') {
|
if (s.back() != '\n') {
|
||||||
strlcat(boot->recovery, "\n", sizeof(boot->recovery));
|
recovery += '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
strlcpy(boot->recovery, recovery.c_str(), sizeof(boot->recovery));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,11 @@ bool write_bootloader_message_to(const bootloader_message& boot,
|
|||||||
// set the command and recovery fields, and reset the rest.
|
// set the command and recovery fields, and reset the rest.
|
||||||
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err);
|
bool write_bootloader_message(const std::vector<std::string>& options, std::string* err);
|
||||||
|
|
||||||
|
// Write bootloader message (boots into recovery with the options) to the specific BCB device. Will
|
||||||
|
// set the command and recovery fields, and reset the rest.
|
||||||
|
bool write_bootloader_message_to(const std::vector<std::string>& options,
|
||||||
|
const std::string& misc_blk_device, std::string* err);
|
||||||
|
|
||||||
// Update bootloader message (boots into recovery with the options) to BCB. Will
|
// Update bootloader message (boots into recovery with the options) to BCB. Will
|
||||||
// only update the command and recovery fields.
|
// only update the command and recovery fields.
|
||||||
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err);
|
bool update_bootloader_message(const std::vector<std::string>& options, std::string* err);
|
||||||
|
|||||||
Reference in New Issue
Block a user