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

+14 -3
View File
@@ -121,8 +121,8 @@
| 连接列表 / 断开连接 | `COMMAND_CONNECTION` / `COMMAND_KILL_CONNECTION` | ✅ `list_network_connections` / `kill_network_connection` | — |
| 屏幕截图 | `COMMAND_SCREEN_PREVIEW_REQ` | ✅ `get_screenshot` | — |
| 鼠标 / 键盘 / 剪贴板写 | `COMMAND_SCREEN_CONTROL` + `MSG64` | ✅ `remote_*` | — |
| **锁定对端键鼠** | `COMMAND_SCREEN_BLOCK_INPUT`(2 字节) | ❌ **缺** | **零客户端改动**(无回包) |
| 黑屏 / Ctrl+Alt+Del | `COMMAND_SCREEN_BLANK` / `COMMAND_SCREEN_CTRL_ALT_DEL` | Ctrl+Alt+Del → ✅ `remote_lock_screen`(仅 Android,映射为锁屏);黑屏 ❌ | 黑屏**客户端未实现**,需客户端改动 |
| **锁定对端键鼠** | `COMMAND_SCREEN_BLOCK_INPUT`(2 字节) | ✅ `remote_block_input`(Windows `BlockInput()`;Android 无障碍全屏透明 overlay,`CLIENT_CAP_PRIVACY_OVERLAY`) | 无回包;Android 侧在注入手势期间临时放行(等价 Windows 的 `BlockInput(false)` 包裹) |
| 黑屏 / Ctrl+Alt+Del | `COMMAND_SCREEN_BLANK` / `COMMAND_SCREEN_CTRL_ALT_DEL` | Ctrl+Alt+Del → ✅ `remote_lock_screen`(仅 Android,映射为锁屏);黑屏 → Android 客户端已实现处理,**未暴露为 MCP 工具** | 见 §3.1 注:Android 的黑色 overlay 会被 MediaProjection 一起抓走,主控画面同步变黑,无法做成「对端看不见、主控看得见」 |
| 窗口级 / 区域捕获 | `COMMAND_SCREEN_WINDOW` / `COMMAND_SCREEN_ROI` | ❌ | 流式接口,需评估(见 §4.2) |
| 注册表读 | `COMMAND_REGEDIT` + `COMMAND_REG_FIND` | ✅ `list_registry`(子键 + 值) | — |
| **注册表写** | 无命令 | ❌ | **需客户端改动** |
@@ -215,7 +215,7 @@ MCP 现在能读、能传、能搜,**唯独不能删、不能改名、不能
## 3. 新工具(P10-C):远程控制补全 + 工具族去重
### 3.1 `remote_block_input`(P10-C,零客户端改动)
### 3.1 `remote_block_input`(P10-C;Windows 零客户端改动,Android 需新版 APK)
| 项 | 内容 |
|---|---|
@@ -231,6 +231,17 @@ MCP 现在能读、能传、能搜,**唯独不能删、不能改名、不能
`BlockInput` 在进程退出时会自动解除,所以真正的死锁风险只出现在「客户端进程活着但会话丢了」——上面两条正好覆盖。
**Android 版(`CLIENT_CAP_PRIVACY_OVERLAY`)**:客户端在无障碍服务上挂一个全屏透明
`TYPE_ACCESSIBILITY_OVERLAY` 吃掉触摸,服务端注入的手势在飞行期间把 overlay 临时置
`FLAG_NOT_TOUCHABLE`(相当于 Windows 在 `ProcessCommand` 前后 `BlockInput(false)` 再恢复)。
子连接断开时客户端自己撤掉 overlay——Android 没有「随调用线程退出自动解除」这层兜底。
**黑屏(`COMMAND_SCREEN_BLANK`)为什么没有做成工具**:Windows 上黑屏窗口可以用
`WDA_EXCLUDEFROMCAPTURE` 从抓屏里排除,所以「本机全黑、主控照常看画面」成立;Android 的
MediaProjection 抓的是合成后的帧缓冲,无障碍 overlay 无论是否 `FLAG_SECURE` 都会被抓到
(后者在画面里就是黑的),做了也是把主控一起弄瞎。客户端仍实现该命令(协议完整性,
将来 MFC 界面若加「隐私屏」菜单项可直接下发),但 MCP 侧不提供对应工具。
### 3.2 工具族重叠:`list_*` vs `host_list_*`(P10-A,纯文档/描述改动)
**这是当前最容易被忽略、但对模型影响最大的问题**。同一件事有两套工具,走两条完全不同的链路,门控也不同: