Catch ForegroundServiceStartNotAllowedException in AttachmentProgressService listener.

This commit is contained in:
Greyson Parrelli
2026-04-27 18:31:20 +00:00
parent ad7e9c0fd7
commit cce1979716
@@ -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
}