diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc index ffa526189c4..1940dc4ec2a 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc @@ -142,8 +142,9 @@ Result 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> 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 diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp b/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp index 145a65dd8e6..bdfbbec30cf 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.cpp @@ -74,7 +74,8 @@ Result> ConsoleBootconfig( Result> BootconfigArgsFromConfig( const CuttlefishConfig& config, - const CuttlefishConfig::InstanceSpecific& instance) { + const CuttlefishConfig::InstanceSpecific& instance, + const std::map> builtin_bootconfig_args) { std::unordered_map bootconfig_args; AppendMapWithReplacement(&bootconfig_args, @@ -247,6 +248,12 @@ Result> 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())); diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.h b/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.h index 136c42f4876..5706e8342ab 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.h +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/bootconfig_args.h @@ -26,7 +26,8 @@ namespace cuttlefish { Result> BootconfigArgsFromConfig( const CuttlefishConfig& config, - const CuttlefishConfig::InstanceSpecific& instance); + const CuttlefishConfig::InstanceSpecific& instance, + const std::map> builtin_bootconfig_args); Result BootconfigArgsString( const std::unordered_map& args, diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/BUILD.bazel b/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/BUILD.bazel index 6013dda1f94..6e4f1360833 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/BUILD.bazel +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/BUILD.bazel @@ -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", ], diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.cpp b/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.cpp index 80c4a0b598b..fe50c8bb3b5 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.cpp +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/disk/generate_persistent_bootconfig.cpp @@ -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>> 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(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> BootConfigPartition::CreateIfNeeded( const CuttlefishConfig& config, @@ -58,8 +79,10 @@ Result> 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";