From 6d339cd023f75e1d54703513acf4164b3f9f6914 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 24 Sep 2019 14:26:04 -0400 Subject: [PATCH] Fix a crash when starting a call from the system contacts. --- .../securesms/webrtc/VoiceCallShare.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/org/thoughtcrime/securesms/webrtc/VoiceCallShare.java b/src/org/thoughtcrime/securesms/webrtc/VoiceCallShare.java index ebbaeb21a5..df727936db 100644 --- a/src/org/thoughtcrime/securesms/webrtc/VoiceCallShare.java +++ b/src/org/thoughtcrime/securesms/webrtc/VoiceCallShare.java @@ -8,9 +8,9 @@ import android.provider.ContactsContract; import android.text.TextUtils; import org.thoughtcrime.securesms.WebRtcCallActivity; -import org.thoughtcrime.securesms.database.Address; -import org.thoughtcrime.securesms.phonenumbers.PhoneNumberFormatter; +import org.thoughtcrime.securesms.recipients.Recipient; import org.thoughtcrime.securesms.service.WebRtcCallService; +import org.thoughtcrime.securesms.util.concurrent.SimpleTask; public class VoiceCallShare extends Activity { @@ -27,19 +27,20 @@ public class VoiceCallShare extends Activity { cursor = getContentResolver().query(getIntent().getData(), null, null, null, null); if (cursor != null && cursor.moveToNext()) { - String destination = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.RawContacts.Data.DATA1)); - Address address = Address.fromSerialized(PhoneNumberFormatter.get(this).format(destination)); - - if (!TextUtils.isEmpty(destination)) { - Intent serviceIntent = new Intent(this, WebRtcCallService.class); - serviceIntent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL); - serviceIntent.putExtra(WebRtcCallService.EXTRA_REMOTE_RECIPIENT, address); - startService(serviceIntent); + String destination = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.RawContacts.Data.DATA1)); - Intent activityIntent = new Intent(this, WebRtcCallActivity.class); - activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(activityIntent); - } + SimpleTask.run(() -> Recipient.external(this, destination), recipient -> { + if (!TextUtils.isEmpty(destination)) { + Intent serviceIntent = new Intent(this, WebRtcCallService.class); + serviceIntent.setAction(WebRtcCallService.ACTION_OUTGOING_CALL); + serviceIntent.putExtra(WebRtcCallService.EXTRA_REMOTE_RECIPIENT, recipient.getId()); + startService(serviceIntent); + + Intent activityIntent = new Intent(this, WebRtcCallActivity.class); + activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(activityIntent); + } + }); } } finally { if (cursor != null) cursor.close();