Feature: Add activity history to the Android client
get_activity_history was gated to Windows and Linux. The Android client now answers COMMAND_QUERY_ACTIVITY with a TOKEN_REPORT_ACTIVITY snapshot on the main connection, the same RPC shape as the other platforms; the server takes the first packet without CancelIO, so no sub-connection or request correlation is involved. The sampler reuses linux/LinuxActivityHistory.h, whose ActivityHistory class and formatters are platform-neutral, and is fed by a probe that asks the new ControlService.currentActivityTitle() once per second over JNI. The accessibility service already tracks the foreground package from TYPE_WINDOW_STATE_CHANGED; the title is "label (package)" with the label resolved once and cached, "Home" for the launcher, and idle for lock or screen-off, so no permission beyond the service users already enable is needed. Without the service the report says so instead of recording placeholder "Android" entries. Also scope the connection teardown to its own generation: a ConnectionThread that exits late (CaptureService restart) no longer clears the new run's g_running or g_pMainClient, and the report thread takes one local snapshot of the main client pointer. Verified on the emulator against a local debug server: five records (Settings, Chrome, launcher, Home) came back newest-first with dwell times, and disabling accessibility produced the permission hint. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
d365a4f948
commit
5ed1a07dc4
4 files changed
+158
-9
No files matched your search
@@ -344,7 +344,8 @@ const char* kServerInstructions =
|
||||
u8"(客户端有 PTY 实现,但服务端本轮未开放)、kill_process;"
|
||||
u8"文件传输、进程列表、日志可用。\n"
|
||||
u8"apk(APK):支持主机列表(list_online_hosts / list_all_hosts)/ 详情 / 搜索 / "
|
||||
u8"审计日志 / 服务状态 / 会话管理、运行日志(get_client_log),以及 "
|
||||
u8"审计日志 / 服务状态 / 会话管理、运行日志(get_client_log)、活动历史"
|
||||
u8"(get_activity_history,前台应用停留记录),以及 "
|
||||
u8"host_set_remark / host_set_watch_level 这两个只改服务端本地数据的工具。其余一律不支持"
|
||||
u8"(客户端未实现 SYSTEM 与 SHELL)。\n"
|
||||
u8"copy_files_c2c 是唯一有方向性的工具:源端 src_id 必须是 win,目标端 dst_id 可以是 "
|
||||
@@ -2184,7 +2185,7 @@ std::string BuildToolsListResult(const Json::Value& id) {
|
||||
{
|
||||
Json::Value tool(Json::objectValue);
|
||||
tool["name"] = "get_activity_history";
|
||||
tool["description"] = u8"获取指定在线主机的历史活动记录。Windows 与有桌面的 Linux 客户端返回前台窗口驻留记录,每行一条「[时间] [标题] 时长」;无桌面的 Linux 客户端返回登录记录与 shell 命令历史,每行带「[登录]」或「[命令]」标签(首行为「[来源]」说明)。主连接 RPC。结果按 limit/offset 分页(默认 100 条、上限 1000),新在前:offset=0 就是最近 limit 条,想看更早的再往后翻。total 为本机现有记录总数,hasMore 表示还有更早的记录;窗口后端只保留最近 500 条,所以 total 最多约 501(含进行中的当前窗口)。";
|
||||
tool["description"] = u8"获取指定在线主机的历史活动记录。Windows 与有桌面的 Linux 客户端返回前台窗口驻留记录,每行一条「[时间] [标题] 时长」;Android 客户端返回前台应用驻留记录(标题为「应用名 (包名)」,需开启无障碍服务);无桌面的 Linux 客户端返回登录记录与 shell 命令历史,每行带「[登录]」或「[命令]」标签(首行为「[来源]」说明)。主连接 RPC。结果按 limit/offset 分页(默认 100 条、上限 1000),新在前:offset=0 就是最近 limit 条,想看更早的再往后翻。total 为本机现有记录总数,hasMore 表示还有更早的记录;窗口后端只保留最近 500 条,所以 total 最多约 501(含进行中的当前窗口)。";
|
||||
|
||||
tool["inputSchema"] = BuildPagedHostListInputSchema(); // { id | ids } + limit/offset
|
||||
tool["outputSchema"] = BuildActivityHistoryOutputSchema();
|
||||
@@ -9966,8 +9967,9 @@ const ToolPlatform kToolPlatforms[] = {
|
||||
// 那是给 SystemDlg 窗口管理用的,不是 MCP 这条路径。
|
||||
{ "list_windows", kPlatWin },
|
||||
// Linux 客户端已实现 COMMAND_QUERY_ACTIVITY → TOKEN_REPORT_ACTIVITY(linux/LinuxActivityHistory.h,
|
||||
// 有桌面走 X11 窗口采样,无桌面走 last + shell 历史),与 Windows 同为主连接 RPC
|
||||
{ "get_activity_history", kPlatWin|kPlatLnx },
|
||||
// 有桌面走 X11 窗口采样,无桌面走 last + shell 历史),Android 复用同一套采样机、
|
||||
// 前台应用由无障碍服务提供,与 Windows 同为主连接 RPC
|
||||
{ "get_activity_history", kPlatWin|kPlatLnx|kPlatApk },
|
||||
{ "list_services", kPlatWin },
|
||||
{ "get_keylog", kPlatWin },
|
||||
{ "list_registry", kPlatWin },
|
||||
|
||||
Reference in new issue
Block a user