|
@@ -1,9 +1,24 @@
|
|
|
@echo off
|
|
@echo off
|
|
|
chcp 65001 >nul
|
|
chcp 65001 >nul
|
|
|
|
|
+setlocal enabledelayedexpansion
|
|
|
|
|
+
|
|
|
echo ========================================
|
|
echo ========================================
|
|
|
echo Test ADB Connection
|
|
echo Test ADB Connection
|
|
|
echo ========================================
|
|
echo ========================================
|
|
|
echo.
|
|
echo.
|
|
|
|
|
+
|
|
|
|
|
+REM Get the directory where this batch file is located
|
|
|
|
|
+set "SCRIPT_DIR=%~dp0"
|
|
|
|
|
+set "PROJECT_ROOT=%SCRIPT_DIR%.."
|
|
|
|
|
+
|
|
|
|
|
+REM Read ADB path from config.js using PowerShell
|
|
|
|
|
+echo [0/6] Reading ADB path from config.js...
|
|
|
|
|
+for /f "delims=" %%i in ('powershell -Command "$content = Get-Content '%PROJECT_ROOT%\config.js' -Raw; $content = $content -replace 'module\.exports\s*=\s*', ''; $content = $content -replace ';', ''; $content = $content.Trim(); $json = $content | ConvertFrom-Json; $adbPath = $json.'adb-path'; if ($adbPath) { Write-Output ($adbPath.TrimEnd('\') + '\adb.exe') } else { Write-Output 'adb' }"') do set "ADB_PATH=%%i"
|
|
|
|
|
+
|
|
|
|
|
+if "%ADB_PATH%"=="" set "ADB_PATH=adb"
|
|
|
|
|
+echo Using ADB: %ADB_PATH%
|
|
|
|
|
+echo.
|
|
|
|
|
+
|
|
|
echo Please enter the last two digits of the IP address:
|
|
echo Please enter the last two digits of the IP address:
|
|
|
set /p IP_LAST_TWO="Last two digits (e.g., 0.15): "
|
|
set /p IP_LAST_TWO="Last two digits (e.g., 0.15): "
|
|
|
if "%IP_LAST_TWO%"=="" (
|
|
if "%IP_LAST_TWO%"=="" (
|
|
@@ -18,18 +33,18 @@ echo.
|
|
|
echo Connecting to %DEVICE_ADDRESS%...
|
|
echo Connecting to %DEVICE_ADDRESS%...
|
|
|
echo.
|
|
echo.
|
|
|
|
|
|
|
|
-echo [1/5] Check if ADB is available...
|
|
|
|
|
-adb version >nul 2>&1
|
|
|
|
|
|
|
+echo [1/6] Check if ADB is available...
|
|
|
|
|
+"%ADB_PATH%" version >nul 2>&1
|
|
|
if errorlevel 1 (
|
|
if errorlevel 1 (
|
|
|
- echo Error: ADB not installed or not in PATH
|
|
|
|
|
- echo Please ensure Android SDK Platform Tools is installed
|
|
|
|
|
|
|
+ echo Error: ADB not found at: %ADB_PATH%
|
|
|
|
|
+ echo Please check config.js and ensure ADB path is correct
|
|
|
pause
|
|
pause
|
|
|
exit /b 1
|
|
exit /b 1
|
|
|
)
|
|
)
|
|
|
echo ADB is available
|
|
echo ADB is available
|
|
|
echo.
|
|
echo.
|
|
|
|
|
|
|
|
-echo [2/5] Test network connectivity (ping %DEVICE_IP%)...
|
|
|
|
|
|
|
+echo [2/6] Test network connectivity (ping %DEVICE_IP%)...
|
|
|
ping -n 2 %DEVICE_IP% >nul 2>&1
|
|
ping -n 2 %DEVICE_IP% >nul 2>&1
|
|
|
if errorlevel 1 (
|
|
if errorlevel 1 (
|
|
|
echo Cannot ping %DEVICE_IP%
|
|
echo Cannot ping %DEVICE_IP%
|
|
@@ -40,7 +55,7 @@ if errorlevel 1 (
|
|
|
echo.
|
|
echo.
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-echo [3/5] Check if port %DEVICE_PORT% is open...
|
|
|
|
|
|
|
+echo [3/6] Check if port %DEVICE_PORT% is open...
|
|
|
powershell -Command "Test-NetConnection -ComputerName %DEVICE_IP% -Port %DEVICE_PORT% -InformationLevel Quiet" >nul 2>&1
|
|
powershell -Command "Test-NetConnection -ComputerName %DEVICE_IP% -Port %DEVICE_PORT% -InformationLevel Quiet" >nul 2>&1
|
|
|
if errorlevel 1 (
|
|
if errorlevel 1 (
|
|
|
echo Port %DEVICE_PORT% may not be open or blocked by firewall
|
|
echo Port %DEVICE_PORT% may not be open or blocked by firewall
|
|
@@ -50,12 +65,12 @@ if errorlevel 1 (
|
|
|
echo.
|
|
echo.
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-echo [4/5] Disconnect old connection (if any)...
|
|
|
|
|
-adb disconnect %DEVICE_ADDRESS% >nul 2>&1
|
|
|
|
|
|
|
+echo [4/6] Disconnect old connection (if any)...
|
|
|
|
|
+"%ADB_PATH%" disconnect %DEVICE_ADDRESS% >nul 2>&1
|
|
|
timeout /t 1 /nobreak >nul
|
|
timeout /t 1 /nobreak >nul
|
|
|
|
|
|
|
|
echo Attempting to connect %DEVICE_ADDRESS%...
|
|
echo Attempting to connect %DEVICE_ADDRESS%...
|
|
|
-adb connect %DEVICE_ADDRESS%
|
|
|
|
|
|
|
+"%ADB_PATH%" connect %DEVICE_ADDRESS%
|
|
|
set CONNECT_RESULT=%ERRORLEVEL%
|
|
set CONNECT_RESULT=%ERRORLEVEL%
|
|
|
|
|
|
|
|
echo.
|
|
echo.
|
|
@@ -83,7 +98,7 @@ if %CONNECT_RESULT% equ 0 (
|
|
|
echo.
|
|
echo.
|
|
|
echo 4. If phone doesn't have "Wireless debugging" option, try:
|
|
echo 4. If phone doesn't have "Wireless debugging" option, try:
|
|
|
echo a) Connect phone to computer via USB
|
|
echo a) Connect phone to computer via USB
|
|
|
- echo b) Run: adb tcpip 5555
|
|
|
|
|
|
|
+ echo b) Run: 0-ENABLE-TCPIP.BAT
|
|
|
echo c) Unplug USB, then run this script again
|
|
echo c) Unplug USB, then run this script again
|
|
|
echo.
|
|
echo.
|
|
|
echo 5. Check if phone and computer are on same Wi-Fi network
|
|
echo 5. Check if phone and computer are on same Wi-Fi network
|
|
@@ -92,9 +107,9 @@ if %CONNECT_RESULT% equ 0 (
|
|
|
echo.
|
|
echo.
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-echo [5/5] Check device list...
|
|
|
|
|
|
|
+echo [5/6] Check device list...
|
|
|
echo.
|
|
echo.
|
|
|
-adb devices
|
|
|
|
|
|
|
+"%ADB_PATH%" devices
|
|
|
echo.
|
|
echo.
|
|
|
|
|
|
|
|
echo ========================================
|
|
echo ========================================
|