From a8336b8c2410a2cce2074be1f5795fc49f0a0290 Mon Sep 17 00:00:00 2001 From: Albert I Date: Fri, 29 Apr 2022 23:42:44 +0800 Subject: [PATCH] init: Use `IsRecoveryMode()` for normal boot checks Checking androidboot.mode properties will never work on devices where this property is always absent, primarily non-Pixel devices. Use existing IsRecoveryMode() check instead which is ugly, but works for this very purpose. Change-Id: Idc79fb2bf45f0416b242a1e1aa12bdb07bcf56b9 Signed-off-by: Albert I Signed-off-by: Alexander Winkowski Signed-off-by: Dmitrii --- init/property_service.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index 48307d5a4..a28f0c1d0 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -875,8 +875,6 @@ static void load_override_properties() { } } -constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv; - static const char *snet_prop_key[] = { "ro.boot.vbmeta.device_state", "ro.boot.verifiedbootstate", @@ -936,24 +934,10 @@ static const char *snet_prop_value[] = { static void workaround_snet_properties() { std::string build_type = android::base::GetProperty("ro.build.type", ""); - // Check whether this is a normal boot, and whether the bootloader is actually locked - auto isNormalBoot = true; // no prop = normal boot - // This runs before keys are set as props, so we need to process them ourselves. - ImportKernelCmdline([&](const std::string& key, const std::string& value) { - if (key == ANDROIDBOOT_MODE && value != "normal") { - isNormalBoot = false; - } - }); - ImportBootconfig([&](const std::string& key, const std::string& value) { - if (key == ANDROIDBOOT_MODE && value != "normal") { - isNormalBoot = false; - } - }); - // Bail out if this is recovery, fastbootd, or anything other than a normal boot. // fastbootd, in particular, needs the real values so it can allow flashing on // unlocked bootloaders. - if (!isNormalBoot) { + if (IsRecoveryMode()) { return; }