From ccc15c5dbd1097b1e6007caab4dca7d4d940c51d Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Tue, 9 Mar 2021 13:20:36 -0800 Subject: [PATCH] Move the `androidboot.` literal into its own variable Bug: 182291166 Test: presubmit Signed-off-by: Roman Kiryanov Change-Id: I19f25671c82fff34dd52e3557361c4340706aab0 --- init/property_service.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 404a99c4c..7b7e9194c 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -1162,13 +1163,15 @@ static void ProcessKernelDt() { } } +constexpr auto ANDROIDBOOT_PREFIX = "androidboot."sv; + static void ProcessKernelCmdline() { bool for_emulator = false; ImportKernelCmdline([&](const std::string& key, const std::string& value) { if (key == "qemu") { for_emulator = true; - } else if (StartsWith(key, "androidboot.")) { - InitPropertySet("ro.boot." + key.substr(12), value); + } else if (StartsWith(key, ANDROIDBOOT_PREFIX)) { + InitPropertySet("ro.boot." + key.substr(ANDROIDBOOT_PREFIX.size()), value); } }); @@ -1182,8 +1185,8 @@ static void ProcessKernelCmdline() { static void ProcessBootconfig() { ImportBootconfig([&](const std::string& key, const std::string& value) { - if (StartsWith(key, "androidboot.")) { - InitPropertySet("ro.boot." + key.substr(12), 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