OSDN Git Service

JobParameters#isDeadlineExpired returns wrong value
authorMatthew Williams <mjwilliams@google.com>
Sat, 4 Apr 2015 04:52:02 +0000 (21:52 -0700)
committerMatthew Williams <mjwilliams@google.com>
Sat, 4 Apr 2015 04:52:02 +0000 (21:52 -0700)
If the job has no constraints other than a deadline
JobParameters#isOverrideDeadlineExpired will never
return true. The bug is that the better name for
this implementation is really
"jobParameters#areConstraintsSatisfied". Which are
ostensibly one and the same *except* for the case
where there are no constraints other than time.

Change-Id: I2e055b1279480283b13269b51cb489c64debfffd

services/core/java/com/android/server/job/JobServiceContext.java

index 63c8d92..53ceb2e 100644 (file)
@@ -153,8 +153,9 @@ public class JobServiceContext extends IJobCallback.Stub implements ServiceConne
             }
 
             mRunningJob = job;
-            mParams = new JobParameters(this, job.getJobId(), job.getExtras(),
-                    !job.isConstraintsSatisfied());
+            final boolean isDeadlineExpired =
+                    job.getLatestRunTimeElapsed() >= SystemClock.elapsedRealtime();
+            mParams = new JobParameters(this, job.getJobId(), job.getExtras(), isDeadlineExpired);
             mExecutionStartTimeElapsed = SystemClock.elapsedRealtime();
 
             mVerb = VERB_BINDING;