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:
yuanyuanxianganddeepseek-flash committed 2026-11-11 13:14:46 +01:00
1 parent d365a4f948
commit 5ed1a07dc4
4 files changed
+158 -9

No files matched your search

@@ -2,4 +2,6 @@
<resources>
<string name="app_name">YAMA</string>
<string name="accessibility_service_description">YAMA remote control service</string>
<!-- 历史活动记录里「桌面」这一项的窗口标题(Home 屏,没有对应 Activity 包名) -->
<string name="activity_home">Home</string>
</resources>