From ed5f5adc9b64c12305efb0e3866a3f03855a27bc Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 2 Jul 2019 10:06:20 -0400 Subject: [PATCH] Prevented avatar read failures from crashing. There are a handful of devices that refuse to use our AesGcmProvider, and as a result they would crash with AssertionErrors when downloading avatars. Still haven't found why, but for now, probably best to stop these devices from crashing, since it puts them in a crash loop, and the app is still usable without avatars. --- .../securesms/jobs/RetrieveProfileAvatarJob.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java index 33bf3467d7..14ee1604b2 100644 --- a/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java +++ b/src/org/thoughtcrime/securesms/jobs/RetrieveProfileAvatarJob.java @@ -102,7 +102,12 @@ public class RetrieveProfileAvatarJob extends BaseJob implements InjectableType InputStream avatarStream = receiver.retrieveProfileAvatar(profileAvatar, downloadDestination, profileKey, MAX_PROFILE_SIZE_BYTES); File decryptDestination = File.createTempFile("avatar", "jpg", context.getCacheDir()); - Util.copy(avatarStream, new FileOutputStream(decryptDestination)); + try { + Util.copy(avatarStream, new FileOutputStream(decryptDestination)); + } catch (AssertionError e) { + throw new IOException("Failed to copy stream. Likely a Conscrypt issue.", e); + } + decryptDestination.renameTo(AvatarHelper.getAvatarFile(context, recipient.getAddress())); } catch (PushNetworkException e) { if (e.getCause() instanceof NonSuccessfulResponseCodeException) {