diff --git a/.idea/iOSAI.iml b/.idea/iOSAI.iml
index c969471..6cb8b9a 100644
--- a/.idea/iOSAI.iml
+++ b/.idea/iOSAI.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 0364d80..db8786c 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index eaf5365..b5fa875 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,8 +5,15 @@
+
+
+
+
+
+
+
@@ -67,23 +74,25 @@
"git-widget-placeholder": "main",
"javascript.nodejs.core.library.configured.version": "20.17.0",
"javascript.nodejs.core.library.typings.version": "20.17.58",
- "last_opened_file_path": "C:/Users/zhangkai/Desktop/last-item/Storage",
+ "last_opened_file_path": "E:/code/Python/iOSAi/resources/iproxy",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "org.jetbrains.plugins.gitlab.GitLabSettingsConfigurable",
+ "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
"two.files.diff.last.used.file": "E:/share/iOSAI/Module/FlaskService.py",
"vue.rearranger.settings.migration": "true"
}
}
+
+
@@ -172,7 +181,7 @@
-
+
diff --git a/Module/DeviceInfo.py b/Module/DeviceInfo.py
index 7fcae33..d6b93e7 100644
--- a/Module/DeviceInfo.py
+++ b/Module/DeviceInfo.py
@@ -1,15 +1,16 @@
import os
import signal
import subprocess
-import threading
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
from typing import Dict, Optional, List
+import tidevice
import wda
from tidevice import Usbmux, ConnectionType
from tidevice._device import BaseDevice
from Entity.DeviceModel import DeviceModel
+from Entity.Variables import WdaAppBundleId
from Module.FlaskSubprocessManager import FlaskSubprocessManager
from Utils.LogManager import LogManager
@@ -46,11 +47,18 @@ class DeviceInfo:
def _add_device(self, udid: str):
if not self._trusted(udid):
return
+ r = self.startWda(udid)
+ if r is False:
+ LogManager.info("启动wda失败")
+ return
+ w, h, s = self._screen_info(udid)
+ if w == 0 or h == 0 or s == 0:
+ print("未获取到设备屏幕信息")
+ return
port = self._alloc_port()
proc = self._start_iproxy(udid, port)
if not proc:
return
- w, h, s = self._screen_info(udid)
model = DeviceModel(deviceId=udid, screenPort=port,
width=w, height=h, scale=s, type=1)
model.ready = True
@@ -75,14 +83,30 @@ class DeviceInfo:
except Exception:
return False
+ def startWda(self, udid):
+ print("进入启动wda方法")
+ try:
+ dev = tidevice.Device(udid)
+ print("获取tidevice对象成功,准备启动wda")
+ dev.app_start(WdaAppBundleId)
+ print("启动wda成功")
+ time.sleep(3)
+ return True
+ except Exception as e:
+ print("启动wda遇到错误:", e)
+ return False
+
def _screen_info(self, udid: str):
try:
c = wda.USBClient(udid, 8100)
+ c.home()
size = c.window_size()
scale = c.scale
return int(size.width), int(size.height), float(scale)
- except Exception:
- return 828, 1792, 2.0
+ return 0, 0, 0
+ except Exception as e:
+ print("获取设备信息遇到错误:",e)
+ return 0, 0, 0
...
# ---------------- 原来代码不变,只替换下面一个函数 ----------------
diff --git a/Module/FlaskService.py b/Module/FlaskService.py
index f65865d..78a293d 100644
--- a/Module/FlaskService.py
+++ b/Module/FlaskService.py
@@ -151,6 +151,12 @@ def deviceList():
LogManager.error("获取设备列表失败:", e)
return ResultData(data=[]).toJson()
+# 传递token
+@app.route('/passToken', methods=['POST'])
+def passToken():
+ data = request.get_json()
+ print(data)
+ return ResultData(data="").toJson()
# 获取设备应用列表
@app.route('/deviceAppList', methods=['POST'])
@@ -400,7 +406,6 @@ def monitorMessages():
manager = ScriptManager()
event = threading.Event()
thread = threading.Thread(target=manager.replyMessages, args=(udid, event))
- thread.start()
# 添加到线程管理
ThreadManager.add(udid, thread, event)
return ResultData(data="").toJson()
diff --git a/Module/Main.py b/Module/Main.py
index 3d5fb0b..8b8a9f3 100644
--- a/Module/Main.py
+++ b/Module/Main.py
@@ -2,9 +2,6 @@ import os
import sys
from pathlib import Path
-import wda
-
-import tidevice
from Module.DeviceInfo import DeviceInfo
from Module.FlaskSubprocessManager import FlaskSubprocessManager
from Utils.DevDiskImageDeployer import DevDiskImageDeployer
@@ -27,32 +24,19 @@ if "--role=flask" in sys.argv:
_run_flask_role()
sys.exit(0)
+def main(arg):
+ print(arg)
+ if len(arg) != 2:
+ sys.exit(0)
+ else:
+ if arg[1] != "iosai":
+ sys.exit(0)
# 项目入口
if __name__ == "__main__":
- wda.debug = True
-
- # 1. 打包环境
- if hasattr(sys, '_MEIPASS'):
- base_dir = sys._MEIPASS
- # 2. 源码调试环境
- else:
- base_dir = os.path.dirname(
- os.path.dirname(os.path.abspath(__file__)) # 向上跳一级
- )
-
- # 3. 拼 iproxy 目录
- iproxy_dir = os.path.join(base_dir, 'resources', 'iproxy')
-
- # 4. 剩余逻辑不变
- if os.path.isdir(iproxy_dir):
- sep = os.pathsep
- old_path = os.environ.get('PATH', '')
- if iproxy_dir not in old_path:
- os.environ['PATH'] = old_path + sep + iproxy_dir
- else:
- print(f'warning: {iproxy_dir} not found', file=sys.stderr)
+ # 获取启动时候传递的参数
+ main(sys.argv)
# 添加iOS开发包到电脑上
deployer = DevDiskImageDeployer(verbose=True)
@@ -69,15 +53,13 @@ if __name__ == "__main__":
except Exception as e:
print("[WARN] Device listener not running:", e)
-
# === 保活:阻塞主线程,直到收到 Ctrl+C/关闭 ===
import threading, time, signal
-
stop = threading.Event()
def _handle(_sig, _frm):
stop.set()
-
+
# Windows 上 SIGINT/SIGTERM 都可以拦到
try:
signal.signal(signal.SIGINT, _handle)
diff --git a/Module/__pycache__/DeviceInfo.cpython-312.pyc b/Module/__pycache__/DeviceInfo.cpython-312.pyc
index b76a677..213890b 100644
Binary files a/Module/__pycache__/DeviceInfo.cpython-312.pyc and b/Module/__pycache__/DeviceInfo.cpython-312.pyc differ
diff --git a/Module/__pycache__/FlaskService.cpython-312.pyc b/Module/__pycache__/FlaskService.cpython-312.pyc
index 77fccbb..c94e9d2 100644
Binary files a/Module/__pycache__/FlaskService.cpython-312.pyc and b/Module/__pycache__/FlaskService.cpython-312.pyc differ
diff --git a/Module/__pycache__/Main.cpython-312.pyc b/Module/__pycache__/Main.cpython-312.pyc
index c284234..8904565 100644
Binary files a/Module/__pycache__/Main.cpython-312.pyc and b/Module/__pycache__/Main.cpython-312.pyc differ
diff --git a/build-tidevice.bat b/build-tidevice.bat
index 49725b2..598d2d9 100644
--- a/build-tidevice.bat
+++ b/build-tidevice.bat
@@ -1,13 +1,13 @@
-pyinstaller -F -n tidevice ^
- --hidden-import=tidevice._proto ^
- --hidden-import=tidevice._instruments ^
- --hidden-import=tidevice._usbmux ^
- --hidden-import=tidevice._wdaproxy ^
- --collect-all tidevice ^
- --noconsole ^
- --add-data="C:\Users\milk\AppData\Local\Programs\Python\Python312\Lib\site-packages\tidevice;tidevice" ^
- tidevice_entry.py
-
-@REM pyinstaller -F -n tidevice -noconsole ^
+@REM pyinstaller -F -n tidevice ^
+@REM --hidden-import=tidevice._proto ^
+@REM --hidden-import=tidevice._instruments ^
+@REM --hidden-import=tidevice._usbmux ^
+@REM --hidden-import=tidevice._wdaproxy ^
@REM --collect-all tidevice ^
-@REM tidevice_entry.py
\ No newline at end of file
+@REM --noconsole ^
+@REM --add-data="C:\Users\milk\AppData\Local\Programs\Python\Python312\Lib\site-packages\tidevice;tidevice" ^
+@REM tidevice_entry.py
+
+pyinstaller -F -n tidevice ^
+ --collect-all tidevice ^
+ tidevice_entry.py
\ No newline at end of file
diff --git a/build.bat b/build.bat
index cd6ebc3..25cfd62 100644
--- a/build.bat
+++ b/build.bat
@@ -1,58 +1,10 @@
-@REM python -m nuitka "Module/Main.py" ^
-@REM --standalone ^
-@REM --msvc=latest ^
-@REM --windows-console-mode=disable ^
-@REM --output-filename=IOSAI ^
-@REM --include-package=Module,Utils,Entity,script ^
-@REM --include-module=flask ^
-@REM --include-module=flask_cors ^
-@REM --include-module=lxml ^
-@REM --include-module=lxml.etree ^
-@REM --include-module=requests ^
-@REM --include-module=urllib3 ^
-@REM --include-module=certifi ^
-@REM --include-module=idna ^
-@REM --include-data-files="E:/code/Python/iOSAI/.venv/Scripts/tidevice.exe=tidevice.exe" ^
-@REM --include-data-dir="E:/code/Python/iOSAI/.venv/Scripts=Scripts" ^
-@REM --include-data-dir="E:/code/Python/iOSAI/SupportFiles=SupportFiles" ^
-@REM --include-data-dir="E:/code/Python/iOSAI/resources=resources" ^
-@REM --include-data-files="E:/code/Python/iOSAI/resources/iproxy/*=resources/iproxy/" ^
-@REM --windows-icon-from-ico="E:/code/Python/iOSAI/resources/icon.ico"
-
-
-
-@REM python -m nuitka "Module/Main.py" ^
-@REM --standalone ^
-@REM --msvc=latest ^
-@REM --windows-console-mode=force ^
-@REM --output-filename=IOSAI ^
-@REM --include-package=Module,Utils,Entity,script ^
-@REM --include-module=flask ^
-@REM --include-module=wda ^
-@REM --include-module=flask_cors ^
-@REM --include-module=lxml ^
-@REM --include-module=lxml.etree ^
-@REM --include-module=requests ^
-@REM --include-module=urllib3 ^
-@REM --include-module=certifi ^
-@REM --include-module=idna ^
-@REM --include-module=setuptools ^
-@REM --include-module=tidevice ^
-@REM --include-data-dir=resources=resources ^
-@REM --include-data-dir=SupportFiles=SupportFiles ^
-@REM --include-data-files="E:/code/Python/iOSAi/resources/iproxy/*=resources/iproxy/" ^
-@REM --include-data-files=resources/icon.ico=resources/icon.ico ^
-@REM --jobs=20 ^
-@REM --windows-icon-from-ico=resources/icon.ico
-
-
python -m nuitka Module\Main.py ^
--standalone ^
--msvc=latest ^
- --windows-console-mode=force ^
+ --windows-console-mode=disable ^
--output-filename=IOSAI ^
--include-package=Module,Utils,Entity,script ^
- --include-module=flask,wda,flask_cors,lxml,lxml.etree,requests,urllib3,certifi,idna,setuptools,tidevice ^
+ --include-module=flask,wda,psutil,portalocker,flask_cors,cv2,lxml.etree,requests,urllib3,certifi,idna,setuptools,tidevice ^
--include-data-dir=resources=resources ^
--include-data-dir=SupportFiles=SupportFiles ^
--include-data-files="E:/code/Python/iOSAi/resources/iproxy/*=resources/iproxy/" ^
diff --git a/resources/iproxy/tidevice.exe b/resources/iproxy/tidevice.exe
deleted file mode 100644
index e57f50f..0000000
Binary files a/resources/iproxy/tidevice.exe and /dev/null differ