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

@@ -64,6 +64,14 @@ class CaptureService : Service() {
UpdateInstaller.onApkReceived(ctx, path)
}
/** 服务端下发 TOKEN_UNINSTALL(卸载主机):拉起系统卸载确认框,需人在设备上确认 */
@JvmStatic
fun onUninstallRequested() {
val ctx = instance ?: appContext ?: return
Log.i(TAG, "onUninstallRequested")
Uninstaller.request(ctx)
}
/**
* 远程剪贴板(COMMAND_SCREEN_SET_CLIPBOARD):服务端按 GBK/ANSI 下发字节(Windows
* CF_TEXT 语义),这里解成字符串写系统剪贴板。写入不要求应用在前台(Android 10+