openDownloadsFd method
Opens a writable file descriptor for Downloads/$subdirectory/$fileName
via MediaStore, returning the raw fd — pass it straight into
NativeBindings.shimStartRecordingFd/shimStartIqRecordingFd. The
entry stays hidden from other apps (IS_PENDING) until
finishDownloadsFd is called.
Implementation
@override
Future<int> openDownloadsFd({
required String fileName,
required String mimeType,
String subdirectory = 'Recordings',
}) async {
openCalls.add((
fileName: fileName,
mimeType: mimeType,
subdirectory: subdirectory,
));
if (failNextOpen) {
failNextOpen = false;
throw PlatformException(code: 'OPEN_DOWNLOADS_FD_FAILED');
}
final fd = firstFd + _nextFd;
_nextFd++;
return fd;
}