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

+6 -5
View File
@@ -49,9 +49,9 @@
## 1. 现状盘点
### 1.1 工具族(62 个)
### 1.1 工具族(63 个)
登记表在 `server/2015Remote/McpInternal.cpp:479` 的 `kToolHints[]`(62 项,与下表的工具逐条对应)。
登记表在 `server/2015Remote/McpInternal.cpp:479` 的 `kToolHints[]`(63 项,与下表的工具逐条对应)。
下表是 P11 之后的口径;写作时是 54 个、8 个族,P10-B 加 3 个(文件系统写)、P10-C 加 1 个
(`remote_block_input`)、P11 加 2 个(`mcp_list_sessions` / `mcp_cancel_session`)。
@@ -63,14 +63,14 @@
| 远程控制 | 7 | `remote_open` `remote_close` `remote_mouse` `remote_keyboard` `remote_clipboard` `remote_lock_screen` `remote_block_input` | `McpRemoteControl=1` **且** `McpReadonly=0` |
| 文件传输 | 2 | `upload_file` `copy_files_c2c` | `McpFileTransfer=1` **且** `McpReadonly=0`(`download_file` 只要求此开关) |
| 文件系统写 | 3 | `delete_path` `move_path` `create_folder` | `McpFileWrite=1` **且** `McpReadonly=0` |
| 设备管理 | 4 | `kill_process` `operate_window` `control_service` `power_action` | `McpManage=1` **且** `McpReadonly=0` |
| 设备管理 | 5 | `kill_process` `operate_window` `control_service` `power_action` `uninstall_host` | `McpManage=1` **且** `McpReadonly=0` |
| 主机/连接管理 | 7 | `kill_network_connection` `host_control_process` `host_control_window` `host_control_service` `host_control_task` `host_set_remark` `host_set_watch_level` | 前 5 个:`McpMachine=1` + `McpMachineDangerous=1` + `McpReadonly=0`;`host_set_remark` / `host_set_watch_level` 始终在列表里,调用要求 `McpReadonly=0` |
| 远程交谈 | 4 | `chat_open` `chat_send` `chat_wait` `chat_close` | `McpChat=1`(与 `McpReadonly` 无关) |
合计 9+22+4+7+2+3+4+7+4 = 62。默认配置(`McpReadonly=1`、其余开关 0)下 `tools/list` **19 个**
合计 9+22+4+7+2+3+5+7+4 = 63。默认配置(`McpReadonly=1`、其余开关 0)下 `tools/list` **19 个**
= 服务端本机只读 9 + 主机只读 8(去掉 `get_keylog` / `download_file` / `list_network_connections` /
`host_list_*`)+ 主机/连接管理 2(`host_set_remark` / `host_set_watch_level`);其余各族依赖开关,全部不可见。
开关全开且关闭只读时为 **62 个**。
开关全开且关闭只读时为 **63 个**。
**已有的工程范式**(新工具直接复用,不必重新设计):
@@ -130,6 +130,7 @@
| **键盘记录(离线常驻)** | `COMMAND_KEYBOARD_OFFLINE` / `COMMAND_KEYBOARD_CLEAR` | ❌ **缺** | **零客户端改动**(见 §5.2) |
| 客户端日志 | `COMMAND_QUERY_LOG` | ✅ `get_client_log` | — |
| 电源操作 | `TOKEN_MACHINE_MANAGE` | ✅ `power_action` | — |
| 卸载主机(被控程序) | `TOKEN_UNINSTALL` | ✅ `uninstall_host`(win + apk) | Android 新版拉起系统卸载确认框,需人工确认 |
| 远程交谈 | `COMMAND_CHAT` | ✅ `chat_*` | — |
| **客户端升级** | `COMMAND_UPDATE` | ❌ | 零客户端改动,需独立评审(见 §4.4) |
| **上传执行 / 下载执行** | `COMMAND_UPLOAD_EXEC` / `COMMAND_DOWN_EXEC` | ❌ | 零客户端改动,需独立评审(见 §4.4) |