Skip to content

Commit 2a3aa9d

Browse files
committed
Use elapsedRealtime instead of currentTimeMillis
1 parent 1e91a3b commit 2a3aa9d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api

‎AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api/BackgroundExecutor.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Copyright (C) 2010-2016 eBusiness Information, Excilys Group
3+
* Copyright (C) 2016-2017 the AndroidAnnotations project
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
56
* use this file except in compliance with the License. You may obtain a copy of
@@ -27,6 +28,7 @@
2728
import java.util.concurrent.atomic.AtomicBoolean;
2829

2930
import android.os.Looper;
31+
import android.os.SystemClock;
3032
import android.util.Log;
3133

3234
public final class BackgroundExecutor {
@@ -384,7 +386,7 @@ public Task(String id, long delay, String serial) {
384386
}
385387
if (delay > 0) {
386388
remainingDelay = delay;
387-
targetTimeMillis = System.currentTimeMillis() + delay;
389+
targetTimeMillis = SystemClock.elapsedRealtime() + delay;
388390
}
389391
if (!"".equals(serial)) {
390392
this.serial = serial;
@@ -424,7 +426,7 @@ private void postExecute() {
424426
if (next != null) {
425427
if (next.remainingDelay != 0) {
426428
/* the delay may not have elapsed yet */
427-
next.remainingDelay = Math.max(0L, next.targetTimeMillis - System.currentTimeMillis());
429+
next.remainingDelay = Math.max(0L, next.targetTimeMillis - SystemClock.elapsedRealtime());
428430
}
429431
/* a task having the same serial was queued, execute it */
430432
BackgroundExecutor.execute(next);

0 commit comments

Comments
 (0)