Feature: Add screen preview to the Android client
get_screenshot and the server's online-list and hover thumbnails were gated to Windows and X11 Linux. The Android client now answers COMMAND_SCREEN_PREVIEW_REQ on the main connection with TOKEN_SCREEN_PREVIEW_RSP plus a JPEG, and advertises CLIENT_CAP_SCREEN_PREVIEW at login only when it can really capture. Capture goes through AccessibilityService.takeScreenshot (API 30+), enabled by canTakeScreenshot in the service config. MediaProjection is deliberately not reused: its VirtualDisplay already feeds the H.264 encoder and Android 14+ refuses a second one from the same projection, while accessibility capture runs alongside the live stream. The JPEG is scaled to maxWidth and encoded in Kotlin; native only copies the bytes and drops a request while one is in flight. Only mode=screen is supported, and capabilities are re-evaluated on every login so turning the service off withdraws the capability. Also fix two review findings: a screenshot callback that lands after the 3 s timeout now recycles its bitmap instead of leaking it, and the server's failure hint lists the possible Android causes instead of asserting disabled accessibility. Verified on the emulator against a local debug server: get_screenshot returns 640x1422 and 720x1600 JPEGs, the 120-wide list thumbnail works, and both MCP tool-table checkers pass with apk added for get_screenshot, get_activity_history and get_client_log. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
66acde0301
commit
f29150d20e
6 files changed
+346
-16
No files matched your search
@@ -119,11 +119,15 @@ GATE = {
|
||||
# 支持面是产品定位的阶梯:win 100% > lnx 46% > mac 28% ≈ apk 16%。
|
||||
# Windows 是唯一全量支持的平台,check_platform_table.py 会把这条做成不变式。
|
||||
#
|
||||
# apk 现状:COMMAND_SYSTEM 与 COMMAND_SHELL 在 android/.../main.cpp:534-540 明确
|
||||
# 标注 not implemented,且客户端未声明 SCREEN_PREVIEW,故除服务端本地类外几乎全不支持。
|
||||
# apk 现状:COMMAND_SYSTEM 与 COMMAND_SHELL 在 android/.../main.cpp 明确标注 not
|
||||
# implemented,故除服务端本地类之外,只有少量按需补过分支的能力:运行日志
|
||||
# (COMMAND_QUERY_LOG)、活动历史(COMMAND_QUERY_ACTIVITY)、截屏
|
||||
# (COMMAND_SCREEN_PREVIEW_REQ,靠无障碍 takeScreenshot,Android 11+ 且开无障碍时
|
||||
# 登录才声明 SCREEN_PREVIEW 能力位)。
|
||||
_APK = ["win", "lnx", "mac", "apk"]
|
||||
_TRIO = ["win", "lnx", "mac"]
|
||||
_WL = ["win", "lnx"]
|
||||
_WLA = ["win", "lnx", "apk"]
|
||||
_WIN = ["win"]
|
||||
|
||||
PLATFORMS = {
|
||||
@@ -139,10 +143,11 @@ PLATFORMS = {
|
||||
"host_set_remark": _APK,
|
||||
"host_set_watch_level": _APK,
|
||||
|
||||
# SYSTEM / LIST_DRIVE / QUERY_LOG:三个桌面平台都实现了
|
||||
# SYSTEM / LIST_DRIVE / QUERY_LOG:三个桌面平台都实现了;APK 也实现了 QUERY_LOG
|
||||
# (android/.../main.cpp ClientLogThread → TOKEN_REPORT_LOG)
|
||||
"list_processes": _TRIO,
|
||||
"list_files": _TRIO,
|
||||
"get_client_log": _TRIO,
|
||||
"get_client_log": _APK,
|
||||
|
||||
# list_windows 只有 Windows:服务端把 COMMAND_WSLIST 发在主连接上,Linux/macOS
|
||||
# 主循环只处理 COMMAND_SYSTEM,WSLIST 只在 SystemManager 子连接里处理 —— 走不到,
|
||||
@@ -170,15 +175,16 @@ PLATFORMS = {
|
||||
"remote_mouse": _WL,
|
||||
"remote_clipboard": _WL,
|
||||
|
||||
# 需要 CLIENT_CAP_SCREEN_PREVIEW:Windows 恒有,Linux 仅在探测到 X11 桌面时声明
|
||||
"get_screenshot": _WL,
|
||||
# 需要 CLIENT_CAP_SCREEN_PREVIEW:Windows 恒有,Linux 仅在探测到 X11 桌面时声明,
|
||||
# Android 仅在无障碍服务在跑时声明(takeScreenshot,只支持 mode=screen)
|
||||
"get_screenshot": _WLA,
|
||||
|
||||
# ---- 仅 Windows ----
|
||||
"list_services": _WIN,
|
||||
"control_service": _WIN,
|
||||
"list_registry": _WIN,
|
||||
"get_keylog": _WIN,
|
||||
"get_activity_history": _WL, # Windows 前台窗口;Linux 桌面/无桌面均有实现(linux/main.cpp)
|
||||
"get_activity_history": _WLA, # Windows 前台窗口;Linux 桌面/无桌面均有实现(linux/main.cpp);APK 复用同一采样机
|
||||
"get_foreground_window": _WIN, # 窗口信息 RPC:CLIENT_CAP_WINDOW_INFO,仅 Windows 客户端声明
|
||||
"search_file": _WIN,
|
||||
"delete_path": _WIN,
|
||||
|
||||
Reference in new issue
Block a user