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:
1 parent
445bd8bbb9
commit
a801a2999a
9 files changed
+306
-24
No files matched your search
@@ -322,7 +322,7 @@ const char* kServerInstructions =
|
||||
u8"GUI 自动化:remote_open 取得 session_id 与分辨率(screen_w/screen_h)→ get_screenshot 看画面 → "
|
||||
u8"get_foreground_window 确认前台窗口(或用 remote_mouse / remote_keyboard 的 expect_hwnd 做前置校验)→ "
|
||||
u8"remote_mouse / remote_keyboard 用归一化坐标(0..1)操作 → 必须 remote_close 释放会话,闲置会话会被回收。"
|
||||
u8"要防止真人操作打断自动化时用 remote_block_input 锁定对端键鼠(必须带 max_block_ms,到期自动解除;"
|
||||
u8"要防止真人操作打断自动化时用 remote_block_input 锁定对端键鼠(Windows/Android;必须带 max_block_ms,到期自动解除;"
|
||||
u8"客户端无管理员权限时 Windows 会让 BlockInput 静默失败,成功只代表命令已送达)。\n"
|
||||
u8"命令执行:exec_command 一次性取输出;需要保持 cd 或环境变量时用 terminal_open + terminal_exec,用毕 terminal_close。\n"
|
||||
u8"\n"
|
||||
@@ -2580,7 +2580,7 @@ std::string BuildToolsListResult(const Json::Value& id) {
|
||||
{
|
||||
Json::Value tool(Json::objectValue);
|
||||
tool["name"] = "remote_block_input";
|
||||
tool["description"] = u8"锁定或解除目标 Windows 主机的本机键鼠。做 GUI 自动化时先 block=true,真人碰一下鼠标就不会打断流程。必须带期限:max_block_ms(默认 300000 毫秒)到期由服务端自动解除,并在下一次调用结果的 auto_unblocked 里上报;remote_close 或会话闲置回收时服务端也会强制解除。两个限制:1) Windows 只在调用进程具备管理员权限(或 UIAccess)时才允许 BlockInput,普通权限的客户端会静默失败且不上报结果,所以本工具的成功只代表命令已送达、不保证真的锁住了——不要凭它断言对端已被锁;2) 若屏幕子连接因目标机断网被拆,服务端也再没有下发通道,只能等客户端进程退出(BlockInput 随调用线程结束自动释放)。仅 Windows 支持(Linux 客户端不处理该报文,直接报 -32005)。";
|
||||
tool["description"] = u8"锁定或解除目标主机的本机键鼠/触摸。做 GUI 自动化时先 block=true,真人碰一下屏幕就不会打断流程。必须带期限:max_block_ms(默认 300000 毫秒)到期由服务端自动解除,并在下一次调用结果的 auto_unblocked 里上报;remote_close 或会话闲置回收时服务端也会强制解除。Windows 用 BlockInput(),只在调用进程具备管理员权限(或 UIAccess)时为真,普通权限的客户端会静默失败且不上报结果;Android 用无障碍全屏透明 overlay 吃掉触摸,服务端注入的手势在飞行期间临时放行(等价于 Windows 在 ProcessCommand 前后 BlockInput(false) 的包裹),不声明相应能力位的老 APK 返回 -32005。两个限制:1) 成功只代表命令已送达,不保证真的锁住了——不要凭它断言对端已被锁;2) 若屏幕子连接因目标机断网被拆,服务端就再没有下发通道(Windows 只能等客户端进程退出,Android 客户端会在子连接断开时主动撤掉 overlay)。Linux/macOS 不支持,返回 -32005。";
|
||||
tool["inputSchema"] = BuildRemoteBlockInputInputSchema();
|
||||
tool["outputSchema"] = BuildRemoteBlockInputOutputSchema();
|
||||
tools.append(tool);
|
||||
@@ -2968,6 +2968,9 @@ void AppendHostTechnicalDetail(CMy2015RemoteDlg* parent, uint64_t devId, Json::V
|
||||
caps["registry"] = IsWindowsClient(ctx);
|
||||
// windowInfo → get_foreground_window / host_list_windows 的矩形与 activate(SupportsWindowInfo)
|
||||
caps["windowInfo"] = ctx->SupportsWindowInfo();
|
||||
// privacyOverlay → Android 的 remote_block_input(无障碍 overlay)。Windows 恒可用、
|
||||
// 不声明这个位,所以这里只对「非 Windows 且声明了能力位」的主机为 true。
|
||||
caps["privacyOverlay"] = ctx->SupportsPrivacyOverlay();
|
||||
host["capabilities"] = caps;
|
||||
}
|
||||
|
||||
@@ -6855,10 +6858,16 @@ std::string BuildRemoteBlockInput(const Json::Value& id, const Json::Value& args
|
||||
if (!ResolveScreenCtrlSessionHost(id, args, parent, devId, ctx, errJson))
|
||||
return errJson;
|
||||
|
||||
// Linux/Android 客户端根本没有 COMMAND_SCREEN_BLOCK_INPUT 分支(静默忽略),只做报文的
|
||||
// 服务端不做「发了就算成功」的假动作——直接报不支持(能力限制,非参数错误)。
|
||||
if (!IsWindowsClient(ctx))
|
||||
return BuildError(id, -32005, "remote_block_input is only supported on Windows hosts");
|
||||
// 平台门:Windows 用 BlockInput();Android 新版用无障碍全屏 overlay 吃掉本机触摸
|
||||
// (CLIENT_CAP_PRIVACY_OVERLAY);Linux/macOS 与老 APK 根本没有 COMMAND_SCREEN_BLOCK_INPUT
|
||||
// 分支(静默忽略),服务端不做「发了就算成功」的假动作——直接按能力限制拒绝。
|
||||
if (!IsWindowsClient(ctx)) {
|
||||
if (ctx->GetAdditionalData(RES_CLIENT_TYPE) != "APK")
|
||||
return BuildError(id, -32005, "remote_block_input is only supported on Windows and Android hosts");
|
||||
if (!ctx->SupportsPrivacyOverlay())
|
||||
return BuildError(id, -32005, "Android client is too old for remote_block_input: "
|
||||
"the APK has no input-block overlay, upgrade the client first");
|
||||
}
|
||||
|
||||
std::string sessionId = GetStringArg(args, "session_id");
|
||||
if (sessionId.empty())
|
||||
@@ -10296,7 +10305,7 @@ const ToolPlatform kToolPlatforms[] = {
|
||||
{ "list_services", kPlatWin },
|
||||
{ "get_keylog", kPlatWin },
|
||||
{ "list_registry", kPlatWin },
|
||||
{ "remote_block_input", kPlatWin },
|
||||
{ "remote_block_input", kPlatWin|kPlatApk },
|
||||
// 两端并集。方向性差异由 CollectTargetReqs 精确处理:源端必须 win,目标端 win/lnx/mac
|
||||
{ "copy_files_c2c", kPlatWin|kPlatLnx|kPlatMac },
|
||||
{ "operate_window", kPlatWin },
|
||||
|
||||
Reference in new issue
Block a user