Clarify WiFi ADB scan failure hint
This commit is contained in:
1 parent
5c98bb8353
commit
20e438ee13
2 files changed
+43
-2
No files matched your search
@@ -59,12 +59,16 @@ def _handle_scan_result(
|
||||
if len(connected) == 0 and len(unauthorized) == 0 and failed:
|
||||
# 端口开放但 adb connect 失败:通常是 adb 服务异常 / 设备处于诡异状态。
|
||||
# 把 adb 真实返回拼出来,让用户看到根因,而不是误导地说"请授权"。
|
||||
failed_targets = []
|
||||
for d in failed:
|
||||
msg = (d.message or "").strip().replace("\n", " | ")
|
||||
failed_targets.append(str(d.target or "").strip())
|
||||
on_line(f"[扫描] {d.target} 连接失败 (state=failed): {msg or '未知错误'}")
|
||||
sample_target = next((t for t in failed_targets if t), "<ip:port>")
|
||||
on_line(
|
||||
"[扫描] 提示:可在终端跑 `adb kill-server && adb connect <ip:port>` 看真实输出,"
|
||||
"或检查是否多个 adb 进程冲突"
|
||||
f"[扫描] 提示:多台 WiFi ADB 可同时在线;失败时先逐个执行 "
|
||||
f"`adb connect {sample_target}` 和 `adb devices -l` 看真实状态,"
|
||||
"若 adb server 状态异常再执行 `adb kill-server` 后重试"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
from gui.components.wifi_adb_one_click_scan import _handle_scan_result
|
||||
|
||||
|
||||
class _Var:
|
||||
def __init__(self):
|
||||
self.value = ""
|
||||
|
||||
def set(self, value):
|
||||
self.value = value
|
||||
|
||||
|
||||
def test_failed_scan_hint_mentions_multi_target_connect_without_saying_multiple_adb_conflict():
|
||||
logs: list[str] = []
|
||||
devs = [
|
||||
SimpleNamespace(
|
||||
target="192.168.10.105:44219",
|
||||
adb_state="failed",
|
||||
message="cannot connect",
|
||||
)
|
||||
]
|
||||
|
||||
_handle_scan_result(
|
||||
devs,
|
||||
on_line=logs.append,
|
||||
device_var=_Var(),
|
||||
refresh_devices=lambda: None,
|
||||
open_pick_dialog=lambda _devs: None,
|
||||
)
|
||||
|
||||
hint = "\n".join(logs)
|
||||
assert "adb connect 192.168.10.105:44219" in hint
|
||||
assert "adb devices -l" in hint
|
||||
assert "多个 adb 进程冲突" not in hint
|
||||
Reference in new issue
Block a user