Do not check buffered response on boot

This commit is contained in:
sim 2023-05-30 23:53:08 +02:00
parent 0a7fe27ca1
commit ac30bf8aa8
2 changed files with 13 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import okhttp3.sse.EventSourceListener
import org.unifiedpush.distributor.nextpush.api.response.SSEResponse import org.unifiedpush.distributor.nextpush.api.response.SSEResponse
import org.unifiedpush.distributor.nextpush.distributor.Distributor.deleteAppFromSSE import org.unifiedpush.distributor.nextpush.distributor.Distributor.deleteAppFromSSE
import org.unifiedpush.distributor.nextpush.distributor.Distributor.sendMessage 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.FailureHandler
import org.unifiedpush.distributor.nextpush.services.RestartNetworkCallback import org.unifiedpush.distributor.nextpush.services.RestartNetworkCallback
import org.unifiedpush.distributor.nextpush.services.RestartWorker import org.unifiedpush.distributor.nextpush.services.RestartWorker
@ -30,11 +31,15 @@ class SSEListener(val context: Context) : EventSourceListener() {
FailureHandler.newEventSource(context, eventSource) FailureHandler.newEventSource(context, eventSource)
startingTimer?.cancel() startingTimer?.cancel()
if (!bufferedResponseChecked) { if (!bufferedResponseChecked) {
if (StartReceiver.booting) {
StartReceiver.booting = false
} else {
startingTimer = Timer().schedule(45_000L /* 45secs */) { startingTimer = Timer().schedule(45_000L /* 45secs */) {
StartService.stopService() StartService.stopService()
showStartErrorNotification(context) showStartErrorNotification(context)
} }
} }
}
StartService.wakeLock?.let { StartService.wakeLock?.let {
while (it.isHeld) { while (it.isHeld) {
it.release() it.release()

View File

@ -8,8 +8,13 @@ import org.unifiedpush.distributor.nextpush.services.RestartWorker
class StartReceiver : BroadcastReceiver() { class StartReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
booting = true
if (intent.action == Intent.ACTION_BOOT_COMPLETED) { if (intent.action == Intent.ACTION_BOOT_COMPLETED) {
RestartWorker.startPeriodic(context) RestartWorker.startPeriodic(context)
} }
} }
companion object {
var booting = false
}
} }