openDownloadsFd method

  1. @override
Future<int> openDownloadsFd({
  1. required String fileName,
  2. required String mimeType,
  3. String subdirectory = 'Recordings',
})
override

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;
}