feat: 内置并统一使用项目 ADB (#149)

This commit is contained in:
chengma
2026-08-11 12:01:07 +08:00
parent 56b1a46c5c
commit 8f2037db2f
21 changed files with 355 additions and 46 deletions
+13 -2
View File
@@ -16,6 +16,8 @@ import xml.etree.ElementTree as ET
from collections.abc import Callable
from typing import Any
from src.adb_runtime import configure_bundled_adb_environment
PDD_PACKAGE_NAME = "com.xunmeng.pinduoduo"
READY_MARKERS = ("发起拼单", "立即购买", "单独购买", "免拼购买", "快要抢光")
@@ -59,11 +61,20 @@ def wait_goods_ready(device: Any, first_xml: str, timeout: float) -> None:
def measure_once(serial: str, goods_url: str, cold: bool) -> dict[str, int]:
adb_executable = str(configure_bundled_adb_environment())
import uiautomator2 as u2
if cold:
subprocess.run(
["adb", "-s", serial, "shell", "am", "force-stop", PDD_PACKAGE_NAME],
[
adb_executable,
"-s",
serial,
"shell",
"am",
"force-stop",
PDD_PACKAGE_NAME,
],
check=True,
capture_output=True,
text=True,
@@ -80,7 +91,7 @@ def measure_once(serial: str, goods_url: str, cold: bool) -> dict[str, int]:
_, result["adb_device_check"] = measure_call(
"adb_device_check",
lambda: subprocess.run(
["adb", "-s", serial, "get-state"],
[adb_executable, "-s", serial, "get-state"],
check=True,
capture_output=True,
text=True,