readSnapshot method
The native surface as a scene; a sentinel scene when it cannot be read.
Implementation
@override
Future<Scene> readSnapshot() async {
lastReadProblem = null;
final r = await serverCall?.call(const {'cmd': 'windows'});
if (r != null && r['ok'] == true) return sceneFromServerWindows(r, devicePixelRatio());
try {
const path = '/data/local/tmp/glint_ui.xml';
final dump = await runCapped(
run,
adbPath,
['-s', serial, 'shell', 'uiautomator', 'dump', path],
timeout: const Duration(seconds: 15),
phase: 'uiautomator dump',
);
if (dump.exitCode != 0) {
final others = await otherDeviceServers(serial, adbPath, run: run);
lastReadProblem = dump.exitCode == 137
? 'uiautomator was killed: another automation tool holds the accessibility connection'
'${others.isEmpty ? ' (Appium, mobile-mcp, agent-device)' : ': ${others.join(', ')}'}'
: 'uiautomator dump failed (exit ${dump.exitCode})';
return _sentinel();
}
final xml = await runCapped(
run,
adbPath,
['-s', serial, 'exec-out', 'cat', path],
timeout: const Duration(seconds: 15),
phase: 'reading the uiautomator dump',
);
return sceneFromUiDump(xml.stdout as String, devicePixelRatio());
} on Object catch (e) {
lastReadProblem = 'uiautomator dump failed: $e';
return _sentinel();
}
}