E2E smoke hardening + Android lock/capture fixes #8

Merged
yuanyuanxiang merged 2 commits from review/e2e-android-fixes into main 2026-11-22 21:11:43 +00:00
Owner

概要

包含两个已本地审查通过的提交:

be197448 — Test: harden the E2E smoke script against hangs and hidden crashes

  • SendInt 改用 SendMessageTimeout(SMTO_ABORTIFHUNG,2s),UI 线程挂死时不再无限等待
  • -Build 移到修改 settings.ini 之前,server / -ClientOnly 两次构建各自检查 $LASTEXITCODE
  • settings 修改包 try/catch + finally 恢复备份,异常路径不残留改动
  • 上线等待重写:进程退出立即抛死因;区分「UI 挂死」与偶发慢响应
  • LVM_GETITEMSTATE 返回 -1 时短路,不再把错误值当状态位

340fb205 — Fix(android): correct lock/input state and recover screen capture

  • TV 卡「Locked」修复:锁屏状态改纯事件驱动(SCREEN_OFF/ON/USER_PRESENT),不再每次心跳查 KeyguardManager;输入策略(leanback→D-pad)与 TV 启发式(leanback/television/uiMode)分离
  • 抓屏自愈:SendLoop 5s 无首帧→同一 MediaProjection 重建采集管线(保留编码尺寸,避免主控解码器黑屏);13s 仍无帧→进程级 60s 节流回一条明确消息
  • createVirtualDisplay 返回 null 不再静默:释放编码器、先降级前台类型回 DATA_SYNC 再 stop projection,避免 Android 14+ 连带杀服务导致掉线
  • 编码器泄漏修复:configure/start 抛异常时就地 release
  • nativeReady 守卫:nativeInit 返回 -1(已运行)不再 stopSelf 掉线;NoClassDefFoundError 兜底
  • 日志入 ring:新增 nativeLog JNI,Kotlin 侧 ylog 经 android_log_tag 同时写 logcat 与 Logger ring,get_client_log 可取回
  • 重新授权链路:无抓屏尺寸时节流拉起录屏授权 Intent(MainActivity.onNewIntent 处理)

审查状态

两个提交已完成静态审查,无阻塞问题。非阻塞观察:

  1. lockedAtElapsed 跨线程读写未加 @Volatile(既有模式,最终可见)
  2. SendLoop 13s 消息与 ScreenSpyThread 的授权提示路径重叠,但都覆盖用户告知

测试计划

  • E2E 脚本逻辑静态审查
  • Android 变更静态审查(Debug APK 可构建)
  • Android 真机验证:TV 睡眠唤醒后画面恢复、锁屏状态显示、无录屏授权时的提示链路
  • E2E 冒烟脚本实跑一轮
