Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c3e645d authored by Kweku Adams's avatar Kweku Adams
Browse files

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
parent 0cea16dc
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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()));