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
This commit is contained in:
Kweku Adams
2022-11-04 20:30:44 +00:00
parent 0cea16dce2
commit 3c3e645dd5

View File

@@ -161,6 +161,7 @@ public final class TimeController extends StateController {
// 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 @@ public final class TimeController extends StateController {
&& 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()));