Skip to content

Commit

Permalink
Fix crash when changing contact color without contacts permission.
Browse files Browse the repository at this point in the history
On mulit-device app, after the contact color is changed, a multi-device
contact update job is triggered, which tries to access the system
avatar.
This causes a crash if the user has revoked the contacts permission.
  • Loading branch information
AsamK authored and cody-signal committed Feb 8, 2021
1 parent 8f51bdc commit e0128e7
Showing 1 changed file with 7 additions and 1 deletion.
@@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.jobs;

import android.Manifest;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.net.Uri;
Expand All @@ -20,6 +21,7 @@
import org.thoughtcrime.securesms.jobmanager.Data;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.permissions.Permissions;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.providers.BlobProvider;
import org.thoughtcrime.securesms.recipients.Recipient;
Expand Down Expand Up @@ -304,7 +306,11 @@ private Optional<SignalServiceAttachmentStream> getSystemAvatar(@Nullable Uri ur
if (uri == null) {
return Optional.absent();
}


if (!Permissions.hasAny(context, Manifest.permission.READ_CONTACTS, Manifest.permission.WRITE_CONTACTS)) {
return Optional.absent();
}

Uri displayPhotoUri = Uri.withAppendedPath(uri, ContactsContract.Contacts.Photo.DISPLAY_PHOTO);

try {
Expand Down

0 comments on commit e0128e7

Please sign in to comment.