Allow a kernel bootconfig to set the `qemu` key

The existing code has a lot of references to the
`ro.boot.qemu` and `ro.boot.qemu.something` properties
which is not supported by the bootconfig if we place
everything under `androidboot.qemu`.

Bug: 182291166
Test: getprop | grep qemu
Signed-off-by: Roman Kiryanov <rkir@google.com>
Change-Id: Icb9d29c8dc39e1fa52a6f2ce43b4f42182b7995d
This commit is contained in:
Roman Kiryanov 2021-04-28 15:15:44 -07:00
parent 26e5d8f1e2
commit 6e20ff83ac
1 changed files with 10 additions and 3 deletions

View File

@ -1218,13 +1218,20 @@ static void ProcessKernelCmdline() {
});
}
// bootconfig does not allow to populate `key=value` simultaneously with
// `key.subkey=value` which does not work with the existing code for
// `hardware` (e.g. we want both `ro.boot.hardware=value` and
// `ro.boot.hardware.sku=value`) and for `qemu` (Android Stidio Emulator
// specific).
static bool IsAllowedBootconfigKey(const std::string_view key) {
return (key == "hardware"sv) || (key == "qemu"sv);
}
static void ProcessBootconfig() {
ImportBootconfig([&](const std::string& key, const std::string& value) {
if (StartsWith(key, ANDROIDBOOT_PREFIX)) {
InitPropertySet("ro.boot." + key.substr(ANDROIDBOOT_PREFIX.size()), value);
} else if (key == "hardware") {
// "hardware" in bootconfig replaces "androidboot.hardware" kernel
// cmdline parameter
} else if (IsAllowedBootconfigKey(key)) {
InitPropertySet("ro.boot." + key, value);
}
});