diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java index b5c5a3015..cff40a8a6 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/FullBackupExporter.java @@ -197,7 +197,9 @@ public class FullBackupExporter extends FullBackupBase { throwIfCanceled(cancellationSignal); if (avatar != null) { EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.PROGRESS, ++count, estimatedCount)); - outputStream.write(avatar.getFilename(), avatar.getInputStream(), avatar.getLength()); + try (InputStream inputStream = avatar.getInputStream()) { + outputStream.write(avatar.getFilename(), inputStream, avatar.getLength()); + } } } @@ -377,6 +379,7 @@ public class FullBackupExporter extends FullBackupBase { EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.PROGRESS, ++count, estimatedCount)); outputStream.write(new AttachmentId(rowId, uniqueId), inputStream, size); + inputStream.close(); } } catch (IOException e) { Log.w(TAG, e); @@ -395,8 +398,9 @@ public class FullBackupExporter extends FullBackupBase { if (!TextUtils.isEmpty(data) && size > 0) { EventBus.getDefault().post(new BackupEvent(BackupEvent.Type.PROGRESS, ++count, estimatedCount)); - InputStream inputStream = ModernDecryptingPartInputStream.createFor(attachmentSecret, random, new File(data), 0); - outputStream.writeSticker(rowId, inputStream, size); + try (InputStream inputStream = ModernDecryptingPartInputStream.createFor(attachmentSecret, random, new File(data), 0)) { + outputStream.writeSticker(rowId, inputStream, size); + } } } catch (IOException e) { Log.w(TAG, e); diff --git a/app/src/spinner/java/org/thoughtcrime/securesms/SpinnerApplicationContext.kt b/app/src/spinner/java/org/thoughtcrime/securesms/SpinnerApplicationContext.kt index d7f730020..f6cc03792 100644 --- a/app/src/spinner/java/org/thoughtcrime/securesms/SpinnerApplicationContext.kt +++ b/app/src/spinner/java/org/thoughtcrime/securesms/SpinnerApplicationContext.kt @@ -39,6 +39,14 @@ class SpinnerApplicationContext : ApplicationContext() { .build() ) + try { + Class.forName("dalvik.system.CloseGuard") + .getMethod("setEnabled", Boolean::class.javaPrimitiveType) + .invoke(null, true) + } catch (e: ReflectiveOperationException) { + throw RuntimeException(e) + } + Spinner.init( this, mapOf(