From 3c89647889cfd2bd9f74253269e4683100c2af7f Mon Sep 17 00:00:00 2001 From: sim Date: Mon, 4 Nov 2024 19:37:46 +0000 Subject: [PATCH] Fix RestartWorker not starting when ping is missing --- .../distributor/nextpush/services/RestartWorker.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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