Rethrow SecurityExceptions when opening files on removable drives.

This commit is contained in:
akwizgran
2022-04-17 11:36:16 +01:00
parent 74a3f54d28
commit 3c08e86822

View File

@@ -32,13 +32,22 @@ class AndroidRemovableDrivePlugin extends RemovableDrivePlugin {
InputStream openInputStream(TransportProperties p) throws IOException { InputStream openInputStream(TransportProperties p) throws IOException {
String uri = p.get(PROP_URI); String uri = p.get(PROP_URI);
if (isNullOrEmpty(uri)) throw new IllegalArgumentException(); if (isNullOrEmpty(uri)) throw new IllegalArgumentException();
return app.getContentResolver().openInputStream(Uri.parse(uri)); try {
return app.getContentResolver().openInputStream(Uri.parse(uri));
} catch (SecurityException e) {
throw new IOException(e);
}
} }
@Override @Override
OutputStream openOutputStream(TransportProperties p) throws IOException { OutputStream openOutputStream(TransportProperties p) throws IOException {
String uri = p.get(PROP_URI); String uri = p.get(PROP_URI);
if (isNullOrEmpty(uri)) throw new IllegalArgumentException(); if (isNullOrEmpty(uri)) throw new IllegalArgumentException();
return app.getContentResolver().openOutputStream(Uri.parse(uri), "wt"); try {
return app.getContentResolver()
.openOutputStream(Uri.parse(uri), "wt");
} catch (SecurityException e) {
throw new IOException(e);
}
} }
} }