From 2a3aa9d0567d2d6324bd46bcccf04736e1f5766d Mon Sep 17 00:00:00 2001 From: Kay-Uwe Janssen Date: Tue, 7 Mar 2017 19:53:30 +0100 Subject: [PATCH] Use elapsedRealtime instead of currentTimeMillis --- .../java/org/androidannotations/api/BackgroundExecutor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api/BackgroundExecutor.java b/AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api/BackgroundExecutor.java index 1b1b25b787..51edb6469e 100644 --- a/AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api/BackgroundExecutor.java +++ b/AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java/org/androidannotations/api/BackgroundExecutor.java @@ -1,5 +1,6 @@ /** * Copyright (C) 2010-2016 eBusiness Information, Excilys Group + * Copyright (C) 2016-2017 the AndroidAnnotations project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -27,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import android.os.Looper; +import android.os.SystemClock; import android.util.Log; public final class BackgroundExecutor { @@ -384,7 +386,7 @@ public Task(String id, long delay, String serial) { } if (delay > 0) { remainingDelay = delay; - targetTimeMillis = System.currentTimeMillis() + delay; + targetTimeMillis = SystemClock.elapsedRealtime() + delay; } if (!"".equals(serial)) { this.serial = serial; @@ -424,7 +426,7 @@ private void postExecute() { if (next != null) { if (next.remainingDelay != 0) { /* the delay may not have elapsed yet */ - next.remainingDelay = Math.max(0L, next.targetTimeMillis - System.currentTimeMillis()); + next.remainingDelay = Math.max(0L, next.targetTimeMillis - SystemClock.elapsedRealtime()); } /* a task having the same serial was queued, execute it */ BackgroundExecutor.execute(next);