Feature: Add remote lock screen for Android hosts

Implement the Ctrl+Alt+Del path on Android as a system lock screen.
Android has no secure attention sequence, so COMMAND_SCREEN_CTRL_ALT_DEL
is mapped in the client to GLOBAL_ACTION_LOCK_SCREEN and the server
exposes it as the new MCP tool remote_lock_screen.

The Android client resolves ControlService.lockScreen()/canLockScreen()
in nativeInit and dispatches the command from the screen sub-connection
through the usual attach/detach JNI path. The lock action is posted to
the accessibility service handler because performGlobalAction must not
run on the receiver thread.

Login advertises the new CLIENT_CAP_LOCK_SCREEN bit only when the
accessibility service is bound and the API level is 28+, so the server
can reject old APKs and Windows/Linux hosts up front instead of
reporting a lock that never happened. There is no receipt: a successful
call only means the command was delivered, and the tool description
tells the caller to confirm with get_screenshot.

Server side adds the schema and handler next to remote_clipboard, audits
the call, and gates it on client type plus the capability bit. Since it
is the only APK-only tool, check_platform_table.py gains a documented
exemption from the Windows baseline invariant, and make_tools_json.py
learns an APK-only platform set. tools.json is regenerated from the live
server and the plan document now counts 62 tools.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-11 20:59:10 +01:00
1 parent 0a0b709e8a
commit fd1b085279
11 files changed
+264 -14

No files matched your search

@@ -71,6 +71,36 @@ class ControlService : AccessibilityService() {
return text.filterNot { it in '\uD800'..'\uDFFF' }
}
/**
* 登录前探测(C++ 侧据此决定是否声明 CLIENT_CAP_LOCK_SCREEN):锁屏依赖无障碍
* 服务在跑(performGlobalAction)与 API 28+,两者缺一就如实不声明,免得服务端
* 把「命令已下发」当成「已锁上」。
*/
@JvmStatic
fun canLockScreen(): Boolean =
instance != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
/**
* 服务端 COMMAND_SCREEN_CTRL_ALT_DEL:Android 没有 Ctrl+Alt+Del 这个组合键,
* 客户端映射成「锁屏」(GLOBAL_ACTION_LOCK_SCREEN,API 28+)。调用方是屏幕
* 子连接的 OnReceive 线程,performGlobalAction 必须在主线程,故 post 过去。
*/
@JvmStatic
fun lockScreen() {
val svc = instance ?: run {
Log.w(TAG, "lockScreen: accessibility service inactive, command dropped")
return
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
Log.w(TAG, "lockScreen: GLOBAL_ACTION_LOCK_SCREEN needs API 28+")
return
}
svc.handler.post {
if (!svc.performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN))
Log.w(TAG, "lockScreen: performGlobalAction rejected by the system")
}
}
// ── Screen geometry (set by CaptureService) ──────────────────────
// Server sends coords in encoding space [0, encW) × [0, encH).
// We map them to physical screen space before dispatching.