Catch RuntimeException thrown by NotificationManager

In case anything goes wront during calling
'NotificationManger#activeNotification' an 'RuntimeException' will be
thrown. This results in a crash if not catched.

Resolves: #2078

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-05-27 12:15:09 +02:00
parent 7a3e81073e
commit 964dc2a76d
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E

View File

@ -1709,14 +1709,19 @@ class ChatController(args: Bundle) :
binding.messageInputView.findViewById<ImageButton>(R.id.attachmentButton)?.visibility = View.VISIBLE binding.messageInputView.findViewById<ImageButton>(R.id.attachmentButton)?.visibility = View.VISIBLE
} }
@Suppress("Detekt.TooGenericExceptionCaught")
private fun cancelNotificationsForCurrentConversation() { private fun cancelNotificationsForCurrentConversation() {
if (conversationUser != null) { if (conversationUser != null) {
if (!TextUtils.isEmpty(roomToken)) { if (!TextUtils.isEmpty(roomToken)) {
try {
NotificationUtils.cancelExistingNotificationsForRoom( NotificationUtils.cancelExistingNotificationsForRoom(
applicationContext, applicationContext,
conversationUser, conversationUser,
roomToken!! roomToken!!
) )
} catch (e: RuntimeException) {
Log.w(TAG, "Cancel notifications for current conversation results with an error.", e)
}
} }
} }
} }