diff --git a/scripts/flash_script.sh b/scripts/flash_script.sh index 9a039e080..c227d7563 100644 --- a/scripts/flash_script.sh +++ b/scripts/flash_script.sh @@ -47,6 +47,7 @@ mount_partitions find_boot_image find_dtbo_image +check_data get_flags [ -z $BOOTIMAGE ] && abort "! Unable to detect target image" @@ -72,8 +73,6 @@ remove_system_su ui_print "- Constructing environment" -check_data - if $DATA; then MAGISKBIN=/data/magisk $DATA_DE && MAGISKBIN=/data/adb/magisk diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index 60b81f474..d78ae391a 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -94,7 +94,7 @@ mount_partitions() { mount -t ext4 -o ro $SYSTEMBLOCK /system fi [ -f /system/build.prop ] || is_mounted /system || abort "! Cannot mount /system" - cat /proc/mounts | grep -E '/dev/root|/system_root' >/dev/null && SYSTEM_ROOT=true || SYSTEM_ROOT=false + grep -qE '/dev/root|/system_root' /proc/mounts && SYSTEM_ROOT=true || SYSTEM_ROOT=false if [ -f /system/init ]; then SYSTEM_ROOT=true mkdir /system_root 2>/dev/null @@ -125,7 +125,10 @@ get_flags() { fi fi if [ -z $KEEPFORCEENCRYPT ]; then - if [ "`getprop ro.crypto.state`" = "encrypted" ]; then + grep ' /data ' /proc/mounts | grep -q 'dm-' && FDE=true || FDE=false + [ -d /data/unencrypted ] && FBE=true || FBE=false + # No data access means unable to decrypt in recovery + if $FDE || $FBE || ! $DATA; then KEEPFORCEENCRYPT=true ui_print "- Encrypted data detected, keep forceencrypt" else