From cce1979716a0f497b2c19f7fbfa6afca5608e7ec Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 27 Apr 2026 18:31:20 +0000 Subject: [PATCH] Catch ForegroundServiceStartNotAllowedException in AttachmentProgressService listener. --- .../securesms/service/AttachmentProgressService.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/AttachmentProgressService.kt b/app/src/main/java/org/thoughtcrime/securesms/service/AttachmentProgressService.kt index 23d77aa8cc..9ba7bfbdfe 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/AttachmentProgressService.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/service/AttachmentProgressService.kt @@ -5,6 +5,7 @@ package org.thoughtcrime.securesms.service +import android.app.ForegroundServiceStartNotAllowedException import android.app.Notification import android.app.PendingIntent import android.content.Context @@ -119,6 +120,9 @@ class AttachmentProgressService : SafeForegroundService() { if (Build.VERSION.SDK_INT >= 31 && e.message?.contains("Time limit", ignoreCase = true) == true) { Log.w(TAG, "Foreground service timed out, but not in onTimeout call", e) stopDueToTimeout() + } else if (Build.VERSION.SDK_INT >= 31 && e is ForegroundServiceStartNotAllowedException) { + Log.w(TAG, "Unable to start foreground service", e) + stopDueToTimeout() } else { throw e }