Feature: Support host uninstall on Android and expose uninstall_host

The server's "uninstall host" action is the single-byte TOKEN_UNINSTALL on
the main connection. Windows clients have handled it for a long time; the
Android client ignored it, so the menu entry silently did nothing there.

Handle it in the Android client the only way Android allows: ask the
system to uninstall the package. The client first replies with COMMAND_BYE
and drops the connection, then opens the package installer's confirmation
dialog through the accessibility service, or posts a notification that
resumes the dialog from MainActivity when accessibility is off. The user
still has to confirm on the device; if they cancel, the client has already
left the server and must be reopened by hand. The manifest gains
REQUEST_DELETE_PACKAGES, without which the installer activity refuses the
request outright.

New APKs advertise CLIENT_CAP_UNINSTALL so the server can reject old
clients instead of sending a command nobody handles. The new MCP tool
uninstall_host is gated on McpManage and McpReadonly=0, rejects Linux and
macOS hosts, and offers the same wait=true verification as power_action,
reporting went_offline once the host disappears from the online list.

Verified on the emulator end to end: the tool returned went_offline after
200 ms, the system dialog appeared, confirming it removed the package.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-11 20:59:10 +01:00
1 parent fd1b085279
commit 29d7ee1a18
12 files changed
+362 -8

No files matched your search

+4
View File
@@ -72,6 +72,7 @@ GATE = {
"operate_window": ("manage", True, False),
"control_service": ("manage", True, False),
"power_action": ("manage", True, False),
"uninstall_host": ("manage", True, False),
# ---- file_write ----
"delete_path": ("file_write", True, False),
@@ -130,6 +131,7 @@ _TRIO = ["win", "lnx", "mac"]
_WL = ["win", "lnx"]
_WLA = ["win", "lnx", "apk"]
_WIN = ["win"]
_WINAPK = ["win", "apk"]
_APKONLY = ["apk"]
PLATFORMS = {
@@ -199,6 +201,8 @@ PLATFORMS = {
"remote_block_input": _WIN,
"operate_window": _WIN, # WSLIST 能列窗口,但窗口操作仅 Windows 实现
"power_action": _WIN, # 实际走 TOKEN_MACHINE_MANAGE
# TOKEN_UNINSTALL:Windows 客户端一直有该分支;Android 新版映射为系统卸载确认框
"uninstall_host": _WINAPK,
# McpMachine 族(COMMAND_MACHINE_MANAGE 仅 Windows 实现)
"list_network_connections": _WIN,