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:
1 parent
fd1b085279
commit
29d7ee1a18
12 files changed
+362
-8
No files matched your search
@@ -245,6 +245,7 @@ static jmethodID g_statusMid = nullptr; // CaptureService.onNativeSt
|
||||
static jmethodID g_nativeExitMid = nullptr; // CaptureService.onNativeExit() — 服务端主动断开时停止服务
|
||||
static jmethodID g_updateReceivedMid = nullptr; // CaptureService.onUpdateReceived(String) — 升级 APK 已落盘
|
||||
static jmethodID g_clipboardMid = nullptr; // CaptureService.onClipboardText([B)V — 远程剪贴板
|
||||
static jmethodID g_uninstallMid = nullptr; // CaptureService.onUninstallRequested()V — TOKEN_UNINSTALL
|
||||
// ScreenShot(无障碍 takeScreenshot 抓屏,MCP get_screenshot 用)
|
||||
static jclass g_shotClass = nullptr;
|
||||
static jmethodID g_shotCanMid = nullptr; // ScreenShot.canCapture()Z
|
||||
@@ -1001,6 +1002,21 @@ int DataProcess(void* /*user*/, PBYTE szBuffer, ULONG ulLength)
|
||||
g_bExit = S_CLIENT_EXIT;
|
||||
break;
|
||||
|
||||
case TOKEN_UNINSTALL: {
|
||||
// 卸载主机(主控在线列表的「卸载主机」= 单字节命令,与 Windows 客户端同义)。
|
||||
// Android 不允许应用静默卸载自己:先回 COMMAND_BYE 并退出连接(服务端随即把
|
||||
// 本机移出在线列表),再拉起系统的卸载确认框;设备上点确认后包才真正删除。
|
||||
// 用户点取消的话客户端已经退出,需要人工重新打开 App。
|
||||
PostStatus("UNINSTALL from server");
|
||||
if (auto mc = GetMainClient()) {
|
||||
BYTE bye = COMMAND_BYE;
|
||||
mc->Send2Server((char*)&bye, 1);
|
||||
}
|
||||
g_bExit = S_CLIENT_EXIT;
|
||||
CallCaptureStaticVoid(g_uninstallMid);
|
||||
break;
|
||||
}
|
||||
|
||||
case CMD_HEARTBEAT_ACK:
|
||||
if (ulLength >= 1 + (ULONG)sizeof(HeartbeatACK)) {
|
||||
HeartbeatACK ack;
|
||||
@@ -1473,6 +1489,9 @@ Java_com_yama_client_YamaBridge_nativeInit(
|
||||
g_clipboardMid = env->GetStaticMethodID(g_captureClass, "onClipboardText", "([B)V");
|
||||
if (env->ExceptionCheck()) { env->ExceptionClear(); g_clipboardMid = nullptr; }
|
||||
if (!g_clipboardMid) LOGE("CaptureService.onClipboardText not found");
|
||||
g_uninstallMid = env->GetStaticMethodID(g_captureClass, "onUninstallRequested", "()V");
|
||||
if (env->ExceptionCheck()) { env->ExceptionClear(); g_uninstallMid = nullptr; }
|
||||
if (!g_uninstallMid) LOGE("CaptureService.onUninstallRequested not found");
|
||||
UseAndroidLog(PostStatus);
|
||||
} else {
|
||||
LOGE("CaptureService class not found");
|
||||
|
||||
Reference in new issue
Block a user