feat(android): add opt-in dp coordinate unit
Merged
SA
5h ago+2106+2106+0123456789012345678901234567890123456789-97-97-01234567890123456789
Summary
Android geometry is physical pixels. This adds an opt-in coordinateUnit: 'dp', on the client config or per call; native stays the default.
- The daemon converts at the router: dp input becomes whole pixels before dispatch, and results come back in dp with a
coordinateslabel. Handlers and.adscripts keep pixels. - Density comes from the request's own capture, else the device's read (
wm density, ormobile: deviceInfoon WebDriver hubs), else the caller'scoordinateDensity. Nothing is kept between requests. - Without a density, a dp request with geometry is refused before dispatch (
coordinate_unit_density_unknown).
Before / after
const client = createAgentDeviceClient({ coordinateUnit: 'dp' });
await client.capture.snapshot();
// before: viewport { width: 1080, height: 2400 }
// after: viewport { width: 411.43, height: 914.29 }, coordinates { unit: 'dp', pixelDensity: 2.625 }
await client.interactions.press({ x: 200, y: 450 });
// before: taps (200, 450); after: taps (525, 1181)
Validation
Hosted runs at 5e1ed75c71, with dp and no coordinateDensity. Every session was released.
| Provider | Device | Density | Result |
|---|---|---|---|
| Limrun | Android emulator | 1.75 | press hit target |
| BrowserStack | Pixel 8, Android 14 | 2.625 | press hit target |
| Revyl | Android emulator | none | refused, dispatched: no |
| Sauce Labs | Pixel 7 emulator | 420 dpi | raw hub check |
| TestMu AI | — | — | unit tests only |
CI owns the gates. Risk: TestMu AI has no live run.