From 8815cdc3de211e78cfbee67e0aefa1dc57a7e074 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 14 Sep 2021 09:18:27 -0400 Subject: [PATCH] Fix potential crash during notification processing. --- .../notifications/v2/NotificationStateProvider.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationStateProvider.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationStateProvider.kt index 5b0551bdaf..018625401c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationStateProvider.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/v2/NotificationStateProvider.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications.v2 import android.content.Context import androidx.annotation.WorkerThread +import org.signal.core.util.logging.Log import org.thoughtcrime.securesms.database.DatabaseFactory import org.thoughtcrime.securesms.database.MmsSmsColumns import org.thoughtcrime.securesms.database.MmsSmsDatabase @@ -10,12 +11,15 @@ import org.thoughtcrime.securesms.database.model.MessageRecord import org.thoughtcrime.securesms.database.model.ReactionRecord import org.thoughtcrime.securesms.recipients.Recipient import org.thoughtcrime.securesms.util.CursorUtil +import java.lang.IllegalStateException /** * Queries the message databases to determine messages that should be in notifications. */ object NotificationStateProvider { + private val TAG = Log.tag(NotificationStateProvider::class.java) + @WorkerThread fun constructNotificationState(context: Context, stickyThreads: Map): NotificationStateV2 { val messages: MutableList = mutableListOf() @@ -40,7 +44,13 @@ object NotificationStateProvider { lastReactionRead = CursorUtil.requireLong(unreadMessages, MmsSmsColumns.REACTIONS_LAST_SEEN) ) } - record = reader.next + try { + record = reader.next + } catch (e: IllegalStateException) { + // XXX Weird SQLCipher bug that's being investigated + record = null + Log.w(TAG, "Failed to read next record!", e) + } } } }