Feature: Honor remote desktop tuning commands on Android hosts

The Android client dropped CMD_QUALITY_LEVEL, CMD_FPS, CMD_QUALITY_PROFILES
and CMD_SCREEN_TUNING as log lines, and hardcoded ScreenSettings.QualityLevel
to Good. Because the server initializes adaptive quality from the client's
reported level, that hardcoded value pinned every Android session to a fixed
profile: adaptive quality could never start.

ScreenTuning.kt now owns the state in SharedPreferences (level, max fps and
the master's six-row profile table), and C++ only parses the wire format.
The level is persisted when the master sets it explicitly, including -1
adaptive and -2 disabled, and is reported back in TOKEN_BITMAPINFO on the
next screen session. A concrete level switch applies the profile bitrate at
runtime via MediaCodec.setParameters(PARAMETER_KEY_VIDEO_BITRATE), which is
smooth and needs no encoder rebuild.

Frame rate is stored as-is (255 = unlimited, matching Windows) and only
reaches KEY_FRAME_RATE at the next capture start, since surface encoders
have no runtime fps cap. Ultra and High default to a zero bitrate because
their Windows algorithms are DIFF/RGB565, so Android falls back to the
previous 4000 kbps. CMD_SCREEN_TUNING stays log-only: all four flags belong
to the Windows capture/x264 path and Android does not claim
SCREEN_CAP_TUNING_FLAGS. CMD_SCREEN_SIZE is ignored; the server's pending
resolution-change mark self-heals after one second.

Verified on the emulator: a seeded Level 5 starts capture at 800 kbps/8 fps
and the server title shows Minimal; a master-side switch to Good changes the
live bitrate to 3000, and a restart picks up fps 30 from CMD_FPS.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-11 21:58:54 +01:00
1 parent a801a2999a
commit 3ab5154db1
6 files changed
+444 -12

No files matched your search

+15
View File
@@ -270,6 +270,21 @@ MediaProjection 抓的是合成后的帧缓冲,无障碍 overlay 无论是否
**不建议合并**:两族走不同子连接、不同能力位、不同门控,合并会破坏既有安全模型(`McpMachine` 开关的意义就是「单独关掉一套」)。
### 3.3 Android 主机的远程桌面调参(`CMD_QUALITY_LEVEL` / `CMD_FPS` / `CMD_QUALITY_PROFILES`)
这一项不新增工具,修的是**Android 客户端把调参命令当日志丢弃**的问题,但直接决定
`remote_open` 会话的画质:Android 上报的 `ScreenSettings.QualityLevel` 原来写死为 Good,
服务端据此把会话判定为「固定档位」,`m_AdaptiveQuality.enabled` 永远为 false——
自适应质量在 Android 主机上从未启动。
客户端现在(`ScreenTuning.kt` + `ScreenHandler.h`):档位/帧率/6 档配置表存
SharedPreferences,下次建子连接时随 `TOKEN_BITMAPINFO` 上报;具体档位切换用
`MediaCodec.setParameters(PARAMETER_KEY_VIDEO_BITRATE)` 平滑改码率。帧率只进
`KEY_FRAME_RATE` 码控提示(下次开抓生效),`CMD_SCREEN_SIZE` 与
`CMD_SCREEN_TUNING` 的四个开关在 Android 上没有对应实现,客户端不声明
`SCREEN_CAP_TUNING_FLAGS`,服务端继续用主控端按设备保存的副本。设计与限制详见
`Mcp_RemoteControl_Design.md §5.4`。
---
## 4. 大能力(需独立立项,不建议并入本轮)