This commit is contained in:
eric
2026-03-29 03:35:05 -05:00
parent 895dafc0e0
commit 22061fb3c8
14 changed files with 669 additions and 94 deletions

View File

@@ -431,16 +431,34 @@ async def android_logcat_recent(serial: str, lines: int = 200) -> str:
return await _shell(serial, f"logcat -d -t {n}", timeout=60.0)
def _strip_to_png(data: bytes) -> bytes:
if not data:
return data
stripped = data.lstrip().replace(b"\r\n", b"\n")
sig = b"\x89PNG\r\n\x1a\n"
idx = stripped.find(sig)
if idx > 0:
stripped = stripped[idx:]
if stripped.startswith(b"\n\x89PNG"):
stripped = stripped[1:]
return stripped
async def android_screenshot(serial: str, *, exec_timeout: float = 14.0) -> bytes:
if not serial:
raise ValueError("Missing Android device serial")
code, data, err = await _adb_binary(serial, "exec-out", "screencap", "-p", timeout=exec_timeout)
if code == 0 and data:
normalized = data.replace(b"\r\n", b"\n")
if _is_png(data) or normalized.startswith(b"\x89PNG"):
normalized = _strip_to_png(data)
if _is_png(normalized):
return normalized
last_err = err or "exec-out screencap failed"
code_sh, data_sh, err_sh = await _adb_binary(serial, "shell", "screencap", "-p", timeout=exec_timeout)
if code_sh == 0 and data_sh:
normalized_sh = _strip_to_png(data_sh)
if _is_png(normalized_sh):
return normalized_sh
last_err = err_sh or err or "screencap failed"
for remote in ("/data/local/tmp/live-cap.png", "/sdcard/live-cap.png"):
tmp = Path(tempfile.mkstemp(suffix=".png")[1])
try:

View File

@@ -619,6 +619,7 @@ def stack_summary() -> dict:
netd = env.get("NETDATA_PORT", "19999")
srs_http = env.get("SRS_HTTP_PORT", "8080")
srs_api = env.get("SRS_API_PORT", "1985")
srs_rtmp = env.get("SRS_RTMP_PORT", "1935")
android_panel = env.get("ANDROID_PANEL_PORT", "5000")
chrome_dbg = env.get("BROWSER_REMOTE_DEBUG_PORT", "9222")
neko_port = env.get("NEKO_HTTP_PORT", "9200")
@@ -628,6 +629,8 @@ def stack_summary() -> dict:
"filebrowser": f"http://{mdns_host}:{fb}",
"netdata": f"http://{mdns_host}:{netd}",
"srs_http": f"http://{mdns_host}:{srs_http}/",
"srs_rtmp_publish": f"rtmp://{mdns_host}:{srs_rtmp}/live/livestream",
"srs_play_flv": f"http://{mdns_host}:{srs_http}/live/livestream.flv",
"srs_api": f"http://{mdns_host}:{srs_api}/api/v1/versions",
"ws_scrcpy": f"http://{mdns_host}:{android_panel}",
"chromium_remote_debug": f"http://{mdns_host}:{chrome_dbg}",