feat: 强制安装APK(推送+pm install 绕过厂商弹窗)+ 定位设备(亮屏+大字定位页,结束定位关闭浏览器含后台)+ 一键亮屏/息屏(并发全部设备)
This commit is contained in:
+29
-3
@@ -305,12 +305,38 @@ class ApkManager:
|
||||
"设备未在本地 adb 列表中,请检查 USB 连接/驱动")
|
||||
return
|
||||
|
||||
# 安装
|
||||
self._set_item(serial, "installing", "正在安装...")
|
||||
# 强制安装:绕过厂商安全防护(MIUI 等用 adb install 会弹"通过 USB 安装应用"
|
||||
# 确认框需要手点;改为 推送 + pm install,shell 安装不弹窗)
|
||||
# 1. 关闭 adb 安装校验(包校验器/安全守护拦截)
|
||||
try:
|
||||
_adb("-s", serial, "shell", "settings", "put", "global",
|
||||
"verifier_verify_adb_installs", "0")
|
||||
except Exception:
|
||||
pass
|
||||
# 2. 推送 APK 到设备(大 APK 经 WiFi 推送较慢,超时与安装共用)
|
||||
self._set_item(serial, "installing", "正在推送 APK...")
|
||||
r = subprocess.run(
|
||||
[ADB_PATH, "-s", serial, "install", "-r", apk_path],
|
||||
[ADB_PATH, "-s", serial, "push", apk_path, "/data/local/tmp/_install.apk"],
|
||||
capture_output=True, timeout=_INSTALL_TIMEOUT
|
||||
)
|
||||
push_out = ((r.stdout or b"") + (r.stderr or b"")).decode("utf-8", errors="replace")
|
||||
if r.returncode != 0 or "1 file pushed" not in push_out:
|
||||
msg = push_out.strip().replace("\n", " ")[:150] or f"推送失败(returncode={r.returncode})"
|
||||
self._set_item(serial, "failed", msg)
|
||||
_log.warning(f"[{serial}] APK 推送失败: {msg}")
|
||||
return
|
||||
# 3. pm install 强制安装(-r 覆盖安装 / -t 允许测试包 / -d 允许降级版本)
|
||||
self._set_item(serial, "installing", "正在安装...")
|
||||
r = subprocess.run(
|
||||
[ADB_PATH, "-s", serial, "shell", "pm", "install", "-r", "-t", "-d",
|
||||
"/data/local/tmp/_install.apk"],
|
||||
capture_output=True, timeout=_INSTALL_TIMEOUT
|
||||
)
|
||||
# 4. 清理设备临时文件(失败残留下次推送会覆盖,不影响)
|
||||
try:
|
||||
_adb("-s", serial, "shell", "rm", "-f", "/data/local/tmp/_install.apk")
|
||||
except Exception:
|
||||
pass
|
||||
out = ((r.stdout or b"") + (r.stderr or b""))
|
||||
try:
|
||||
out = out.decode("utf-8", errors="replace")
|
||||
|
||||
Reference in New Issue
Block a user