From 4ddfd023cc012280f6121a2017f77fe18284b286 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Tue, 9 Mar 2021 17:22:21 -0800 Subject: [PATCH] Populate more emulator properties to `ro.boot.` ro.boot.config.low_ram ro.boot.dalvik.vm.heapsize ro.boot.debug.hwui.renderer ro.boot.debug.stagefright.ccodec ro.boot.opengles.version Bug: 182291166 Test: presubmit Signed-off-by: Roman Kiryanov Change-Id: I4d7ee19feb13a418a95f31be7534df98dfaeb3e3 --- init/property_service.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 27ace7d43..73ef97ada 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -1165,12 +1165,37 @@ static void ProcessKernelDt() { constexpr auto ANDROIDBOOT_PREFIX = "androidboot."sv; +// emulator specific, should be removed once emulator is migrated to +// bootconfig, see b/182291166. +static std::string RemapEmulatorPropertyName(const std::string_view qemu_key) { + if (StartsWith(qemu_key, "dalvik."sv) || StartsWith(qemu_key, "opengles."sv) || + StartsWith(qemu_key, "config."sv)) { + return std::string(qemu_key); + } else if (qemu_key == "uirenderer"sv) { + return "debug.hwui.renderer"s; + } else if (qemu_key == "media.ccodec"sv) { + return "debug.stagefright.ccodec"s; + } else { + return ""s; // TBD + } +} + static void ProcessKernelCmdline() { ImportKernelCmdline([&](const std::string& key, const std::string& value) { + constexpr auto qemu_prefix = "qemu."sv; + if (StartsWith(key, ANDROIDBOOT_PREFIX)) { InitPropertySet("ro.boot." + key.substr(ANDROIDBOOT_PREFIX.size()), value); - } else if (StartsWith(key, "qemu."sv)) { - InitPropertySet("ro.kernel." + key, value); + } else if (StartsWith(key, qemu_prefix)) { + InitPropertySet("ro.kernel." + key, value); // emulator specific, deprecated + + // emulator specific, should be retired once emulator migrates to + // androidboot. + const auto new_name = + RemapEmulatorPropertyName(std::string_view(key).substr(qemu_prefix.size())); + if (!new_name.empty()) { + InitPropertySet("ro.boot." + new_name, value); + } } else if (key == "qemu") { // emulator specific, should be retired once emulator migrates to // androidboot.