Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightlord851108 committed Jan 14, 2019
2 parents 1ccca6c + dba3d00 commit bf14488
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 27 deletions.
14 changes: 9 additions & 5 deletions GeometrA/src/ADB/adbRobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand Down
18 changes: 14 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Binary file added resources/adb_resources/win/adb.exe
Binary file not shown.
34 changes: 17 additions & 17 deletions resources/aos_info.bat
Original file line number Diff line number Diff line change
@@ -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
Binary file added resources/scrcpy-resources/win/AdbWinApi.dll
Binary file not shown.
Binary file added resources/scrcpy-resources/win/AdbWinUsbApi.dll
Binary file not shown.
Binary file added resources/scrcpy-resources/win/SDL2.dll
Binary file not shown.
Binary file added resources/scrcpy-resources/win/adb.exe
Binary file not shown.
Binary file added resources/scrcpy-resources/win/avcodec-58.dll
Binary file not shown.
Binary file added resources/scrcpy-resources/win/avformat-58.dll
Binary file not shown.
Binary file added resources/scrcpy-resources/win/avutil-56.dll
Binary file not shown.
Binary file not shown.
Binary file added resources/scrcpy-resources/win/scrcpy-server.jar
Binary file not shown.
Binary file added resources/scrcpy-resources/win/scrcpy.exe
Binary file not shown.
Binary file added resources/scrcpy-resources/win/swresample-3.dll
Binary file not shown.

0 comments on commit bf14488

Please sign in to comment.