Be more resistent to android disallowing service starts.
This commit is contained in:
parent
d5d7c73ebf
commit
523f9c7409
1 changed files with 19 additions and 14 deletions
|
@ -10,6 +10,7 @@ import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
|||
import org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob
|
||||
import org.thoughtcrime.securesms.messages.RestStrategy
|
||||
import org.thoughtcrime.securesms.util.concurrent.SerialMonoLifoExecutor
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
/**
|
||||
* Our goals with FCM processing are as follows:
|
||||
|
@ -42,6 +43,7 @@ object FcmFetchManager {
|
|||
@JvmStatic
|
||||
fun enqueue(context: Context, foreground: Boolean) {
|
||||
synchronized(this) {
|
||||
try {
|
||||
if (foreground) {
|
||||
Log.i(TAG, "Starting in the foreground.")
|
||||
ContextCompat.startForegroundService(context, Intent(context, FcmFetchForegroundService::class.java))
|
||||
|
@ -59,6 +61,9 @@ object FcmFetchManager {
|
|||
activeCount++
|
||||
Log.i(TAG, "Incrementing active count to $activeCount")
|
||||
}
|
||||
} catch (e: IllegalStateException) {
|
||||
Log.w(TAG, "Failed to start service!", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue