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

Commit 0359388a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Shift job readiness re-evaluation check." into udc-dev

parents 4f53ae93 a2282a9c
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1577,8 +1577,6 @@ public class JobSchedulerService extends com.android.server.SystemService
                mJobPackageTracker.notePending(jobStatus);
                mPendingJobQueue.add(jobStatus);
                maybeRunPendingJobsLocked();
            } else {
                evaluateControllerStatesLocked(jobStatus);
            }
        }
        return JobScheduler.RESULT_SUCCESS;
@@ -3050,8 +3048,6 @@ public class JobSchedulerService extends com.android.server.SystemService
                    Slog.d(TAG, "    queued " + job.toShortString());
                }
                newReadyJobs.add(job);
            } else {
                evaluateControllerStatesLocked(job);
            }
        }

@@ -3171,7 +3167,6 @@ public class JobSchedulerService extends com.android.server.SystemService
                } else if (mPendingJobQueue.remove(job)) {
                    noteJobNonPending(job);
                }
                evaluateControllerStatesLocked(job);
            }
        }

@@ -3297,7 +3292,7 @@ public class JobSchedulerService extends com.android.server.SystemService

    @GuardedBy("mLock")
    boolean isReadyToBeExecutedLocked(JobStatus job, boolean rejectActive) {
        final boolean jobReady = job.isReady();
        final boolean jobReady = job.isReady() || evaluateControllerStatesLocked(job);

        if (DEBUG) {
            Slog.v(TAG, "isReadyToBeExecutedLocked: " + job.toShortString()
@@ -3372,12 +3367,17 @@ public class JobSchedulerService extends com.android.server.SystemService
        return !appIsBad;
    }

    /**
     * Gets each controller to evaluate the job's state
     * and then returns the value of {@link JobStatus#isReady()}.
     */
    @VisibleForTesting
    void evaluateControllerStatesLocked(final JobStatus job) {
    boolean evaluateControllerStatesLocked(final JobStatus job) {
        for (int c = mControllers.size() - 1; c >= 0; --c) {
            final StateController sc = mControllers.get(c);
            sc.evaluateStateLocked(job);
        }
        return job.isReady();
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -1132,7 +1132,7 @@ public class JobSchedulerServiceTest {
    @Test
    public void testRareJobBatching() {
        spyOn(mService);
        doNothing().when(mService).evaluateControllerStatesLocked(any());
        doReturn(false).when(mService).evaluateControllerStatesLocked(any());
        doNothing().when(mService).noteJobsPending(any());
        doReturn(true).when(mService).isReadyToBeExecutedLocked(any(), anyBoolean());
        advanceElapsedClock(24 * HOUR_IN_MILLIS);