fix(fs): return an error when Android returns no file descriptor (#3636)

In plugins/fs/src/android.rs resolve_content_uri, a null `fd` from
getFileDescriptor (openAssetFileDescriptor returning null, e.g. for
virtual files) hit unimplemented!() and panicked inside the command handler.

It now returns an Unsupported I/O error. Also switches the two
io::Error::new(Other, ..) calls to io::Error::other, which clippy flags on
the Android target. Checked with cargo clippy --target aarch64-linux-android.
This commit is contained in:
Lucas Fernandes Nogueira authored and GitHub committed 2026-10-09 13:06:59 -03:00
1 parent 5de7ebfc95
commit 085a02835d
2 files changed
+13 -2

No files matched your search

+7 -2
View File
@@ -63,10 +63,11 @@ impl<R: Runtime> Fs<R> {
uri: impl Into<String>,
mode: impl Into<String>,
) -> crate::Result<std::fs::File> {
let uri = uri.into();
let result = self.0.run_mobile_plugin::<GetFileDescriptorResponse>(
"getFileDescriptor",
GetFileDescriptorPayload {
uri: uri.into(),
uri: uri.clone(),
mode: mode.into(),
},
)?;
@@ -76,7 +77,11 @@ impl<R: Runtime> Fs<R> {
std::fs::File::from_raw_fd(fd)
})
} else {
unimplemented!()
// the content provider did not return a file descriptor, e.g. for virtual files
Err(crate::Error::Io(std::io::Error::new(
std::io::ErrorKind::Unsupported,
format!("no file descriptor available for {uri}"),
)))
}
}
}