Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 05506f05 authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

Don't reboot into recovery during userspace reboot

In case one of the cryptfs calls to vdc fails, first try a normal
reboot.

Test: manual
Bug: 135984674
Bug: 143970043
Change-Id: I5706d9cd6c3a08fa06329ffb7d141de632620e3d
parent 60ddf3a2
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -1119,10 +1119,15 @@ static Result<void> ExecWithFunctionOnFailure(const std::vector<std::string>& ar
}

static Result<void> ExecVdcRebootOnFailure(const std::string& vdc_arg) {
    bool should_reboot_into_recovery = true;
    auto reboot_reason = vdc_arg + "_failed";
    if (android::sysprop::InitProperties::userspace_reboot_in_progress().value_or(false)) {
        should_reboot_into_recovery = false;
    }

    auto reboot = [reboot_reason](const std::string& message) {
    auto reboot = [reboot_reason, should_reboot_into_recovery](const std::string& message) {
        // TODO (b/122850122): support this in gsi
        if (should_reboot_into_recovery) {
            if (fscrypt_is_native() && !android::gsi::IsGsiRunning()) {
                LOG(ERROR) << message << ": Rebooting into recovery, reason: " << reboot_reason;
                if (auto result = reboot_into_recovery(
@@ -1133,6 +1138,10 @@ static Result<void> ExecVdcRebootOnFailure(const std::string& vdc_arg) {
            } else {
                LOG(ERROR) << "Failure (reboot suppressed): " << reboot_reason;
            }
        } else {
            LOG(ERROR) << message << ": rebooting, reason: " << reboot_reason;
            trigger_shutdown("reboot," + reboot_reason);
        }
    };

    std::vector<std::string> args = {"exec", "/system/bin/vdc", "--wait", "cryptfs", vdc_arg};