From b27b9c1d18362d88f7f0b1e1c46b8e2f1a1d0cd4 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 18 May 2020 04:36:46 -0700 Subject: [PATCH] Minor code changes --- native/jni/core/bootstages.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/native/jni/core/bootstages.cpp b/native/jni/core/bootstages.cpp index 3b85521295ffa..e904517241109 100644 --- a/native/jni/core/bootstages.cpp +++ b/native/jni/core/bootstages.cpp @@ -146,28 +146,27 @@ void reboot() { static bool check_data() { bool mnt = false; - bool data = false; - file_readline("/proc/mounts", [&](string_view s) -> bool { - if (str_contains(s, " /data ") && !str_contains(s, "tmpfs")) + file_readline("/proc/mounts", [&](string_view s) { + if (str_contains(s, " /data ") && !str_contains(s, "tmpfs")) { mnt = true; + return false; + } return true; }); - if (mnt) { - auto crypto = getprop("ro.crypto.state"); - if (!crypto.empty()) { - if (crypto == "unencrypted") { - // Unencrypted, we can directly access data - data = true; - } else { - // Encrypted, check whether vold is started - data = !getprop("init.svc.vold").empty(); - } + if (!mnt) + return false; + auto crypto = getprop("ro.crypto.state"); + if (!crypto.empty()) { + if (crypto == "unencrypted") { + // Unencrypted, we can directly access data + return true; } else { - // ro.crypto.state is not set, assume it's unencrypted - data = true; + // Encrypted, check whether vold is started + return !getprop("init.svc.vold").empty(); } } - return data; + // ro.crypto.state is not set, assume it's unencrypted + return true; } void unlock_blocks() {