diff --git a/flash/FP3/flash_FP3_factory.sh b/flash/FP3/flash_FP3_factory.sh index 71c9b995137f9a9ab21237ae5a9840a83daac31f..566cedcd39c1350b035d74861d8eae70197ecedc 100755 --- a/flash/FP3/flash_FP3_factory.sh +++ b/flash/FP3/flash_FP3_factory.sh @@ -7,7 +7,7 @@ ########## ########## -# This script flashes a software release and complete wipes the device. +# This script flashes a software release and completly wipes the device. # # The script wipes both user data and the Google factory reset protection # information. It will unlock the phone, delete the data, and re-lock it. @@ -86,6 +86,36 @@ find_device() { done } +# Check if the device is properly unlocked +check_unlock_status() { + PHONE_IS_READY=true + if (fastboot getvar is-userspace 2>&1 | grep -q yes); then + echo "Info: Your phone is in fastbootD mode." + if (fastboot getvar unlocked 2>&1 | grep -q no); then + echo "Error: Your phone is still locked." + echo "Did you execute 'fastboot flashing unlock'?" + PHONE_IS_READY=false + fi + else + echo "Info: Your phone is in regular bootloader mode." + if (fastboot getvar unlocked 2>&1 | grep -q no); then + echo "Error: Your phone is still locked." + echo "Did you execute 'fastboot flashing unlock'?" + PHONE_IS_READY=false + fi + if (fastboot oem device-info 2>&1 | grep -q "critical unlocked: false"); then + echo "Error: Critical partitions are still locked." + echo "Did you execute 'fastboot flashing unlock_critical'?" + PHONE_IS_READY=false + fi + fi + + if [ "$PHONE_IS_READY" = "false" ]; then + echo "Error: Your phone is not ready for flashing yet (see above), aborting..." + exit 1 + fi +} + # Flash (or manipulate) relevant partitions flash_device() { @@ -217,5 +247,8 @@ find_device # Call function to look for data wipe check data_wipe_check +# Check if the device is properly unlocked +check_unlock_status + # Flash the device flash_device