Remove satisfied timed jobs from the tracked list.
Remove jobs whose timing constraints have been deemed as satisfied
outside of the normal alarm checking flow from the tracked job list.
They would have eventually be removed, but there's no reason to keep
them in the list longer than necessary.
Bug: 141645789
Test: Android builds
Change-Id: I9d5a78f747a9195621205e62279f92c6c9bba8cc
diff --git a/apex/jobscheduler/service/java/com/android/server/job/controllers/TimeController.java b/apex/jobscheduler/service/java/com/android/server/job/controllers/TimeController.java
index 61d7470..fc60228 100644
--- a/apex/jobscheduler/service/java/com/android/server/job/controllers/TimeController.java
+++ b/apex/jobscheduler/service/java/com/android/server/job/controllers/TimeController.java
@@ -161,6 +161,7 @@
// Scheduler.
mStateChangedListener.onRunJobNow(job);
}
+ mTrackedJobs.remove(job);
Counter.logIncrement(
"job_scheduler.value_job_scheduler_job_deadline_expired_counter");
} else if (wouldBeReadyWithConstraintLocked(job, JobStatus.CONSTRAINT_DEADLINE)) {
@@ -174,8 +175,11 @@
&& job.getEarliestRunTime() <= mNextDelayExpiredElapsedMillis) {
// Since this is just the delay, we don't need to rush the Scheduler to run the job
// immediately if the constraint is satisfied here.
- if (!evaluateTimingDelayConstraint(job, nowElapsedMillis)
- && wouldBeReadyWithConstraintLocked(job, JobStatus.CONSTRAINT_TIMING_DELAY)) {
+ if (evaluateTimingDelayConstraint(job, nowElapsedMillis)) {
+ if (canStopTrackingJobLocked(job)) {
+ mTrackedJobs.remove(job);
+ }
+ } else if (wouldBeReadyWithConstraintLocked(job, JobStatus.CONSTRAINT_TIMING_DELAY)) {
// This job's delay is earlier than the current set alarm. Update the alarm.
setDelayExpiredAlarmLocked(job.getEarliestRunTime(),
mService.deriveWorkSource(job.getSourceUid(), job.getSourcePackageName()));