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

+8
View File
@@ -147,6 +147,14 @@ public:
return (strtoul(caps.GetString(), nullptr, 16) & CLIENT_CAP_LOCK_SCREEN) != 0;
}
// 检查客户端是否处理 TOKEN_UNINSTALL(卸载主机)。Windows 客户端一直有该分支但
// 不声明能力位,调用方按平台区分;只有新版 Android 声明,老 APK 收到会静默丢弃。
bool SupportsUninstall() const {
CString caps = GetClientData(ONLINELIST_CAPABILITIES);
if (caps.IsEmpty()) return false;
return (strtoul(caps.GetString(), nullptr, 16) & CLIENT_CAP_UNINSTALL) != 0;
}
// 检查客户端是否支持远程协议切换(COMMAND_SET_PROTO)。老客户端没有这个命令,
// 收到也会走 default 丢弃,服务端据此把「协议切换」菜单置灰。
bool SupportsProtoSwitch() const {