Skip to content

Commit

Permalink
Apply jitter to maintenance check.
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonides-proton authored and mateusz-markowicz committed Jan 17, 2024
1 parent c6f8eaf commit a9b9675
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class MaintenanceTracker(
scope.launch {
vpnStateMonitor.status.collect { status ->
if (status.state == VpnState.Connected) {
task.scheduleIn(jitterMs(getScheduleDelay()))
task.scheduleIn(getScheduleDelay())
} else if (status.state == VpnState.Disabled) {
task.cancelSchedule()
}
}
}
}

private fun getScheduleDelay(): Long = TimeUnit.MINUTES.toMillis(appConfig.getMaintenanceTrackerDelay())
private fun getScheduleDelay(): Long = jitterMs(TimeUnit.MINUTES.toMillis(appConfig.getMaintenanceTrackerDelay()))

private fun now() = SystemClock.elapsedRealtime()

Expand Down

0 comments on commit a9b9675

Please sign in to comment.