fix: 删除任务/分组持久化(重启不再复活)+ feat: APK 安装支持本机 USB 设备
This commit is contained in:
+25
-16
@@ -274,27 +274,36 @@ class ApkManager:
|
||||
def _install_one(self, serial, apk_path, package_name=""):
|
||||
"""直连设备安装 APK。
|
||||
|
||||
serial 即设备的 adb 网络地址(IP:5555),直接 adb connect 即可。
|
||||
serial 为 adb 网络地址(IP:5555)时直接 adb connect;
|
||||
本机 USB 有线设备(serial 无冒号,如 ZY322XXXX)已在 adb 中,无需 connect。
|
||||
不经过 STF occupy/release,安装完断开连接,app 永久保留。
|
||||
"""
|
||||
from .adb_helper import _adb
|
||||
self._set_item(serial, "installing", f"正在连接 {serial}...")
|
||||
try:
|
||||
# adb connect(带重试,设备网络可能需要几次握手)
|
||||
connected = False
|
||||
last_out = ""
|
||||
for attempt in range(1, 4): # 最多 3 次
|
||||
out = _adb("connect", serial)
|
||||
last_out = out
|
||||
if "connected" in out.lower() and "failed" not in out.lower():
|
||||
connected = True
|
||||
break
|
||||
_log.info(f"[{serial}] adb connect 第{attempt}次: {out}")
|
||||
time.sleep(1 + attempt)
|
||||
if not connected:
|
||||
_log.warning(f"[{serial}] adb connect 失败: 输出={last_out}")
|
||||
self._set_item(serial, "failed", f"adb connect 失败: {last_out[:150]}")
|
||||
return
|
||||
if ":" in serial:
|
||||
# 网络设备:adb connect(带重试,设备网络可能需要几次握手)
|
||||
connected = False
|
||||
last_out = ""
|
||||
for attempt in range(1, 4): # 最多 3 次
|
||||
out = _adb("connect", serial)
|
||||
last_out = out
|
||||
if "connected" in out.lower() and "failed" not in out.lower():
|
||||
connected = True
|
||||
break
|
||||
_log.info(f"[{serial}] adb connect 第{attempt}次: {out}")
|
||||
time.sleep(1 + attempt)
|
||||
if not connected:
|
||||
_log.warning(f"[{serial}] adb connect 失败: 输出={last_out}")
|
||||
self._set_item(serial, "failed", f"adb connect 失败: {last_out[:150]}")
|
||||
return
|
||||
else:
|
||||
# 本机 USB 设备:确认已在 adb devices 列表中
|
||||
dev_out = _adb("devices")
|
||||
if serial not in (dev_out or ""):
|
||||
self._set_item(serial, "failed",
|
||||
"设备未在本地 adb 列表中,请检查 USB 连接/驱动")
|
||||
return
|
||||
|
||||
# 安装
|
||||
self._set_item(serial, "installing", "正在安装...")
|
||||
|
||||
Reference in New Issue
Block a user