You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement file sharing by file descriptor
Using custom gdbus code, as libportal doesn't expose the raw org.freedesktop.portal.OpenURI.OpenFile method.
This commit is contained in:
@@ -23,7 +23,15 @@ public class ContentResolver {
|
||||
}
|
||||
|
||||
public ParcelFileDescriptor openFileDescriptor(Uri uri, String mode) throws FileNotFoundException {
|
||||
return ParcelFileDescriptor.open(new File(uri.toString()), ParcelFileDescriptor.parseMode(mode));
|
||||
if ("file".equals(uri.getScheme())) {
|
||||
return ParcelFileDescriptor.open(new File(uri.toString()), ParcelFileDescriptor.parseMode(mode));
|
||||
} else {
|
||||
ContentProvider provider = ContentProvider.providers.get(uri.getAuthority());
|
||||
if (provider != null)
|
||||
return provider.openFile(uri, mode);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||
@@ -53,4 +61,12 @@ public class ContentResolver {
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getType(Uri uri) {
|
||||
ContentProvider provider = ContentProvider.providers.get(uri.getAuthority());
|
||||
if (provider != null)
|
||||
return provider.getType(uri);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user