Fix RestartWorker not starting when ping is missing

This commit is contained in:
sim 2024-11-04 19:37:46 +00:00
parent 6ee69319fd
commit 3c89647889

View File

@ -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