Skip to content

Commit

Permalink
Fix: fix wrong uiautomator2 init
Browse files Browse the repository at this point in the history
  • Loading branch information
MetalDevOps committed Aug 24, 2020
1 parent fc03131 commit 77f6836
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 23 deletions.
50 changes: 37 additions & 13 deletions alas.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
:: Last updated: 2020-08-23
:: >>> Get updated from: https://github.com/LmeSzinc/AzurLaneAutoScript <<<
@echo off
chcp | find "932" >NUL && set "IME=true" || set "IME=false"
if "%IME%"=="true" (
echo ====================================================================================================
echo Incorrect encoding, visit this link to correct: https://bit.ly/34t8ubY
echo To copy, select the link and CTRL+SHFT+C
echo ====================================================================================================
pause
goto :eof
)
pushd "%~dp0"
setlocal EnableDelayedExpansion
set "Version=3.0"
Expand All @@ -19,6 +28,17 @@ set "root=%~dp0"
set "root=%root:~0,-1%"
cd "%root%"

rem ================= Variables =================

set "pyBin=%root%\toolkit\python.exe"
set "adbBin=%root%\toolkit\Lib\site-packages\adbutils\binaries\adb.exe"
set "gitBin=%root%\toolkit\Git\mingw64\bin\git.exe"
set "curlBin=%root%\toolkit\Git\mingw64\bin\curl.exe"
set "api_json=%root%\config\api_git.json"
set "AlasConfig=%root%\config\alas.ini"
set "template=%root%\config\template.ini"
set "gitFolder=%root%\.git"

:: Import main settings (%Language%, %Region%, %SystemType%) and translation text.
call command\Get.bat Main
:: Import the Proxy setting and apply. Then show more info in Option6.
Expand All @@ -32,14 +52,6 @@ call command\Get.bat DeployMode

:: Start of Deployment
title Alas Run Tool V3
set "pyBin=%root%\toolkit\python.exe"
set "adbBin=%root%\toolkit\Lib\site-packages\adbutils\binaries\adb.exe"
set "gitBin=%root%\toolkit\Git\mingw64\bin\git.exe"
set "curlBin=%root%\toolkit\Git\mingw64\bin\curl.exe"
set "api_json=%root%\config\api_git.json"
set "AlasConfig=%root%\config\alas.ini"
set "template=%root%\config\template.ini"
set "gitFolder=%root%\.git"
if "%IsUsingGit%"=="yes" if "%DeployMode%"=="unknown" ( xcopy /Y toolkit\config .git\ > NUL )
call :UpdateChecker_Alas

Expand Down Expand Up @@ -104,7 +116,6 @@ rem ================= OPTION 1 =================
:en
call :CheckBsBeta
call :AdbConnect
rem call :uiautomator2init
echo ====================================================================================================
echo Python Found in %pyBin% Proceeding..
echo Opening alas_en.pyw in %root%
Expand All @@ -118,7 +129,6 @@ rem ================= OPTION 2 =================
:cn
call :CheckBsBeta
call :AdbConnect
rem call :uiautomator2init
echo ====================================================================================================
echo Python Found in %pyBin% Proceeding..
echo Opening alas_en.pyw in %root%
Expand All @@ -131,7 +141,6 @@ rem ================= OPTION 3 =================
:jp
call :CheckBsBeta
call :AdbConnect
rem call :uiautomator2init
echo ====================================================================================================
echo Python Found in %pyBin% Proceeding..
echo Opening alas_en.pyw in %root%
Expand Down Expand Up @@ -413,6 +422,11 @@ goto ReturnToSetting

rem ================= FUNCTIONS =================

:CheckAdbConnect
for /f "tokens=1*" %%g IN ('%adbBin% connect 127.0.0.1:5555') do set adbCheck=%%g
if "%adbCheck%"=="cannot"
echo %adbCheck%

