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
@@ -146,6 +146,7 @@ inline int isValid_10s()
#define CLIENT_CAP_APK_UPDATE 0x0400 // 支持接收 COMMAND_UPDATE 下发的 APK 并走系统安装器(仅 Android)
#define CLIENT_CAP_SCREEN_CLIPBOARD 0x0800 // 屏幕子连接处理 COMMAND_SCREEN_SET_CLIPBOARD,并把 VK_V 映射成 ACTION_PASTE(仅新版 Android)
#define CLIENT_CAP_LOCK_SCREEN 0x1000 // 屏幕子连接处理 COMMAND_SCREEN_CTRL_ALT_DEL(Android 映射为锁屏 GLOBAL_ACTION_LOCK_SCREEN)
#define CLIENT_CAP_UNINSTALL 0x2000 // 主连接处理 TOKEN_UNINSTALL(Android 拉起系统卸载确认框;Windows 客户端一直支持但不声明)
#define TALK_DLG_MAXLEN 1024 // 最大输入字符长度
@@ -1307,6 +1308,9 @@ typedef struct LOGIN_INFOR {
caps |= CLIENT_CAP_SCREEN_CLIPBOARD;
// 锁屏(COMMAND_SCREEN_CTRL_ALT_DEL → GLOBAL_ACTION_LOCK_SCREEN)依赖无障碍服务
// 与 API 28+,和其它运行时能力一样由 main.cpp 登录前探测后追加,不在默认位里声明。
// 卸载主机(TOKEN_UNINSTALL):命令处理是编译进来的,老 APK 收到只会静默丢弃,
// 服务端据此提前拒绝,而不是发一条没人接的命令后假报 ok。
caps |= CLIENT_CAP_UNINSTALL;
#endif
return caps;
}