Minor code changes

This commit is contained in:
topjohnwu 2020-05-18 04:36:46 -07:00
parent f7d3d1eeaf
commit b27b9c1d18

View File

@ -146,28 +146,27 @@ void reboot() {
static bool check_data() { static bool check_data() {
bool mnt = false; bool mnt = false;
bool data = false; file_readline("/proc/mounts", [&](string_view s) {
file_readline("/proc/mounts", [&](string_view s) -> bool { if (str_contains(s, " /data ") && !str_contains(s, "tmpfs")) {
if (str_contains(s, " /data ") && !str_contains(s, "tmpfs"))
mnt = true; mnt = true;
return false;
}
return true; return true;
}); });
if (mnt) { if (!mnt)
return false;
auto crypto = getprop("ro.crypto.state"); auto crypto = getprop("ro.crypto.state");
if (!crypto.empty()) { if (!crypto.empty()) {
if (crypto == "unencrypted") { if (crypto == "unencrypted") {
// Unencrypted, we can directly access data // Unencrypted, we can directly access data
data = true; return true;
} else { } else {
// Encrypted, check whether vold is started // Encrypted, check whether vold is started
data = !getprop("init.svc.vold").empty(); return !getprop("init.svc.vold").empty();
}
} }
} else {
// ro.crypto.state is not set, assume it's unencrypted // ro.crypto.state is not set, assume it's unencrypted
data = true; return true;
}
}
return data;
} }
void unlock_blocks() { void unlock_blocks() {