阶段2: USB 远程 adb server 打通(220 host 网络 5037 全接口监听,无需改 220)+ 自建远程看屏(MJPEG 流 + u2 触控 tap/swipe/key/text,ws-scrcpy 不在 npm 改自建)
This commit is contained in:
+21
-2
@@ -17,7 +17,8 @@ import time
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
from core.adb_helper import _adb
|
||||
from config import USB_ADB_HOST, USB_ADB_PORT
|
||||
from core.adb_helper import _adb, _adb_remote
|
||||
from core.logger import get_logger
|
||||
from core.models import db, Device
|
||||
|
||||
@@ -61,13 +62,31 @@ def list_devices():
|
||||
|
||||
# ================== 在线状态 ==================
|
||||
def list_online():
|
||||
"""本机 adb devices 中 state=device 的设备(实时)。"""
|
||||
"""本机 adb 中 state=device 的设备 + 池内 USB 设备(经 220 远程 adb server)。
|
||||
|
||||
池内无 USB 设备(serial 无冒号)时不查远程 server,零额外开销。
|
||||
"""
|
||||
out = _adb("devices") or ""
|
||||
serials = []
|
||||
for line in out.splitlines()[1:]:
|
||||
parts = line.split()
|
||||
if len(parts) >= 2 and parts[0] and parts[1] == "device":
|
||||
serials.append(parts[0])
|
||||
# 池内有 USB 设备时,补查远程 adb server(220,host 网络 5037 全接口监听)
|
||||
try:
|
||||
usb = [s for s in list_configured() if ":" not in s]
|
||||
except Exception:
|
||||
usb = []
|
||||
if usb:
|
||||
try:
|
||||
out = _adb_remote(USB_ADB_HOST, USB_ADB_PORT, "devices") or ""
|
||||
for line in out.splitlines()[1:]:
|
||||
parts = line.split()
|
||||
if len(parts) >= 2 and parts[0] and parts[1] == "device":
|
||||
if parts[0] not in serials:
|
||||
serials.append(parts[0])
|
||||
except Exception:
|
||||
pass
|
||||
return serials
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user