fix: STF未就绪设备纳入维护终端列表(adb可达但agent启动失败,标记stf_not_ready)+ 卸载/检查agent自动先connect

This commit is contained in:
2026-08-17 11:02:43 +08:00
parent e48eeef49b
commit c111cb9a5e
3 changed files with 26 additions and 8 deletions
+11 -2
View File
@@ -1065,6 +1065,9 @@ def _merged_device_list():
"""本地 adb(含 USB)+ STF 在线设备池的合并列表([{serial, state}])。
供维护终端/剪贴板注入/应用版本管理等设备选择场景共用。
STF 里 adb 可达但 agent 未就绪的设备(手机端 agent 启动失败)也列入,
标记 stf_not_ready——这种设备恰恰需要用维护终端卸载/重装 agent 修复,
不列出来就永远无法修复(死循环)。
"""
states = {}
out = _adb("devices")
@@ -1075,8 +1078,13 @@ def _merged_device_list():
try:
for d in stf.list_all_devices():
serial = d.get("serial", "")
if serial and d.get("present") and d.get("ready") and serial not in states:
if not serial or serial in states:
continue
if d.get("present") and d.get("ready"):
states[serial] = "stf"
elif d.get("present") and not d.get("ready"):
# adb 可达但 STF agent 未就绪(启动失败/未安装):列入供修复
states[serial] = "stf_not_ready"
except Exception:
pass
return [{"serial": s, "state": st} for s, st in sorted(states.items())]
@@ -1085,7 +1093,8 @@ def _merged_device_list():
@app.route("/api/adb/devices")
@admin_required
def api_adb_devices():
"""维护终端设备列表(仅管理员):本地 adb 已连接 + STF 在线设备池。
"""维护终端设备列表(仅管理员):本地 adb 已连接 + STF 在线设备池
(含 agent 未就绪的待修复设备,state=stf_not_ready)。
供终端设备选择器使用——选中后自动附加 `-s <serial>`,
离线/未连接的设备也可选,配合"重连设备"按钮恢复。