Feature: Add screen preview to the Android client

get_screenshot and the server's online-list and hover thumbnails were
gated to Windows and X11 Linux. The Android client now answers
COMMAND_SCREEN_PREVIEW_REQ on the main connection with
TOKEN_SCREEN_PREVIEW_RSP plus a JPEG, and advertises
CLIENT_CAP_SCREEN_PREVIEW at login only when it can really capture.

Capture goes through AccessibilityService.takeScreenshot (API 30+),
enabled by canTakeScreenshot in the service config. MediaProjection is
deliberately not reused: its VirtualDisplay already feeds the H.264
encoder and Android 14+ refuses a second one from the same projection,
while accessibility capture runs alongside the live stream. The JPEG is
scaled to maxWidth and encoded in Kotlin; native only copies the bytes
and drops a request while one is in flight. Only mode=screen is
supported, and capabilities are re-evaluated on every login so turning
the service off withdraws the capability.

Also fix two review findings: a screenshot callback that lands after
the 3 s timeout now recycles its bitmap instead of leaking it, and the
server's failure hint lists the possible Android causes instead of
asserting disabled accessibility.

Verified on the emulator against a local debug server: get_screenshot
returns 640x1422 and 720x1600 JPEGs, the 120-wide list thumbnail works,
and both MCP tool-table checkers pass with apk added for get_screenshot,
get_activity_history and get_client_log.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-11 20:58:40 +01:00
1 parent 66acde0301
commit f29150d20e
6 files changed
+346 -16

No files matched your search

@@ -4,5 +4,6 @@
android:accessibilityFeedbackType="feedbackGeneric"
android:canPerformGestures="true"
android:canRetrieveWindowContent="true"
android:canTakeScreenshot="true"
android:notificationTimeout="0"
android:settingsActivity="com.yama.client.MainActivity" />