@echo off
setlocal EnableExtensions
if "%~1"=="" (
  echo Usage: oneplus8t-push-camera-fix-safe.bat SERIAL
  exit /b 1
)
set "SERIAL=%~1"
set "ADB=adb"
echo %SERIAL%| findstr /C:":" >nul && "%ADB%" connect %SERIAL%
"%ADB%" -s "%SERIAL%" root
"%ADB%" -s "%SERIAL%" remount
if errorlevel 1 exit /b 1
"%ADB%" -s "%SERIAL%" push libcameraservice.so /system/lib64/libcameraservice.so
"%ADB%" -s "%SERIAL%" push cameraserver /system/bin/cameraserver
"%ADB%" -s "%SERIAL%" shell chmod 644 /system/lib64/libcameraservice.so
"%ADB%" -s "%SERIAL%" shell chmod 755 /system/bin/cameraserver
"%ADB%" -s "%SERIAL%" shell restorecon -F /system/lib64/libcameraservice.so
"%ADB%" -s "%SERIAL%" shell restorecon -F /system/bin/cameraserver
"%ADB%" -s "%SERIAL%" shell setprop ctl.restart cameraserver
echo Done. Force-stop Aperture and reopen.
endlocal
