Skip to content

Commit

Permalink
init: Use IsRecoveryMode() for normal boot checks
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Albert I <[email protected]>
  • Loading branch information
krasCGQ committed Jun 18, 2022
1 parent 47c0f17 commit 45635e7
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions init/property_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,6 @@ static void ProcessKernelDt() {
}

constexpr auto ANDROIDBOOT_PREFIX = "androidboot."sv;
constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv;

static void ProcessKernelCmdline() {
ImportKernelCmdline([&](const std::string& key, const std::string& value) {
Expand All @@ -1326,24 +1325,10 @@ static void ProcessBootconfig() {
}

static void SetSafetyNetProps() {
// 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;
}

Expand Down

0 comments on commit 45635e7

Please sign in to comment.