@echo off



SETLOCAL ENABLEDELAYEDEXPANSION 

:: INSTALL ON ALL ATTACHED DEVICES ::
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%


FOR /F "tokens=1,2 skip=1" %%A IN ('adb devices') DO (
    SET IS_DEV=%%B
	if "!IS_DEV!" == "device" (
	    SET SERIAL=%%A
	    SET CURR_PATH="%~dp0

	    echo %NL%#### PROCESS START FOR SERIAL# -s !SERIAL! ####%NL%

		echo ***Installing Nuovo App***
	    adb  -s !SERIAL! install -r -g !CURR_PATH!\nuovopay.apk

        echo ***Setting up Nuovo as Device Owner***
	    adb -s !SERIAL! shell dpm set-device-owner com.promobitech.nuovo/com.promobitech.mobilock.component.MobilockDeviceAdmin

		echo ***Excluding Nuovo from Battery Optimization***
	    adb -s !SERIAL! shell  dumpsys deviceidle whitelist +com.promobitech.nuovo

		echo ***Launching Nuovo, Scan QR Code***
	    adb -s !SERIAL! shell  am start com.promobitech.nuovo/com.promobitech.mobilock.ui.activities.NavigationActivity
	)
)
ENDLOCAL




