FakeDownloadsChannel class

In-memory DownloadsChannel with no platform-channel dependency — for unit-testing RecordingController.startRecordingToDownloads/ startIqRecordingToDownloads/shareRecording without an Android device.

Hands out incrementing fake fds starting at firstFd and tracks every call so a test can assert on the filenames/mime types/subdirectories used and what got shared.

Constructors

FakeDownloadsChannel({int firstFd = 1000})

Properties

failNextOpen bool
Set to make the next openDownloadsFd call fail — simulates the legacy-Android (pre-API 29) fallback path, where there's no MediaStore.Downloads collection to insert into.
getter/setter pair
finishedFds List<int>
final
firstFd int
final
hashCode int
The hash code for this object.
no setterinherited
openCalls List<({String fileName, String mimeType, String subdirectory})>
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shareCalls List<({String mimeType, String? path, String? uri})>
final

Methods

finishDownloadsFd(int fd) Future<String?>
Finalizes a recording opened via openDownloadsFd — clears IS_PENDING so it becomes visible to other apps — and returns its content:// URI (for a later shareFile call), or null if fd wasn't tracked (only call this for recordings that actually used openDownloadsFd).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openDownloadsFd({required String fileName, required String mimeType, String subdirectory = 'Recordings'}) Future<int>
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.
shareFile({String? uri, String? path, required String mimeType}) Future<void>
Shares a recording via Android's native chooser. Pass uri (a content:// URI, from a MediaStore/Downloads recording) if you have one; otherwise pass path (a plain file — the legacy fallback or a developer's own chosen directory), which gets resolved to a shareable URI via a bundled FileProvider first. Exactly one of uri/path must be given.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited