mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 15:02:54 +00:00
Check for nulls when opening ContentResolver streams
This commit is contained in:
parent
1f69bf558e
commit
bee490d091
5 changed files with 16 additions and 0 deletions
|
@ -27,6 +27,9 @@ public class ExportTask extends ProgressDialogTask<ExportTask.Params, Exception>
|
|||
ExportTask.Params params = args[0];
|
||||
try (InputStream inStream = new FileInputStream(params.getFile());
|
||||
OutputStream outStream = getDialog().getContext().getContentResolver().openOutputStream(params.getDestUri(), "w")) {
|
||||
if (outStream == null) {
|
||||
throw new IOException("openOutputStream returned null");
|
||||
}
|
||||
IOUtils.copy(inStream, outStream);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -29,6 +29,10 @@ public class ImportFileTask extends ProgressDialogTask<ImportFileTask.Params, Im
|
|||
|
||||
Params p = params[0];
|
||||
try (InputStream inStream = context.getContentResolver().openInputStream(p.getUri())) {
|
||||
if (inStream == null) {
|
||||
throw new IOException("openInputStream returned null");
|
||||
}
|
||||
|
||||
String prefix = p.getNamePrefix() != null ? p.getNamePrefix() + "-" : "";
|
||||
String suffix = p.getNameSuffix() != null ? "-" + p.getNameSuffix() : "";
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ public class ImportIconPackTask extends ProgressDialogTask<ImportIconPackTask.Pa
|
|||
tempFile = File.createTempFile("icon-pack-", "", context.getCacheDir());
|
||||
try (InputStream inStream = context.getContentResolver().openInputStream(param.getUri());
|
||||
FileOutputStream outStream = new FileOutputStream(tempFile)) {
|
||||
if (inStream == null) {
|
||||
throw new IOException("openInputStream returned null");
|
||||
}
|
||||
IOUtils.copy(inStream, outStream);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ public class QrDecodeTask extends ProgressDialogTask<List<Uri>, List<QrDecodeTas
|
|||
}
|
||||
|
||||
try (InputStream inStream = context.getContentResolver().openInputStream(uri)) {
|
||||
if (inStream == null) {
|
||||
throw new IOException("openInputStream returned null");
|
||||
}
|
||||
com.google.zxing.Result result = QrCodeHelper.decodeFromStream(inStream);
|
||||
res.add(new Result(uri, fileName, result, null));
|
||||
} catch (QrCodeHelper.DecodeError | IOException e) {
|
||||
|
|
|
@ -85,6 +85,9 @@ public class VaultBackupManager {
|
|||
|
||||
try (FileInputStream inStream = new FileInputStream(tempFile);
|
||||
OutputStream outStream = _context.getContentResolver().openOutputStream(file.getUri())) {
|
||||
if (outStream == null) {
|
||||
throw new IOException("openOutputStream returned null");
|
||||
}
|
||||
IOUtils.copy(inStream, outStream);
|
||||
} catch (IOException e) {
|
||||
throw new VaultRepositoryException(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue