From 050849d30208ffb91c9b0ad89d2af6209c33b64e Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 22 Nov 2019 15:53:46 +1100 Subject: [PATCH] Wrapped envelope handing code inside a try-catch. --- .../securesms/jobs/PushReceivedJob.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushReceivedJob.java b/src/org/thoughtcrime/securesms/jobs/PushReceivedJob.java index 470bfbbe0e..f9dbfeea25 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushReceivedJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushReceivedJob.java @@ -25,22 +25,26 @@ public abstract class PushReceivedJob extends BaseJob { public void processEnvelope(@NonNull SignalServiceEnvelope envelope) { synchronized (RECEIVE_LOCK) { - if (envelope.hasSource()) { - Address source = Address.fromExternal(context, envelope.getSource()); - Recipient recipient = Recipient.from(context, source, false); + try { + if (envelope.hasSource()) { + Address source = Address.fromExternal(context, envelope.getSource()); + Recipient recipient = Recipient.from(context, source, false); - if (!isActiveNumber(recipient)) { - DatabaseFactory.getRecipientDatabase(context).setRegistered(recipient, RecipientDatabase.RegisteredState.REGISTERED); - ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(recipient, false)); + if (!isActiveNumber(recipient)) { + DatabaseFactory.getRecipientDatabase(context).setRegistered(recipient, RecipientDatabase.RegisteredState.REGISTERED); + ApplicationContext.getInstance(context).getJobManager().add(new DirectoryRefreshJob(recipient, false)); + } } - } - if (envelope.isReceipt()) { - handleReceipt(envelope); - } else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage() || envelope.isUnidentifiedSender() || envelope.isFriendRequest()) { - handleMessage(envelope); - } else { - Log.w(TAG, "Received envelope of unknown type: " + envelope.getType()); + if (envelope.isReceipt()) { + handleReceipt(envelope); + } else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage() || envelope.isUnidentifiedSender() || envelope.isFriendRequest()) { + handleMessage(envelope); + } else { + Log.w(TAG, "Received envelope of unknown type: " + envelope.getType()); + } + } catch (Exception e) { + Log.d("Loki", "Failed to process envelope: " + e); } } }