diff --git a/app/src/main/res/raw/manager.sh b/app/src/main/res/raw/manager.sh index 4fa1acd60..f2ec60d29 100644 --- a/app/src/main/res/raw/manager.sh +++ b/app/src/main/res/raw/manager.sh @@ -179,12 +179,6 @@ check_encryption() { fi } -check_vbmeta_partition() { - if [ -e /dev/block/by-name/vbmeta_a ] || [ -e /dev/block/by-name/vbmeta ]; then - VBMETAEXIST=true - fi -} - ########################## # Non-root util_functions ########################## @@ -199,6 +193,14 @@ get_flags() { KEEPVERITY=$SYSTEM_ROOT [ "$(getprop ro.crypto.state)" = "encrypted" ] && ISENCRYPTED=true || ISENCRYPTED=false KEEPFORCEENCRYPT=$ISENCRYPTED + # Although this most certainly won't work without root, keep it just in case + if [ -e /dev/block/by-name/vbmeta_a ] || [ -e /dev/block/by-name/vbmeta ]; then + VBMETAEXIST=true + else + VBMETAEXIST=false + fi + # Preset PATCHVBMETAFLAG to false in the non-root case + PATCHVBMETAFLAG=false # Do NOT preset RECOVERYMODE here } @@ -217,7 +219,6 @@ app_init() { SHA1=$(grep_prop SHA1 $MAGISKTMP/config) check_boot_ramdisk && RAMDISKEXIST=true || RAMDISKEXIST=false check_encryption - check_vbmeta_partition # Make sure RECOVERYMODE has value [ -z $RECOVERYMODE ] && RECOVERYMODE=false } diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index c72d42a4b..c21a8781e 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -377,8 +377,10 @@ umount_apex() { unset BOOTCLASSPATH } +# After calling this method, the following variables will be set: +# KEEPVERITY, KEEPFORCEENCRYPT, RECOVERYMODE, PATCHVBMETAFLAG, +# ISENCRYPTED, VBMETAEXIST get_flags() { - # override variables getvar KEEPVERITY getvar KEEPFORCEENCRYPT getvar RECOVERYMODE @@ -403,12 +405,15 @@ get_flags() { KEEPFORCEENCRYPT=false fi fi + VBMETAEXIST=false + local VBMETAIMG=$(find_block vbmeta vbmeta_a) + [ -n "$VBMETAIMG" ] && VBMETAEXIST=true if [ -z $PATCHVBMETAFLAG ]; then - if [ -e /dev/block/by-name/vbmeta_a ] || [ -e /dev/block/by-name/vbmeta ]; then + if $VBMETAEXIST; then PATCHVBMETAFLAG=false else PATCHVBMETAFLAG=true - ui_print "- Not found vbmeta partition, patch vbmetaflag" + ui_print "- Cannot find vbmeta partition, patch vbmeta in boot image" fi fi [ -z $RECOVERYMODE ] && RECOVERYMODE=false