perf(android): read screenshot rotation from the helper response

TH
2h ago
+233-25

Summary

Each Android helper screenshot spawned adb shell dumpsys display to learn the rotation. The helper's screenshot response now carries displayRotation (default display, read before and after the capture, sent only when both agree) and displayCount. A helper capture spawns no adb process.

  • More than one display still reports no rotation. The helper counts logical displays it can see, which excludes an inactive foldable panel.
  • dumpsys stays for the screencap fallback, orientation settle, and a helper without the headers.

10 files touched.

Validation

Head 04a2045827, base 244d1ff683. Emulator API 35, screenshot on a live helper session. 2 passes × 6 interleaved rounds × 5 shots (n=60 per arm), load 23–49 on 12 cores:

Armp50p95adb spawns per shot
main367 ms595 ms1
branch331 ms681 ms0

Main already ran the probe in parallel with the capture, so wall time stays within host noise. The firm gain is one fewer adb call per screenshot, which counts more on remote devices.

At all four rotations, the helper rotation matched dumpsys mCurrentOrientation and the helper PNG was pixel-identical to screencap. This was verified on API 35 only. A second overlay display made the helper report no rotation.

Focused unit tests, helper JVM suite, and pnpm typecheck pass. CI is green.

🤖 Generated with Claude Code