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

+3
View File
@@ -7,6 +7,9 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<!-- 在线升级:走 PackageInstaller 会话安装服务端下发的 APK,仍需系统安装器人工确认 -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<!-- 卸载主机(TOKEN_UNINSTALL):ACTION_DELETE 拉系统卸载确认框,缺这个权限
UninstallerActivity 会直接报 "does not have REQUEST_DELETE_PACKAGES" 并退出 -->
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<!-- 升级完成/需要人工确认时的提示通知(Android 13+ 是运行时权限) -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />