Update scripts for PATCHVBMETAFLAG

This commit is contained in:
topjohnwu 2022-01-12 02:21:26 -08:00 committed by John Wu
parent ba6e6cc15a
commit 21505a7470
2 changed files with 16 additions and 10 deletions

View File

@ -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
}

View File

@ -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