Loading apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +12 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.UserSwitchObserver; import android.app.job.JobInfo; import android.app.job.JobParameters; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -469,7 +470,7 @@ class JobConcurrencyManager { // Update the priorities of jobs that aren't running, and also count the pending work types. // Do this before the following loop to hopefully reduce the cost of // shouldStopRunningJobLocked(). updateNonRunningPriorities(pendingJobs, true); updateNonRunningPrioritiesLocked(pendingJobs, true); for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) { final JobServiceContext js = activeServices.get(i); Loading Loading @@ -585,7 +586,8 @@ class JobConcurrencyManager { + activeServices.get(i).getRunningJobLocked()); } // preferredUid will be set to uid of currently running job. activeServices.get(i).preemptExecutingJobLocked(preemptReasonForContext[i]); activeServices.get(i).cancelExecutingJobLocked( JobParameters.REASON_PREEMPT, preemptReasonForContext[i]); preservePreferredUid = true; } else { final JobStatus pendingJob = contextIdToJobMap[i]; Loading @@ -610,7 +612,8 @@ class JobConcurrencyManager { mWorkCountTracker.getRunningJobCount(WORK_TYPE_TOP)); } private void updateNonRunningPriorities(@NonNull final List<JobStatus> pendingJobs, @GuardedBy("mLock") private void updateNonRunningPrioritiesLocked(@NonNull final List<JobStatus> pendingJobs, boolean updateCounter) { for (int i = 0; i < pendingJobs.size(); i++) { final JobStatus pending = pendingJobs.get(i); Loading @@ -628,6 +631,7 @@ class JobConcurrencyManager { } } @GuardedBy("mLock") private void startJobLocked(@NonNull JobServiceContext worker, @NonNull JobStatus jobStatus, @WorkType final int workType) { final List<StateController> controllers = mService.mControllers; Loading @@ -647,6 +651,7 @@ class JobConcurrencyManager { } } @GuardedBy("mLock") void onJobCompletedLocked(@NonNull JobServiceContext worker, @NonNull JobStatus jobStatus, @WorkType final int workType) { mWorkCountTracker.onJobFinished(workType); Loading @@ -655,7 +660,7 @@ class JobConcurrencyManager { if (worker.getPreferredUid() != JobServiceContext.NO_PREFERRED_UID) { updateCounterConfigLocked(); // Preemption case needs special care. updateNonRunningPriorities(pendingJobs, false); updateNonRunningPrioritiesLocked(pendingJobs, false); JobStatus highestPriorityJob = null; int highPriWorkType = workType; Loading Loading @@ -726,7 +731,7 @@ class JobConcurrencyManager { } } else if (pendingJobs.size() > 0) { updateCounterConfigLocked(); updateNonRunningPriorities(pendingJobs, false); updateNonRunningPrioritiesLocked(pendingJobs, false); // This slot is now free and we have pending jobs. Start the highest priority job we // find. Loading Loading @@ -775,6 +780,7 @@ class JobConcurrencyManager { * another job to run, or if system state suggests the job should stop. */ @Nullable @GuardedBy("mLock") String shouldStopRunningJobLocked(@NonNull JobServiceContext context) { final JobStatus js = context.getRunningJobLocked(); if (js == null) { Loading Loading @@ -881,6 +887,7 @@ class JobConcurrencyManager { return s.toString(); } @GuardedBy("mLock") void updateConfigLocked() { DeviceConfig.Properties properties = DeviceConfig.getProperties(DeviceConfig.NAMESPACE_JOB_SCHEDULER); Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −13 Original line number Diff line number Diff line Loading @@ -269,8 +269,6 @@ public final class JobServiceContext implements ServiceConnection { try { final int bindFlags; if (job.shouldTreatAsExpeditedJob()) { // TODO(171305774): The job should run on the little cores. We'll probably need // another binding flag for that. bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_ALLOW_NETWORK_ACCESS Loading Loading @@ -355,15 +353,10 @@ public final class JobServiceContext implements ServiceConnection { /** Called externally when a job that was scheduled for execution should be cancelled. */ @GuardedBy("mLock") void cancelExecutingJobLocked(int reason, String debugReason) { void cancelExecutingJobLocked(int reason, @NonNull String debugReason) { doCancelLocked(reason, debugReason); } @GuardedBy("mLock") void preemptExecutingJobLocked(@NonNull String reason) { doCancelLocked(JobParameters.REASON_PREEMPT, reason); } int getPreferredUid() { return mPreferredUid; } Loading Loading @@ -620,7 +613,7 @@ public final class JobServiceContext implements ServiceConnection { } @GuardedBy("mLock") private void doCancelLocked(int stopReasonCode, String debugReason) { private void doCancelLocked(int stopReasonCode, @Nullable String debugReason) { if (mVerb == VERB_FINISHED) { if (DEBUG) { Slog.d(TAG, Loading Loading @@ -733,7 +726,7 @@ public final class JobServiceContext implements ServiceConnection { * _ENDING -> No point in doing anything here, so we ignore. */ @GuardedBy("mLock") private void handleCancelLocked(String reason) { private void handleCancelLocked(@Nullable String reason) { if (JobSchedulerService.DEBUG) { Slog.d(TAG, "Handling cancel for: " + mRunningJob.getJobId() + " " + VERB_STRINGS[mVerb]); Loading Loading @@ -817,7 +810,7 @@ public final class JobServiceContext implements ServiceConnection { * VERB_STOPPING. */ @GuardedBy("mLock") private void sendStopMessageLocked(String reason) { private void sendStopMessageLocked(@Nullable String reason) { removeOpTimeOutLocked(); if (mVerb != VERB_EXECUTING) { Slog.e(TAG, "Sending onStopJob for a job that isn't started. " + mRunningJob); Loading @@ -843,7 +836,7 @@ public final class JobServiceContext implements ServiceConnection { * we want to clean up internally. */ @GuardedBy("mLock") private void closeAndCleanupJobLocked(boolean reschedule, String reason) { private void closeAndCleanupJobLocked(boolean reschedule, @Nullable String reason) { final JobStatus completedJob; if (mVerb == VERB_FINISHED) { return; Loading Loading @@ -889,7 +882,7 @@ public final class JobServiceContext implements ServiceConnection { mJobConcurrencyManager.onJobCompletedLocked(this, completedJob, workType); } private void applyStoppedReasonLocked(String reason) { private void applyStoppedReasonLocked(@Nullable String reason) { if (reason != null && mStoppedReason == null) { mStoppedReason = reason; mStoppedTime = sElapsedRealtimeClock.millis(); Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +12 −5 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.UserSwitchObserver; import android.app.job.JobInfo; import android.app.job.JobParameters; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -469,7 +470,7 @@ class JobConcurrencyManager { // Update the priorities of jobs that aren't running, and also count the pending work types. // Do this before the following loop to hopefully reduce the cost of // shouldStopRunningJobLocked(). updateNonRunningPriorities(pendingJobs, true); updateNonRunningPrioritiesLocked(pendingJobs, true); for (int i = 0; i < MAX_JOB_CONTEXTS_COUNT; i++) { final JobServiceContext js = activeServices.get(i); Loading Loading @@ -585,7 +586,8 @@ class JobConcurrencyManager { + activeServices.get(i).getRunningJobLocked()); } // preferredUid will be set to uid of currently running job. activeServices.get(i).preemptExecutingJobLocked(preemptReasonForContext[i]); activeServices.get(i).cancelExecutingJobLocked( JobParameters.REASON_PREEMPT, preemptReasonForContext[i]); preservePreferredUid = true; } else { final JobStatus pendingJob = contextIdToJobMap[i]; Loading @@ -610,7 +612,8 @@ class JobConcurrencyManager { mWorkCountTracker.getRunningJobCount(WORK_TYPE_TOP)); } private void updateNonRunningPriorities(@NonNull final List<JobStatus> pendingJobs, @GuardedBy("mLock") private void updateNonRunningPrioritiesLocked(@NonNull final List<JobStatus> pendingJobs, boolean updateCounter) { for (int i = 0; i < pendingJobs.size(); i++) { final JobStatus pending = pendingJobs.get(i); Loading @@ -628,6 +631,7 @@ class JobConcurrencyManager { } } @GuardedBy("mLock") private void startJobLocked(@NonNull JobServiceContext worker, @NonNull JobStatus jobStatus, @WorkType final int workType) { final List<StateController> controllers = mService.mControllers; Loading @@ -647,6 +651,7 @@ class JobConcurrencyManager { } } @GuardedBy("mLock") void onJobCompletedLocked(@NonNull JobServiceContext worker, @NonNull JobStatus jobStatus, @WorkType final int workType) { mWorkCountTracker.onJobFinished(workType); Loading @@ -655,7 +660,7 @@ class JobConcurrencyManager { if (worker.getPreferredUid() != JobServiceContext.NO_PREFERRED_UID) { updateCounterConfigLocked(); // Preemption case needs special care. updateNonRunningPriorities(pendingJobs, false); updateNonRunningPrioritiesLocked(pendingJobs, false); JobStatus highestPriorityJob = null; int highPriWorkType = workType; Loading Loading @@ -726,7 +731,7 @@ class JobConcurrencyManager { } } else if (pendingJobs.size() > 0) { updateCounterConfigLocked(); updateNonRunningPriorities(pendingJobs, false); updateNonRunningPrioritiesLocked(pendingJobs, false); // This slot is now free and we have pending jobs. Start the highest priority job we // find. Loading Loading @@ -775,6 +780,7 @@ class JobConcurrencyManager { * another job to run, or if system state suggests the job should stop. */ @Nullable @GuardedBy("mLock") String shouldStopRunningJobLocked(@NonNull JobServiceContext context) { final JobStatus js = context.getRunningJobLocked(); if (js == null) { Loading Loading @@ -881,6 +887,7 @@ class JobConcurrencyManager { return s.toString(); } @GuardedBy("mLock") void updateConfigLocked() { DeviceConfig.Properties properties = DeviceConfig.getProperties(DeviceConfig.NAMESPACE_JOB_SCHEDULER); Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −13 Original line number Diff line number Diff line Loading @@ -269,8 +269,6 @@ public final class JobServiceContext implements ServiceConnection { try { final int bindFlags; if (job.shouldTreatAsExpeditedJob()) { // TODO(171305774): The job should run on the little cores. We'll probably need // another binding flag for that. bindFlags = Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_ALMOST_PERCEPTIBLE | Context.BIND_ALLOW_NETWORK_ACCESS Loading Loading @@ -355,15 +353,10 @@ public final class JobServiceContext implements ServiceConnection { /** Called externally when a job that was scheduled for execution should be cancelled. */ @GuardedBy("mLock") void cancelExecutingJobLocked(int reason, String debugReason) { void cancelExecutingJobLocked(int reason, @NonNull String debugReason) { doCancelLocked(reason, debugReason); } @GuardedBy("mLock") void preemptExecutingJobLocked(@NonNull String reason) { doCancelLocked(JobParameters.REASON_PREEMPT, reason); } int getPreferredUid() { return mPreferredUid; } Loading Loading @@ -620,7 +613,7 @@ public final class JobServiceContext implements ServiceConnection { } @GuardedBy("mLock") private void doCancelLocked(int stopReasonCode, String debugReason) { private void doCancelLocked(int stopReasonCode, @Nullable String debugReason) { if (mVerb == VERB_FINISHED) { if (DEBUG) { Slog.d(TAG, Loading Loading @@ -733,7 +726,7 @@ public final class JobServiceContext implements ServiceConnection { * _ENDING -> No point in doing anything here, so we ignore. */ @GuardedBy("mLock") private void handleCancelLocked(String reason) { private void handleCancelLocked(@Nullable String reason) { if (JobSchedulerService.DEBUG) { Slog.d(TAG, "Handling cancel for: " + mRunningJob.getJobId() + " " + VERB_STRINGS[mVerb]); Loading Loading @@ -817,7 +810,7 @@ public final class JobServiceContext implements ServiceConnection { * VERB_STOPPING. */ @GuardedBy("mLock") private void sendStopMessageLocked(String reason) { private void sendStopMessageLocked(@Nullable String reason) { removeOpTimeOutLocked(); if (mVerb != VERB_EXECUTING) { Slog.e(TAG, "Sending onStopJob for a job that isn't started. " + mRunningJob); Loading @@ -843,7 +836,7 @@ public final class JobServiceContext implements ServiceConnection { * we want to clean up internally. */ @GuardedBy("mLock") private void closeAndCleanupJobLocked(boolean reschedule, String reason) { private void closeAndCleanupJobLocked(boolean reschedule, @Nullable String reason) { final JobStatus completedJob; if (mVerb == VERB_FINISHED) { return; Loading Loading @@ -889,7 +882,7 @@ public final class JobServiceContext implements ServiceConnection { mJobConcurrencyManager.onJobCompletedLocked(this, completedJob, workType); } private void applyStoppedReasonLocked(String reason) { private void applyStoppedReasonLocked(@Nullable String reason) { if (reason != null && mStoppedReason == null) { mStoppedReason = reason; mStoppedTime = sElapsedRealtimeClock.millis(); Loading