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

Commit 765c9bc2 authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix job preemption logic

We try to find the lowest-priority running job for preemption. The code
was looking at the wrong piece of information for deciding which to
select, leading to preemption of inappropriate jobs.

Along the way, fix the mock-based JobSchedulerServiceTest, which had not
yet been updated to track AppStandInternal LocalService changes.

Bug: 137019975
Test: atest com.android.server.job.JobSchedulerServiceTest
Test: atest CtsJobSchedulerTestCases
Change-Id: I902a7626e4a14c288388544f8a6b263770805a7f
parent 22bf81a6
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -372,9 +372,10 @@ class JobConcurrencyManager {
                    continue;
                }

                // TODO lastEvaluatedPriority should be evaluateJobPriorityLocked. (double check it)
                if (minPriorityForPreemption > nextPending.lastEvaluatedPriority) {
                    minPriorityForPreemption = nextPending.lastEvaluatedPriority;
                if (minPriorityForPreemption > jobPriority) {
                    // Step down the preemption threshold - wind up replacing
                    // the lowest-priority running job
                    minPriorityForPreemption = jobPriority;
                    selectedContextId = j;
                    // In this case, we're just going to preempt a low priority job, we're not
                    // actually starting a job, so don't set startingJob.