diff --git a/flash/one/config.mk b/flash/one/config.mk index 66690f12a907d5621122ecfff80fe31fd986c367..a6aec371ba466f303045e572db56733f6dcc7eed 100644 --- a/flash/one/config.mk +++ b/flash/one/config.mk @@ -1,4 +1,5 @@ HLOS_IMAGES_TARGET := boot.img \ + cache.img \ recovery.img \ dtbo.img \ vbmeta_system.img \ diff --git a/flash/one/flash_one_factory.sh b/flash/one/flash_one_factory.sh index 0c297ccff5da20ec00986b10a4351db5f899d763..709bec0a6f82c4dad2d6fa073a8dc6e89ebc290b 100755 --- a/flash/one/flash_one_factory.sh +++ b/flash/one/flash_one_factory.sh @@ -14,6 +14,8 @@ set -e set -u +CLEAN_FLASH="true" # Control data wipe behavior. Default is "true". + # Target device info PRODUCT="Murena One" PRODUCT_ID="g1970upt_v2_gk_p60c_oj_r" @@ -96,7 +98,7 @@ flash_device() { flash_image_or_abort "${sn}" lk lk.img flash_image_or_abort "${sn}" logo logo.bin flash_image_or_abort "${sn}" md1img md1img.img - flash_image_or_abort "${sn}" preloader preloader_g1970upt_v2_gk_p60c_oj_r.bin + flash_image_or_abort "${sn}" preloader preloader_ufs.img flash_image_or_abort "${sn}" recovery recovery.img flash_image_or_abort "${sn}" scp2 scp.img flash_image_or_abort "${sn}" scp1 scp.img @@ -111,9 +113,12 @@ flash_device() { flash_image_or_abort "${sn}" vbmeta_system vbmeta_system.img flash_image_or_abort "${sn}" vbmeta vbmeta.img - "$FASTBOOT_BIN" -s "${sn}" erase userdata - "$FASTBOOT_BIN" -s "${sn}" format md_udc - flash_image_or_abort "${sn}" userdata userdata.img + if [ "${CLEAN_FLASH}" = "true" ] + then + "$FASTBOOT_BIN" -s "${sn}" erase userdata + "$FASTBOOT_BIN" -s "${sn}" format md_udc + flash_image_or_abort "${sn}" userdata userdata.img + fi } # Flash an image to a partition. Abort on failure. @@ -172,6 +177,31 @@ reboot_device() { echo "" } +# Warn about data wipe, and ask for confirmation +data_wipe_check() { + if [ "${CLEAN_FLASH}" = "true" ] + then + echo "" + echo "WARNING: Flashing this image wipes all user data and settings on the phone." + echo " Are you sure you want to wipe data and continue?" + echo "" + # Read user's input + read -rp " Type \"Yes\" (case sensitive) and press enter to wipe data and continue. Else, just press enter: " a + echo "" + if [ "_${a:-"No"}" != '_Yes' ] + # NOTE: $a is being set by the read command above, + # so the check for a to be set is mostly redundant + then + echo "WARNING: You DID NOT type \"Yes\", proceeding without data wipe." + echo "" + CLEAN_FLASH="false" + else + echo "WARNING: You typed \"Yes\", proceeding with data wipe." + CLEAN_FLASH="true" + fi + fi +} + echo "" echo "*** ${PRODUCT} flashing script ***" echo "" @@ -186,6 +216,9 @@ os_checks # If only one device is found $sn will store its serial number find_device +# Call function to look for data wipe check +data_wipe_check + # Flash the device flash_device