Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ Result<void> PrepareBootEnvImage(
// args need to be passed in via the uboot env. This won't be an issue for
// protect kvm which is running a kernel with bootconfig support.
if (!instance.bootconfig_supported()) {
std::map<std::string, std::string, std::less<void>> builtin_bootconfig_args;
auto bootconfig_args =
CF_EXPECT(BootconfigArgsFromConfig(config, instance));
CF_EXPECT(BootconfigArgsFromConfig(config, instance, builtin_bootconfig_args));

// "androidboot.hardware" kernel parameter has changed to "hardware" in
// bootconfig and needs to be replaced before being used in the kernel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ Result<std::unordered_map<std::string, std::string>> ConsoleBootconfig(

Result<std::unordered_map<std::string, std::string>> BootconfigArgsFromConfig(
const CuttlefishConfig& config,
const CuttlefishConfig::InstanceSpecific& instance) {
const CuttlefishConfig::InstanceSpecific& instance,
const std::map<std::string, std::string, std::less<void>> builtin_bootconfig_args) {
std::unordered_map<std::string, std::string> bootconfig_args;

AppendMapWithReplacement(&bootconfig_args,
Expand Down Expand Up @@ -247,6 +248,12 @@ Result<std::unordered_map<std::string, std::string>> BootconfigArgsFromConfig(
bootconfig_args["androidboot.wifi_impl"] = "virt_wifi";
}

if (!builtin_bootconfig_args.count("androidboot.vendor.apex.com.google.emulated.camera.provider.hal")){
bootconfig_args
["androidboot.vendor.apex.com.google.emulated.camera.provider.hal"] =
"com.google.emulated.camera.provider.hal";
}

if (!instance.vcpu_config_path().empty()) {
auto vcpu_config_json =
CF_EXPECT(LoadFromFile(instance.vcpu_config_path()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace cuttlefish {

Result<std::unordered_map<std::string, std::string>> BootconfigArgsFromConfig(
const CuttlefishConfig& config,
const CuttlefishConfig::InstanceSpecific& instance);
const CuttlefishConfig::InstanceSpecific& instance,
const std::map<std::string, std::string, std::less<void>> builtin_bootconfig_args);

Result<std::string> BootconfigArgsString(
const std::unordered_map<std::string, std::string>& args,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,17 @@ cf_cc_library(
hdrs = ["generate_persistent_bootconfig.h"],
deps = [
"//cuttlefish/common/libs/fs",
"//cuttlefish/common/libs/key_equals_value",
"//cuttlefish/common/libs/utils:files",
"//cuttlefish/common/libs/utils:size_utils",
"//cuttlefish/host/commands/assemble_cvd:bootconfig_args",
"//cuttlefish/host/commands/assemble_cvd/boot_image:vendor_boot_image",
"//cuttlefish/host/libs/avb",
"//cuttlefish/host/libs/config:cuttlefish_config",
"//cuttlefish/host/libs/config:data_image",
"//cuttlefish/host/libs/image_aggregator",
"//cuttlefish/io:shared_fd",
"//cuttlefish/io:string",
"//cuttlefish/result",
"@abseil-cpp//absl/log",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,38 @@

#include "cuttlefish/common/libs/fs/shared_buf.h"
#include "cuttlefish/common/libs/fs/shared_fd.h"
#include "cuttlefish/common/libs/key_equals_value/key_equals_value.h"
#include "cuttlefish/common/libs/utils/files.h"
#include "cuttlefish/common/libs/utils/size_utils.h"
#include "cuttlefish/host/commands/assemble_cvd/bootconfig_args.h"
#include "cuttlefish/host/commands/assemble_cvd/boot_image/vendor_boot_image.h"
#include "cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.h"
#include "cuttlefish/host/libs/avb/avb.h"
#include "cuttlefish/host/libs/config/cuttlefish_config.h"
#include "cuttlefish/host/libs/config/data_image.h"
#include "cuttlefish/host/libs/image_aggregator/image_aggregator.h"
#include "cuttlefish/io/shared_fd.h"
#include "cuttlefish/io/string.h"
#include "cuttlefish/result/result.h"

namespace cuttlefish {
namespace {

Result<std::map<std::string, std::string, std::less<void>>> ReadBuiltInBootconfigArgs(
const CuttlefishConfig::InstanceSpecific& instance) {
std::string image_path = instance.vendor_boot_image();
SharedFD fd = SharedFD::Open(image_path, O_RDONLY);
CF_EXPECTF(fd->IsOpen(), "Failed to open '{}': '{}'", image_path, fd->StrError());
VendorBootImage vendor_boot = CF_EXPECT(VendorBootImage::Read(std::make_unique<SharedFdIo>(fd)));
auto bootconfig_opt = vendor_boot.Bootconfig();
if (!bootconfig_opt) {
return {};
}
std::string bootconfig = CF_EXPECT(ReadToString(bootconfig_opt.value()));
return CF_EXPECT(ParseKeyEqualsValue(bootconfig));
}

}

Result<std::optional<BootConfigPartition>> BootConfigPartition::CreateIfNeeded(
const CuttlefishConfig& config,
Expand All @@ -58,8 +79,10 @@ Result<std::optional<BootConfigPartition>> BootConfigPartition::CreateIfNeeded(
CF_EXPECT(bootconfig_fd->IsOpen(),
"Unable to open bootconfig file: " << bootconfig_fd->StrError());

auto builtin_bootconfig_args = CF_EXPECT(ReadBuiltInBootconfigArgs(instance));

const auto bootconfig_args =
CF_EXPECT(BootconfigArgsFromConfig(config, instance));
CF_EXPECT(BootconfigArgsFromConfig(config, instance, builtin_bootconfig_args));
const auto bootconfig =
CF_EXPECT(BootconfigArgsString(bootconfig_args, "\n")) + "\n";

Expand Down
Loading