diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt index 76e23c4..2e31c09 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt @@ -10,6 +10,7 @@ import okhttp3.sse.EventSourceListener import org.unifiedpush.distributor.nextpush.api.response.SSEResponse import org.unifiedpush.distributor.nextpush.distributor.Distributor.deleteAppFromSSE import org.unifiedpush.distributor.nextpush.distributor.Distributor.sendMessage +import org.unifiedpush.distributor.nextpush.receivers.StartReceiver import org.unifiedpush.distributor.nextpush.services.FailureHandler import org.unifiedpush.distributor.nextpush.services.RestartNetworkCallback import org.unifiedpush.distributor.nextpush.services.RestartWorker @@ -30,9 +31,13 @@ class SSEListener(val context: Context) : EventSourceListener() { FailureHandler.newEventSource(context, eventSource) startingTimer?.cancel() if (!bufferedResponseChecked) { - startingTimer = Timer().schedule(45_000L /* 45secs */) { - StartService.stopService() - showStartErrorNotification(context) + if (StartReceiver.booting) { + StartReceiver.booting = false + } else { + startingTimer = Timer().schedule(45_000L /* 45secs */) { + StartService.stopService() + showStartErrorNotification(context) + } } } StartService.wakeLock?.let { diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/receivers/StartReceiver.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/receivers/StartReceiver.kt index 54a9d50..cc583d5 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/receivers/StartReceiver.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/receivers/StartReceiver.kt @@ -8,8 +8,13 @@ import org.unifiedpush.distributor.nextpush.services.RestartWorker class StartReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { + booting = true if (intent.action == Intent.ACTION_BOOT_COMPLETED) { RestartWorker.startPeriodic(context) } } + + companion object { + var booting = false + } }