diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt index 2eefa96..c01bfc2 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartWorker.kt @@ -35,7 +35,14 @@ class RestartWorker(ctx: Context, params: WorkerParameters) : Worker(ctx, params Log.d(TAG, "restartDate: ${restartDate.time}") if (currentDate.after(restartDate)) { Log.d(TAG, "We should have received an event before ${restartDate.time}. Restarting") - /** We do not update [FailureHandler]'s counter, it will be done by the next requests. */ + /** + * If there is at least one failure, we do not update [FailureHandler]'s counter, + * it will be done by the next requests. + * Else we add one failure to be sure the service restarts. + */ + if (!FailureHandler.hasFailed()) { + FailureHandler.once() + } StartService.startListener(applicationContext) // We consider this run as the first event AppCompanion.lastEventDate = currentDate