Try not blocking main threads to start foreground service.

This commit is contained in:
Clark
2023-05-17 13:43:01 -04:00
committed by Greyson Parrelli
parent 99d3f9918f
commit 534c5c3c64
4 changed files with 16 additions and 5 deletions

View File

@@ -30,7 +30,7 @@ import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor
object FcmFetchManager {
private val TAG = Log.tag(FcmFetchManager::class.java)
private const val MAX_BLOCKING_TIME_MS = 500L
private val EXECUTOR = SerialMonoLifoExecutor(SignalExecutors.UNBOUNDED)
@Volatile
@@ -48,7 +48,7 @@ object FcmFetchManager {
try {
if (foreground) {
Log.i(TAG, "Starting in the foreground.")
ForegroundServiceUtil.startWhenCapableOrThrow(context, Intent(context, FcmFetchForegroundService::class.java))
ForegroundServiceUtil.startWhenCapableOrThrow(context, Intent(context, FcmFetchForegroundService::class.java), MAX_BLOCKING_TIME_MS)
startedForeground = true
} else {
Log.i(TAG, "Starting in the background.")