:ReturnToSetting
echo. & echo Press any key to continue...
pause > NUL
Expand Down Expand Up @@ -444,6 +458,7 @@ for /f "tokens=3" %%a in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\BlueStacks_bgp6
set SerialRealtime=127.0.0.1:%port%
echo ====================================================================================================
echo connecting at %SerialRealtime%
%adbBin% kill-server > nul 2>&1
%adbBin% connect %SerialRealtime%
echo ====================================================================================================
if "%FirstRun%"=="yes" (
Expand All @@ -456,14 +471,23 @@ echo Old Serial: %SerialAlas%
echo New Serial: %SerialRealtime%
echo ====================================================================================================
echo Press any to continue...
%pyBin% -m uiautomator2 init
pause > NUL
:: -----------------------------------------------------------------------------
goto :eof

:AdbConnect
if "%RealtimeMode%"=="enable" goto :eof
if "%FirstRun%"=="yes" ( %adbBin% connect %serial_input% && goto :eof )
%adbBin% connect %Serial%
if "%FirstRun%"=="yes" ( goto :eof )
%adbBin% kill-server > nul 2>&1
%adbBin% connect %Serial% | find /i "connected to" >nul
if errorlevel 1 (
echo The connection was not successful
goto Serial_setting
) else (
%pyBin% -m uiautomator2 init
echo The connection was Successful
)
goto :eof

:KillAdb
Expand Down
14 changes: 7 additions & 7 deletions command/GenerateConsoleBatch.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
:: Used for "ADT-V4.bat" in :Create_Console-bat
:: Please make sure that: only call this batch when %cd% is %root%;
:: e.g.
:: call command\GenerateDownloadBatch.bat portable
:: call command\GenerateConsoleBatch.bat portable

@echo off
set "console-bat-filename=console.bat"
REM if "%DeployMode%"=="unknown" exit
call :GenerateDownloadBatch_Common
call :GenerateDownloadBatch-%~1
call :GenerateDownloadBatch_Common2
call :GenerateConsoleBatch_Common
call :GenerateConsoleBatch-%~1
call :GenerateConsoleBatch_Common2
goto :eof


rem ================= FUNCTIONS =================


:GenerateDownloadBatch_Common
:GenerateConsoleBatch_Common
( echo @rem
echo @echo off
echo.
Expand Down Expand Up @@ -50,7 +50,7 @@ echo if NOT exist toolkit\command md toolkit\command
echo del /Q toolkit\command\*.cmd ^>NUL 2^>NUL) > %console-bat-filename%
goto :eof

:GenerateDownloadBatch_Common2
:GenerateConsoleBatch_Common2
( REM :: Show the instructions
echo title Alas Console Debugger
echo echo This is an console to run adb, git, python and pip.
Expand All @@ -70,7 +70,7 @@ echo PROMPT $P$_$G$G$G
echo cmd /Q /K) >> %console-bat-filename%
goto :eof

:GenerateDownloadBatch-New
:GenerateConsoleBatch-New
( echo echo @"%%_pyBin%%\python.exe" "%%_pyBin%%\Scripts\pip3.exe" %%%%*^> toolkit\command\pip3.cmd
echo echo @"%%_pyBin%%\python.exe" "%%_pyBin%%\Scripts\pip.exe" %%%%*^> toolkit\command\pip.cmd
echo echo @"%%_pyBin%%\python.exe" "%%_pyBin%%\Scripts\wheel.exe" %%%%*^> toolkit\command\wheel.cmd
Expand Down
16 changes: 13 additions & 3 deletions command/Get.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ goto :eof

rem ================= FUNCTIONS =================

:Importo_Deploy

:: %cd%: "%root%"
:: Get %Language% , %Region% , %SystemType%
:Import_Main
Expand Down Expand Up @@ -65,9 +67,17 @@ echo If you misstype, you can set in Settings menu Option 3
echo =========================================================================
set /p serial_input=Please input - SERIAL ^(DEFAULT 127.0.0.1:5555 ^):
if "%serial_input%"=="" ( set "serial_input=127.0.0.1:5555" )
call command\Config.bat Serial %serial_input%
call command\ConfigTemplate.bat SerialTemplate %serial_input%

%adbBin% kill-server > nul 2>&1
%adbBin% connect %serial_input% | find /i "connected to" >nul
if errorlevel 1 (
echo The connection was not successful
goto Import_Serial
) else (
call command\Config.bat Serial %serial_input%
call command\ConfigTemplate.bat SerialTemplate %serial_input%
%pyBin% -m uiautomator2 init
echo The connection was Successful
)
echo =========================================================================
echo Old Serial: %Serial%
echo New Serial: %serial_input%
Expand Down

0 comments on commit 77f6836

Please sign in to comment.