Feature: Support input blocking and privacy overlay on Android hosts

remote_block_input rejected anything but Windows because the Android
client had no COMMAND_SCREEN_BLOCK_INPUT handler. This adds the overlay
on the client and the server gating, and wires up COMMAND_SCREEN_BLANK.

Client: the accessibility service hangs a full-screen
TYPE_ACCESSIBILITY_OVERLAY on itself. block=true makes it transparent
and touchable so it swallows physical taps; black=true paints it black.
Both are absolute states, so repeated commands are idempotent, and the
handler clears the overlay when the screen sub-connection dies (Android
has no "released when the calling thread exits" fallback). During a
remote gesture the overlay is flipped to FLAG_NOT_TOUCHABLE, mirroring
Windows' BlockInput(false) wrap; the flag change and the injection must
be separated by a short delay or the gesture is swallowed.

Server: CLIENT_CAP_PRIVACY_OVERLAY distinguishes new APKs from old ones;
Linux/macOS and old APKs still get -32005 up front. Tool masks,
instructions and mcp/tools.json follow the change. COMMAND_SCREEN_BLANK
is implemented but not exposed as a tool: MediaProjection captures the
overlay, so blacking out the screen blinds the operator too and cannot
emulate Windows' WDA_EXCLUDEFROMCAPTURE.

Verified on the Android 15 emulator: blocked taps are swallowed while
remote clicks still land, the block re-arms after each gesture, the
watchdog auto-unblocks at the deadline, a dropped sub-connection clears
the overlay, and a black overlay shows up in both screencap and
get_screenshot. The committed ghost.apk is stale; rebuild before release.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-11 21:58:54 +01:00
1 parent 445bd8bbb9
commit a801a2999a
9 files changed
+306 -24

No files matched your search

+3
View File
@@ -149,6 +149,7 @@ inline int isValid_10s()
#define CLIENT_CAP_UNINSTALL 0x2000 // 主连接处理 TOKEN_UNINSTALL(Android 拉起系统卸载确认框;Windows 客户端一直支持但不声明)
#define CLIENT_CAP_REMOTE_CHAT 0x4000 // 主连接处理 COMMAND_CHAT(远程交谈子连接;Windows 一直支持但不声明,目前只有新版 Android 声明)
#define CLIENT_CAP_TERMINAL 0x8000 // 主连接处理 COMMAND_SHELL(PTY 终端子连接:exec_command / terminal_*;Linux 一直支持但不声明,目前只有新版 Android 声明)
#define CLIENT_CAP_PRIVACY_OVERLAY 0x10000 // 屏幕子连接处理 COMMAND_SCREEN_BLOCK_INPUT / COMMAND_SCREEN_BLANK(Android 用无障碍全屏 overlay 实现;Windows 一直支持锁定键鼠但不声明这个位)
#define TALK_DLG_MAXLEN 1024 // 最大输入字符长度
@@ -1310,6 +1311,8 @@ typedef struct LOGIN_INFOR {
caps |= CLIENT_CAP_SCREEN_CLIPBOARD;
// 锁屏(COMMAND_SCREEN_CTRL_ALT_DEL → GLOBAL_ACTION_LOCK_SCREEN)依赖无障碍服务
// 与 API 28+,和其它运行时能力一样由 main.cpp 登录前探测后追加,不在默认位里声明。
// 同理:键鼠锁定 / 黑屏(COMMAND_SCREEN_BLOCK_INPUT / COMMAND_SCREEN_BLANK →
// CLIENT_CAP_PRIVACY_OVERLAY)要靠无障碍服务挂全屏 overlay,也在登录前按运行时状态追加。
// 卸载主机(TOKEN_UNINSTALL):命令处理是编译进来的,老 APK 收到只会静默丢弃,
// 服务端据此提前拒绝,而不是发一条没人接的命令后假报 ok。
caps |= CLIENT_CAP_UNINSTALL;