Use /metadata/watchdog as preinit dir if exists

Since Android 15, all domains are allowed to search /metadata so preinit
dir will be exposed. Use /metadata/watchdog when /metadata is chosen as
preinit device, and the dir is available (since Android 11).
This commit is contained in:
Wang Han 2024-12-14 00:32:58 +08:00 committed by John Wu
parent 005560a4c5
commit 704541aef2
2 changed files with 3 additions and 1 deletions

View File

@ -144,6 +144,8 @@ string resolve_preinit_dir(const char *base_dir) {
dir += "/unencrypted/magisk";
} else if (access((dir + "/adb").data(), F_OK) == 0) {
dir += "/adb/modules";
} else if (access((dir + "/watchdog").data(), F_OK) == 0) {
dir += "/watchdog/magisk";
} else {
dir += "/magisk";
}

View File

@ -151,7 +151,7 @@ rm -rf \
/cache/*magisk* /cache/unblock /data/*magisk* /data/cache/*magisk* /data/property/*magisk* \
/data/Magisk.apk /data/busybox /data/custom_ramdisk_patch.sh /data/adb/*magisk* \
/data/adb/post-fs-data.d /data/adb/service.d /data/adb/modules* \
/data/unencrypted/magisk /metadata/magisk /persist/magisk /mnt/vendor/persist/magisk
/data/unencrypted/magisk /metadata/magisk /metadata/watchdog/magisk /persist/magisk /mnt/vendor/persist/magisk
ADDOND=/system/addon.d/99-magisk.sh
if [ -f $ADDOND ]; then