if "%service_auth%"=="0" goto skipauth
:precaution_for_mtk_device
fb2 -s %psn% oem getBootloaderType 2>&1 | findstr service > nul
if "%errorlevel%"=="0" fb2 -s %psn% oem getRootStatus 2>&1 | findstr Disable > nul
if "%errorlevel%"=="0" call call_auth.cmd
:skipauth

if "!target:~0,3!"=="md4" (
if "%resultverify%"=="0" goto eof
echo %t0049%
goto noechox
)
if "!target:~0,3!"=="md5" (
if "%resultverify%"=="0" goto eof
echo %t0049%
goto noechox
)
echo %t0038% "fastboot -s %psn% flash !target!"...
:noechox
if %verbose_mode%==1 (
echo.
if "%msm8937value%"=="1" (
if "!target:~0,6!"=="system" (
fastboot -s %psn% erase !target!
)
)
fastboot -s %psn% flash !target! 2>&1 | tee %temp%\lastcmd.txt
findstr /C:"Volume Full" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
echo %t0100%
timeout /t 3 /nobreak
goto skipauth
)
findstr /C:"FAILED" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
set errorflash=1
echo errorflash>%temp%\eflash2.txt
goto eof
)
echo.
) else (
if "%msm8937value%"=="1" (
if "!target:~0,6!"=="system" (
fastboot -s %psn% erase !target! 2>nul
)
)
fastboot -s %psn% flash !target! 2>%temp%\lastcmd.txt
findstr /C:"Volume Full" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
echo Retrying...
timeout /t 3 /nobreak
goto skipauth
)
findstr /I /C:"flash write failure" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
set errorflash=1
echo errorflash>%temp%\eflash5.txt
goto eof
)
findstr /I /C:"write protected" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
set errorflash=1
echo errorflash>%temp%\eflash5.txt
goto eof
)
findstr /C:"FAILED" %temp%\lastcmd.txt > nul
if "!errorlevel!"=="0" (
del %temp%\lastcmd.txt
set errorflash=1
echo errorflash>%temp%\eflash2.txt
goto eof
)
)

:eof