Cleanup implementation

This commit is contained in:
topjohnwu
2023-05-18 20:26:20 -07:00
parent 17569005a4
commit cd7a335d0f
5 changed files with 126 additions and 115 deletions
+5 -5
View File
@@ -127,7 +127,7 @@ string find_preinit_device() {
part_t ext4_type = UNKNOWN;
part_t f2fs_type = UNKNOWN;
bool encrypted = getprop("ro.crypto.state") == "encrypted";
bool encrypted = get_prop("ro.crypto.state") == "encrypted";
bool mount = getuid() == 0 && getenv("MAGISKTMP");
bool make_dev = mount && getenv("MAKEDEV");
@@ -283,14 +283,14 @@ static bool check_data() {
});
if (!mnt)
return false;
auto crypto = getprop("ro.crypto.state");
auto crypto = get_prop("ro.crypto.state");
if (!crypto.empty()) {
if (crypto != "encrypted") {
// Unencrypted, we can directly access data
return true;
} else {
// Encrypted, check whether vold is started
return !getprop("init.svc.vold").empty();
return !get_prop("init.svc.vold").empty();
}
}
// ro.crypto.state is not set, assume it's unencrypted
@@ -391,8 +391,8 @@ static void post_fs_data() {
goto early_abort;
}
if (getprop("persist.sys.safemode", true) == "1" ||
getprop("ro.sys.safemode") == "1" || check_key_combo()) {
if (get_prop("persist.sys.safemode", true) == "1" ||
get_prop("ro.sys.safemode") == "1" || check_key_combo()) {
boot_state |= FLAG_SAFE_MODE;
// Disable all modules and denylist so next boot will be clean
disable_modules();
+2 -2
View File
@@ -330,7 +330,7 @@ static void daemon_entry() {
switch_cgroup("/acct", pid);
switch_cgroup("/dev/cg2_bpf", pid);
switch_cgroup("/sys/fs/cgroup", pid);
if (getprop("ro.config.per_app_memcg") != "false") {
if (get_prop("ro.config.per_app_memcg") != "false") {
switch_cgroup("/dev/memcg/apps", pid);
}
@@ -350,7 +350,7 @@ static void daemon_entry() {
});
if (SDK_INT < 0) {
// In case some devices do not store this info in build.prop, fallback to getprop
auto sdk = getprop("ro.build.version.sdk");
auto sdk = get_prop("ro.build.version.sdk");
if (!sdk.empty()) {
SDK_INT = parse_int(sdk);
}
+2 -1
View File
@@ -264,7 +264,8 @@ void load_modules() {
strcpy(b, "system.prop");
if (access(buf, F_OK) == 0) {
LOGI("%s: loading [system.prop]\n", module);
load_prop_file(buf, false);
// Do NOT go through property service as it could cause boot lock
load_prop_file(buf, true);
}
// Check whether skip mounting