diff --git a/GeometrA/src/ADB/adbRobot.py b/GeometrA/src/ADB/adbRobot.py index fa81e1e..1e0fb7a 100644 --- a/GeometrA/src/ADB/adbRobot.py +++ b/GeometrA/src/ADB/adbRobot.py @@ -8,7 +8,7 @@ if (platform.system() == 'Windows'): PATH = GEOMETRA_ROOT + '\\screenshot_pic\\' - ADB_COMMAND = 'adb' + ADB_COMMAND = RESOURCE_PATH.replace('\\', '/') + '/adb_resources/win/adb.exe' else: PATH = GEOMETRA_ROOT + '/screenshot_pic/' ADB_COMMAND = RESOURCE_PATH + '/adb_resources/mac/adb' @@ -19,8 +19,8 @@ def getAppsInfo(): # Get informations of all apps in aos device. if (platform.system() == 'Windows'): - getAppsInfoBatch = [r'.\\GeometrA\\static\\aos_info.bat'] - subprocess.call(getAppsInfoBatch) + getAppsInfoBatch = "set GEOMETRA_AAPT=" + RESOURCE_PATH + "\\aapt-arm-pie && "+ RESOURCE_PATH + "\\aos_info.bat" + subprocess.call(getAppsInfoBatch, shell=True) else: getAppsInfoScript = "export GEOMETRA_RESOURCE=" + RESOURCE_PATH + " && bash " + RESOURCE_PATH + "/aos_info.sh" subprocess.call(getAppsInfoScript, shell=True) @@ -136,7 +136,10 @@ def input_text(self, text): return "Error" def get_uiautomator_dump(self): - path = GEOMETRA_ROOT + "/dumpXML" + if (platform.system() == 'Windows'): + path = GEOMETRA_ROOT + "\\dumpXML" + else: + path = GEOMETRA_ROOT + "/dumpXML" wait = ADB_COMMAND + " wait-for-device" subprocess.call(wait, shell=True) @@ -147,7 +150,8 @@ def get_uiautomator_dump(self): os.makedirs(path) pull = ADB_COMMAND + " pull ./data/local/tmp/" + fileName + " " + path subprocess.call(pull, shell=True) - print(path + "/uidump.xml") + if (platform.system() == 'Windows'): + return path + "\\uidump.xml" return path + "/uidump.xml" def get_display(self): diff --git a/main.js b/main.js index 2e8b86b..4a8e1d0 100644 --- a/main.js +++ b/main.js @@ -80,7 +80,11 @@ const createPyProc = () => { if (guessPackaged()) { pyProc = require('child_process').execFile(script, [port]) } else { - pyProc = require('child_process').spawn('python', [script]) + if (process.platform === 'win32') { + pyProc = require('child_process').spawn('py', [script]) + } else { + pyProc = require('child_process').spawn('python', [script]) + } } if (pyProc != null) { @@ -121,17 +125,23 @@ const SCRCPY_RESOURCE_FOLDER = 'scrcpy-resources' const ADB_RESOURCE_FOLDER = 'adb_resources' const SCRCPY_BIN = 'scrcpy' const getScrcpyPath = () => { - if (process.platform === 'darwin') + if (process.platform === 'darwin') { return path.join(__dirname, RESOURCE_FOLDER, SCRCPY_RESOURCE_FOLDER, 'mac', SCRCPY_BIN) + } + if (process.platform === 'win32') { + return path.join(__dirname, SCRCPY_BIN + '.exe') + } return 'scrcpy' } -exports.startLive = function(callback) { +exports.startLive = function() { if (screenProcess !== null) { screenProcess.kill('SIGINT'); } const script = getScrcpyPath(); - if (script === 'scrcpy') { + if (script === 'scrcpy' ) { + return + } else if (process.platform === 'win32') { screenProcess = require('child_process').spawn(script); } else { screenProcess = require('child_process').execFile(script); diff --git a/package.json b/package.json index 1fa08f8..7c1a8bc 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "start": "electron .", "test": "echo \"Error: no test specified\" && exit 1", "build-mac": "npm run pack-py && npm run copy-resource-mac && rm -rf build && rm -rf main.spec && npm run pack", - "build-win": "npm run pack-py && npm run copy-resource-win && npm run pack", + "build-win": "del main.spec && rmdir build /s && rmdir pydist /s && npm run pack-py && npm run copy-resource-win && npm run pack && copy resources\\scrcpy-resources\\win dist\\GeometrA-win32-x64\\resources\\app && copy resources\\scrcpy-resources\\win\\scrcpy-server.jar dist\\GeometrA-win32-x64", "pack": "electron-packager . --out=dist --icon=static/logo --overwrite --ignore=\"aos_info.txt\" --ignore=\"build-dmg.json\" --ignore=\"geometra.dmg\" --ignore=\"requirements.txt\" --ignore=\"tests\" --ignore=\"testReport.xml\" --ignore=\"test_requirements.txt\"", "pack-py": "pyinstaller -y main.py --distpath pydist", "copy-resource-mac": "cp -r resources pydist/main", diff --git a/resources/adb_resources/win/adb.exe b/resources/adb_resources/win/adb.exe new file mode 100644 index 0000000..ef0a407 Binary files /dev/null and b/resources/adb_resources/win/adb.exe differ diff --git a/resources/aos_info.bat b/resources/aos_info.bat index e0649fb..163f8bb 100644 --- a/resources/aos_info.bat +++ b/resources/aos_info.bat @@ -1,43 +1,43 @@ @echo off chcp 65001 -break>aos_info.txt -break>tmp1.txt -break>tmp2.txt -break>tmp3.txt +break>%USERPROFILE%\.GeometrA\aos_info.txt +break>%USERPROFILE%\.GeometrA\tmp1.txt +break>%USERPROFILE%\.GeometrA\tmp2.txt +break>%USERPROFILE%\.GeometrA\tmp3.txt REM Push aapt files to android device -adb push ./GeometrA/static/aapt-arm-pie /data/local/tmp +adb push %GEOMETRA_AAPT% /data/local/tmp adb shell chmod 0755 /data/local/tmp/aapt-arm-pie REM adb shell pm list packages -3 -f >> aos_info.txt REM get list of packages and put into tmp.txt -@For /F "usebackq tokens=1-2 delims=:" %%i in (`adb shell pm list packages -3 -f`) do echo %%j >> tmp1.txt +@For /F "usebackq tokens=1-2 delims=:" %%i in (`adb shell pm list packages -3 -f`) do echo %%j >> %USERPROFILE%\.GeometrA\tmp1.txt -@For /F "usebackq tokens=1-2 delims==" %%i in (tmp1.txt) do ( - echo %%i >> tmp2.txt +@For /F "usebackq tokens=1-2 delims==" %%i in (%USERPROFILE%\.GeometrA\tmp1.txt) do ( + echo %%i >> %USERPROFILE%\.GeometrA\tmp2.txt ) -Del tmp1.txt +Del %USERPROFILE%\.GeometrA\tmp1.txt -@For /F %%i in (tmp2.txt) do ( - adb shell /data/local/tmp/aapt-arm-pie d badging %%i >> tmp3.txt +@For /F %%i in (%USERPROFILE%\.GeometrA\tmp2.txt) do ( + adb shell /data/local/tmp/aapt-arm-pie d badging %%i >> %USERPROFILE%\.GeometrA\tmp3.txt ) -Del tmp2.txt +Del %USERPROFILE%\.GeometrA\tmp2.txt set name= set version= -@For /F "usebackq tokens=1-2 delims=:" %%i in (tmp3.txt) do ( +@For /F "usebackq tokens=1-2 delims=:" %%i in (%USERPROFILE%\.GeometrA\tmp3.txt) do ( If "%%i"=="package" ( For /F "tokens=1-4" %%a in ("%%j") do ( echo ********************* echo %%a - echo|set /p=%%a >> aos_info.txt + echo|set /p=%%a >> %USERPROFILE%\.GeometrA\aos_info.txt echo %%c - echo|set /p=%%c >> aos_info.txt + echo|set /p=%%c >> %USERPROFILE%\.GeometrA\aos_info.txt ) ) If "%%i"=="application-label" ( - echo %%j >> aos_info.txt + echo %%j >> %USERPROFILE%\.GeometrA\aos_info.txt ) ) -Del tmp3.txt +Del %USERPROFILE%\.GeometrA\tmp3.txt adb shell rm -f /data/local/tmp/aapt-arm-pie diff --git a/resources/scrcpy-resources/win/AdbWinApi.dll b/resources/scrcpy-resources/win/AdbWinApi.dll new file mode 100644 index 0000000..7abe26c Binary files /dev/null and b/resources/scrcpy-resources/win/AdbWinApi.dll differ diff --git a/resources/scrcpy-resources/win/AdbWinUsbApi.dll b/resources/scrcpy-resources/win/AdbWinUsbApi.dll new file mode 100644 index 0000000..e7a6de1 Binary files /dev/null and b/resources/scrcpy-resources/win/AdbWinUsbApi.dll differ diff --git a/resources/scrcpy-resources/win/SDL2.dll b/resources/scrcpy-resources/win/SDL2.dll new file mode 100644 index 0000000..934f809 Binary files /dev/null and b/resources/scrcpy-resources/win/SDL2.dll differ diff --git a/resources/scrcpy-resources/win/adb.exe b/resources/scrcpy-resources/win/adb.exe new file mode 100644 index 0000000..ef0a407 Binary files /dev/null and b/resources/scrcpy-resources/win/adb.exe differ diff --git a/resources/scrcpy-resources/win/avcodec-58.dll b/resources/scrcpy-resources/win/avcodec-58.dll new file mode 100644 index 0000000..3edc198 Binary files /dev/null and b/resources/scrcpy-resources/win/avcodec-58.dll differ diff --git a/resources/scrcpy-resources/win/avformat-58.dll b/resources/scrcpy-resources/win/avformat-58.dll new file mode 100644 index 0000000..d375a48 Binary files /dev/null and b/resources/scrcpy-resources/win/avformat-58.dll differ diff --git a/resources/scrcpy-resources/win/avutil-56.dll b/resources/scrcpy-resources/win/avutil-56.dll new file mode 100644 index 0000000..ff74a9f Binary files /dev/null and b/resources/scrcpy-resources/win/avutil-56.dll differ diff --git a/resources/scrcpy-resources/win/scrcpy-noconsole.exe b/resources/scrcpy-resources/win/scrcpy-noconsole.exe new file mode 100644 index 0000000..078f2f6 Binary files /dev/null and b/resources/scrcpy-resources/win/scrcpy-noconsole.exe differ diff --git a/resources/scrcpy-resources/win/scrcpy-server.jar b/resources/scrcpy-resources/win/scrcpy-server.jar new file mode 100644 index 0000000..0e9b05a Binary files /dev/null and b/resources/scrcpy-resources/win/scrcpy-server.jar differ diff --git a/resources/scrcpy-resources/win/scrcpy.exe b/resources/scrcpy-resources/win/scrcpy.exe new file mode 100644 index 0000000..efde950 Binary files /dev/null and b/resources/scrcpy-resources/win/scrcpy.exe differ diff --git a/resources/scrcpy-resources/win/swresample-3.dll b/resources/scrcpy-resources/win/swresample-3.dll new file mode 100644 index 0000000..b5a3d38 Binary files /dev/null and b/resources/scrcpy-resources/win/swresample-3.dll differ