start static method
Implementation
static Future<AdbRecording> start({
required String adbPath,
required String serial,
required String localPath,
Duration startTimeout = const Duration(seconds: 5),
}) async {
await runBounded(adbPath, removeArgs(serial),
timeout: const Duration(seconds: 10), phase: 'adb clearing the old recording');
final proc = await startHelper('screen-recording', adbPath, startArgs(serial),
device: serial, owner: 'android:$serial', life: HelperLife.attachment, label: 'adb screenrecord');
final deadline = DateTime.now().add(startTimeout);
while (DateTime.now().isBefore(deadline)) {
if ((await proc.exitCode.timeout(const Duration(milliseconds: 1), onTimeout: () => -999)) != -999) {
throw BackendToolError(
backend: 'adb($serial)',
command: 'adb shell screenrecord',
exitCode: 1,
stderr: 'screenrecord exited before recording started',
);
}
final ls = await runBounded(adbPath, existsArgs(serial),
timeout: const Duration(seconds: 5), phase: 'adb checking the recording started');
if (ls.exitCode == 0 && !(ls.stdout as String).contains('No such file')) {
return AdbRecording._(proc, adbPath, serial, localPath, DateTime.now());
}
await Future<void>.delayed(const Duration(milliseconds: 100));
}
proc.kill(ProcessSignal.sigkill);
throw BackendToolError(
backend: 'adb($serial)',
command: 'adb shell screenrecord',
exitCode: -1,
stderr: 'screenrecord did not create $remotePath within '
'${startTimeout.inSeconds}s',
);
}