## 概要 包含两个已本地审查通过的提交: ### be197448 — Test: harden the E2E smoke script against hangs and hidden crashes - `SendInt` 改用 `SendMessageTimeout`(SMTO_ABORTIFHUNG,2s),UI 线程挂死时不再无限等待 - `-Build` 移到修改 settings.ini 之前,server / -ClientOnly 两次构建各自检查 `$LASTEXITCODE` - settings 修改包 try/catch + finally 恢复备份,异常路径不残留改动 - 上线等待重写:进程退出立即抛死因;区分「UI 挂死」与偶发慢响应 - `LVM_GETITEMSTATE` 返回 -1 时短路,不再把错误值当状态位 ### 340fb205 — Fix(android): correct lock/input state and recover screen capture - **TV 卡「Locked」修复**:锁屏状态改纯事件驱动(SCREEN_OFF/ON/USER_PRESENT),不再每次心跳查 KeyguardManager;输入策略(leanback→D-pad)与 TV 启发式(leanback/television/uiMode)分离 - **抓屏自愈**:SendLoop 5s 无首帧→同一 MediaProjection 重建采集管线(保留编码尺寸,避免主控解码器黑屏);13s 仍无帧→进程级 60s 节流回一条明确消息 - **createVirtualDisplay 返回 null 不再静默**:释放编码器、先降级前台类型回 DATA_SYNC 再 stop projection,避免 Android 14+ 连带杀服务导致掉线 - **编码器泄漏修复**:configure/start 抛异常时就地 release - **nativeReady 守卫**:nativeInit 返回 -1(已运行)不再 stopSelf 掉线;NoClassDefFoundError 兜底 - **日志入 ring**:新增 nativeLog JNI,Kotlin 侧 ylog 经 android_log_tag 同时写 logcat 与 Logger ring,get_client_log 可取回 - **重新授权链路**:无抓屏尺寸时节流拉起录屏授权 Intent(MainActivity.onNewIntent 处理) ## 审查状态 两个提交已完成静态审查,无阻塞问题。非阻塞观察: 1. `lockedAtElapsed` 跨线程读写未加 @Volatile(既有模式,最终可见) 2. SendLoop 13s 消息与 ScreenSpyThread 的授权提示路径重叠,但都覆盖用户告知 ## 测试计划 - [x] E2E 脚本逻辑静态审查 - [x] Android 变更静态审查(Debug APK 可构建) - [ ] Android 真机验证:TV 睡眠唤醒后画面恢复、锁屏状态显示、无录屏授权时的提示链路 - [ ] E2E 冒烟脚本实跑一轮
yuanyuanxiang added 2 commits 2026-11-22 21:05:37 +00:00
A crash inside the client-online wait was swallowed by Wait-Until's empty
catch, so a dead server or client surfaced only as "no host online after
60s" once the timeout expired. Record the failure reason and report it
right after the wait.

LVM_GETITEMCOUNT and LVM_GETITEMSTATE used SendMessage without a timeout.
A hung server UI thread - the exact regression this script exists to catch
- would block the script forever instead of failing. Send with
SendMessageTimeout (2s) and treat a timeout as a failure.

-Build ran after settings.ini had been temporarily rewritten for busy
MCP/Web ports, so a build failure left the file modified. Build before
touching settings and restore unconditionally in a catch block.

Verified by re-running the Search feature end to end.

Co-Authored-By: deepseek-flash
db148c4 asked KeyguardManager on every heartbeat; some TVs answer "locked"
while playing video, so hosts showed "Locked: HH:MM:SS" forever and the
foreground app never reached the server. Lock state is event-driven again:
SCREEN_OFF records the start, USER_PRESENT clears it, and on SCREEN_ON the
state clears when the device is TV-like or has no keyguard (devices without
a lock screen never send USER_PRESENT); a phone that reconnects while
locked is re-calibrated the same way. Keyguard is consulted only at those
event points, never per heartbeat.

Input strategy and TV heuristics are separate immutable values: isTV (D-pad
focus navigation vs touch injection) only looks at leanback, isTvLike (lock
and encoder heuristics) also accepts television/uiMode. They were once
merged and the TV lost remote control, then an assignment was dropped and
it silently defaulted to false; immutable lazy values make both impossible.
The resolved mode is logged as "input=dpad|touch tvLike=..." and mirrored
into the native ring when available.

Screen capture: on TVs the default encoder configuration is tried first.
After a sleep the existing VirtualDisplay stops composing while the
projection stays alive, so a 5s zero-frame stall rebuilds the encoder and
VirtualDisplay on the same projection (reusing the session's encoded size),
requests a fresh IDR and reports failure only after 13s; if the projection
is gone the native size is cleared so the next request re-authorizes. A
repeated onStartCommand no longer calls nativeInit again (the -1 answer
used to stopSelf and drop the host). Kotlin capture logs mirror into the
native ring and fall back to logcat.

Debug APK builds; device verification pending.

Co-Authored-By: deepseek-flash
yuanyuanxiang merged commit 340fb20518 into main 2026-11-22 21:11:43 +00:00
yuanyuanxiang deleted branch review/e2e-android-fixes 2026-11-22 21:11:43 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: yuanyuanxiang/SimpleRemoter#8