Skip to content
Permalink
Browse files Browse the repository at this point in the history
chore: fix execution delay
  • Loading branch information
Oscar Rodriguez committed Oct 14, 2020
1 parent ea0c4cc commit 7fdc7de
Showing 1 changed file with 2 additions and 3 deletions.
Expand Up @@ -61,16 +61,14 @@ class FakeInfectionReportWorker(context: Context, workerParams: WorkerParameters

val now = clock.currentTimeMillis()
val executionDelay = 0L.coerceAtLeast(tDummy - now)
val executionDelayDays =
executionDelay / FACTOR_DAY_MILLIS

val constraints = Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
val work =
OneTimeWorkRequest
.Builder(FakeInfectionReportWorker::class.java)
.setInitialDelay(executionDelayDays, TimeUnit.MILLISECONDS)
.setInitialDelay(executionDelay, TimeUnit.MILLISECONDS)
.setConstraints(constraints)
.setInputData(Data.Builder().putLong(KEY_T_DUMMY, tDummy).build())
.build()
Expand All @@ -90,6 +88,7 @@ class FakeInfectionReportWorker(context: Context, workerParams: WorkerParameters
val now = clock.currentTimeMillis()
var tDummy = inputData.getLong(KEY_T_DUMMY, now)
while (tDummy < now) {
// only do request if it was planned to do in the last 48h
if (tDummy >= now - FACTOR_HOUR_MILLIS * MAX_DELAY_HOURS) {
if (BuildConfig.DEBUG)
DP3T.addWorkerStartedToHistory(applicationContext, TAG)
Expand Down

0 comments on commit 7fdc7de

Please sign in to comment.