::@echo off
fastboot %* getvar product 2>&1 | findstr /r /c:"^product: *arctic" || echo Missmatching image and device
fastboot %* getvar product 2>&1 | findstr /r /c:"^product: *arctic" || exit /B 1
set Partition_Version=3
fastboot %* getvar partition-version 2>&1 | findstr /r /c:"^partition-version: %Partition_Version%"
if %errorlevel% equ 1 (
@echo error current device partition version is inconsistent with this package
exit /B 1
)
set CURRENT_ANTI_VER=1
for /f "tokens=2 delims=: " %%i in ('fastboot %* getvar anti 2^>^&1 ^| findstr /r /c:"anti:"') do (set version=%%i)
if [%version%] EQU [] set version=0
if %version% GTR %CURRENT_ANTI_VER% (
@echo error current device antirollback version is greater than this package
exit /B 1
)
fastboot %* getvar crc 2>&1 | findstr /r /c:"^crc: 1" && if %errorlevel% equ 0 (
fastboot %* flash crclist %~dp0images\crclist.txt || @echo "Flash crclist error" && exit /B 1
fastboot %* flash sparsecrclist %~dp0images\sparsecrclist.txt || @echo "Flash sparsecrclist error" && exit /B 1
)
::erase opcust and opconfig when cota enabled; Judge whether the partition exists before erase;
fastboot %* getvar partition-type:opcust 2>&1 | findstr /r /c:"^partition-type:opcust: LK"
if %errorlevel% equ 0 (
fastboot %* erase opcust || @echo "Erase opcust error" && exit /B 1
)
fastboot %* getvar partition-type:opconfig 2>&1 | findstr /r /c:"^partition-type:opconfig: LK"
if %errorlevel% equ 0 (
fastboot %* erase opconfig || @echo "Erase opconfig error" && exit /B 1
)
fastboot %* erase boot_ab || @echo "Erase boot_ab error" && exit /B 1
fastboot %* erase misc || @echo "Erase misc error" && exit /B 1
fastboot %* erase uboot_log || @echo "Erase uboot_log error" && exit /B 1
fastboot %* erase l_runtimenv1 || @echo "Erase l_runtimenv1 error" && exit /B 1
fastboot %* erase l_runtimenv2 || @echo "Erase l_runtimenv2 error" && exit /B 1
fastboot %* erase metadata || @echo "Erase metadata error" && exit /B 1
fastboot %* erase sysdumpdb || @echo "Erase sysdumpdb error" && exit /B 1
fastboot %* flash splloader %~dp0images\u-boot-spl-16k-ufs-sign.bin || @echo "Flash splloader error" && exit /B 1
fastboot %* flash splloader_bak %~dp0images\u-boot-spl-16k-ufs-sign.bin || @echo "Flash splloader_bak error" && exit /B 1
fastboot %* flash trustos_ab %~dp0images\tos-sign.bin || @echo "Flash trustos_ab error" && exit /B 1
fastboot %* flash sml_ab %~dp0images\sml-sign.bin || @echo "Flash sml_a error" && exit /B 1
fastboot %* flash uboot_ab %~dp0images\lk-sign.bin || @echo "Flash uboot_ab error" && exit /B 1
fastboot %* flash teecfg_ab %~dp0images\teecfg-sign.bin || @echo "Flash teecfg_ab error" && exit /B 1
fastboot %* flash logo_ab %~dp0images\logo.bin || @echo "Flash logo_ab error" && exit /B 1
fastboot %* flash fbootlogo %~dp0images\logo.bin || @echo "Flash fbootlogo error" && exit /B 1
fastboot %* oem backupnv || @echo "backupnv error" && exit /B 1
fastboot %* flash l_fixnv1_ab %~dp0images\qogirl6_pubcp_MLS_customer_nvitem.bin || @echo "Flash l_fixnv1_ab error" && exit /B 1
fastboot %* flash l_modem_ab %~dp0images\l_modem.img || @echo "Flash l_modem_ab error" && exit /B 1
fastboot %* flash l_deltanv_ab %~dp0images\qogirl6_pubcp_MLS_customer_deltanv.bin || @echo "Flash l_deltanv_ab error" && exit /B 1
fastboot %* flash l_ldsp_ab %~dp0images\l_ldsp.img || @echo "Flash l_ldsp_ab error" && exit /B 1
fastboot %* flash l_gdsp_ab %~dp0images\l_gdsp.img || @echo "Flash l_gdsp_ab error" && exit /B 1
fastboot %* flash l_agdsp_ab %~dp0images\l_agdsp.img || @echo "Flash l_agdsp_ab error" && exit /B 1
fastboot %* flash pm_sys_ab %~dp0images\pm_sys.img || @echo "Flash pm_sys_ab error" && exit /B 1
fastboot %* flash vendor_boot_ab %~dp0images\vendor_boot.img || @echo "Flash vendor_boot_ab error" && exit /B 1
fastboot %* flash init_boot_ab %~dp0images\init_boot.img || @echo "Flash init_boot_ab error" && exit /B 1
fastboot %* flash dtbo_ab %~dp0images\dtbo.img || @echo "Flash dtbo_ab error" && exit /B 1
fastboot %* flash super %~dp0images\super.img || @echo "Flash super error" && exit /B 1
fastboot %* flash cache %~dp0images\cache.img || @echo "Flash cache error" && exit /B 1
fastboot %* flash blackbox %~dp0images\blackbox.img || @echo "Flash blackbox error" && exit /B 1
::fastboot %* flash prodnv %~dp0images\prodnv.img || @echo "Flash prodnv error" && exit /B 1
fastboot %* erase vbmeta_ab || @echo "Erase vbmeta_ab error" && exit /B 1
fastboot %* flash vbmeta_ab %~dp0images\vbmeta.img || @echo "Flash vbmeta_ab error" && exit /B 1
fastboot %* flash vbmeta_system_ab %~dp0images\vbmeta_system.img || @echo "Flash vbmeta_system_ab error" && exit /B 1
fastboot %* flash vbmeta_vendor_ab %~dp0images\vbmeta_vendor.img || @echo "Flash vbmeta_vendor_ab error" && exit /B 1
fastboot %* flash vbmeta_system_ext_ab %~dp0images\vbmeta_system_ext.img || @echo "Flash vbmeta_system_ext_ab error" && exit /B 1
fastboot %* flash vbmeta_product_ab %~dp0images\vbmeta_product.img || @echo "Flash vbmeta_product_ab error" && exit /B 1
fastboot %* flash vbmeta_odm_ab %~dp0images\vbmeta_odm.img || @echo "Flash vbmeta_odm_ab error" && exit /B 1
fastboot %* flash countrycode_ab %~dp0images\countrycode.img || @echo "Flash countrycode_ab error" && exit /B 1
fastboot %* flash rescue %~dp0images\rescue.img || @echo "Flash rescue error" && exit /B 1
::fastboot %* flash cust %~dp0images\cust.img || @echo "Flash cust error" && exit /B 1
fastboot %* erase userdata || @echo "Erase userdata error" && exit /B 1
fastboot %* flash userdata %~dp0images\userdata.img || @echo "Flash userdata error" && exit /B 1
fastboot %* flash boot_ab %~dp0images\boot.img || @echo "Flash boot_ab error" && exit /B 1
fastboot %* oem cdms
::fastboot %* getvar unlocked 2>&1 | findstr /r "yes" 2>&1 && fastboot %* set_active a
fastboot %* reboot