Loading apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -460,14 +460,14 @@ class JobConcurrencyManager { if (mPowerManager != null && mPowerManager.isDeviceIdleMode()) { synchronized (mLock) { stopUnexemptedJobsForDoze(); stopLongRunningJobsLocked("deep doze"); stopOvertimeJobsLocked("deep doze"); } } break; case PowerManager.ACTION_POWER_SAVE_MODE_CHANGED: if (mPowerManager != null && mPowerManager.isPowerSaveMode()) { synchronized (mLock) { stopLongRunningJobsLocked("battery saver"); stopOvertimeJobsLocked("battery saver"); } } break; Loading Loading @@ -555,7 +555,7 @@ class JobConcurrencyManager { * execution guarantee. */ @GuardedBy("mLock") boolean isJobLongRunningLocked(@NonNull JobStatus job) { boolean isJobInOvertimeLocked(@NonNull JobStatus job) { if (!mRunningJobs.contains(job)) { return false; } Loading Loading @@ -1043,7 +1043,7 @@ class JobConcurrencyManager { } @GuardedBy("mLock") private void stopLongRunningJobsLocked(@NonNull String debugReason) { private void stopOvertimeJobsLocked(@NonNull String debugReason) { for (int i = 0; i < mActiveServices.size(); ++i) { final JobServiceContext jsc = mActiveServices.get(i); final JobStatus jobStatus = jsc.getRunningJobLocked(); Loading @@ -1060,7 +1060,7 @@ class JobConcurrencyManager { * restricted by the given {@link JobRestriction}. */ @GuardedBy("mLock") void maybeStopLongRunningJobsLocked(@NonNull JobRestriction restriction) { void maybeStopOvertimeJobsLocked(@NonNull JobRestriction restriction) { for (int i = mActiveServices.size() - 1; i >= 0; --i) { final JobServiceContext jsc = mActiveServices.get(i); final JobStatus jobStatus = jsc.getRunningJobLocked(); Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -1870,10 +1870,10 @@ public class JobSchedulerService extends com.android.server.SystemService return mConcurrencyManager.isJobRunningLocked(job); } /** @see JobConcurrencyManager#isJobLongRunningLocked(JobStatus) */ /** @see JobConcurrencyManager#isJobInOvertimeLocked(JobStatus) */ @GuardedBy("mLock") public boolean isLongRunningLocked(JobStatus job) { return mConcurrencyManager.isJobLongRunningLocked(job); public boolean isJobInOvertimeLocked(JobStatus job) { return mConcurrencyManager.isJobInOvertimeLocked(job); } private void noteJobPending(JobStatus job) { Loading Loading @@ -2155,11 +2155,11 @@ public class JobSchedulerService extends com.android.server.SystemService @Override public void onRestrictionStateChanged(@NonNull JobRestriction restriction, boolean stopLongRunningJobs) { boolean stopOvertimeJobs) { mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget(); if (stopLongRunningJobs) { if (stopOvertimeJobs) { synchronized (mLock) { mConcurrencyManager.maybeStopLongRunningJobsLocked(restriction); mConcurrencyManager.maybeStopOvertimeJobsLocked(restriction); } } } Loading apex/jobscheduler/service/java/com/android/server/job/StateChangedListener.java +3 −3 Original line number Diff line number Diff line Loading @@ -41,11 +41,11 @@ public interface StateChangedListener { * Called by a {@link com.android.server.job.restrictions.JobRestriction} to notify the * JobScheduler that it should check on the state of all jobs. * * @param stopLongRunningJobs Whether to stop any jobs that have run for more than their minimum * @param stopOvertimeJobs Whether to stop any jobs that have run for more than their minimum * execution guarantee and are restricted by the changed restriction */ void onRestrictionStateChanged(@NonNull JobRestriction restriction, boolean stopLongRunningJobs); boolean stopOvertimeJobs); /** * Called by the controller to notify the JobManager that regardless of the state of the task, Loading apex/jobscheduler/service/java/com/android/server/job/restrictions/ThermalStatusRestriction.java +3 −3 Original line number Diff line number Diff line Loading @@ -90,11 +90,11 @@ public class ThermalStatusRestriction extends JobRestriction { final int priority = job.getEffectivePriority(); if (mThermalStatus >= HIGHER_PRIORITY_THRESHOLD) { // For moderate throttling, only let expedited jobs and high priority regular jobs that // haven't been running for long run. // haven't been running for a long time run. return !job.shouldTreatAsExpeditedJob() && !(priority == JobInfo.PRIORITY_HIGH && mService.isCurrentlyRunningLocked(job) && !mService.isLongRunningLocked(job)); && !mService.isJobInOvertimeLocked(job)); } if (mThermalStatus >= LOW_PRIORITY_THRESHOLD) { // For light throttling, throttle all min priority jobs and all low priority jobs that Loading @@ -102,7 +102,7 @@ public class ThermalStatusRestriction extends JobRestriction { return priority == JobInfo.PRIORITY_MIN || (priority == JobInfo.PRIORITY_LOW && (!mService.isCurrentlyRunningLocked(job) || mService.isLongRunningLocked(job))); || mService.isJobInOvertimeLocked(job))); } return false; } Loading services/tests/mockingservicestests/src/com/android/server/job/restrictions/ThermalStatusRestrictionTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -184,8 +184,10 @@ public class ThermalStatusRestrictionTest { when(mJobSchedulerService.isCurrentlyRunningLocked(jobLowPriorityRunning)).thenReturn(true); when(mJobSchedulerService.isCurrentlyRunningLocked(jobHighPriorityRunning)) .thenReturn(true); when(mJobSchedulerService.isLongRunningLocked(jobLowPriorityRunningLong)).thenReturn(true); when(mJobSchedulerService.isLongRunningLocked(jobHighPriorityRunningLong)).thenReturn(true); when(mJobSchedulerService.isJobInOvertimeLocked(jobLowPriorityRunningLong)) .thenReturn(true); when(mJobSchedulerService.isJobInOvertimeLocked(jobHighPriorityRunningLong)) .thenReturn(true); assertFalse(mThermalStatusRestriction.isJobRestricted(jobMinPriority)); assertFalse(mThermalStatusRestriction.isJobRestricted(jobLowPriority)); Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +5 −5 Original line number Diff line number Diff line Loading @@ -460,14 +460,14 @@ class JobConcurrencyManager { if (mPowerManager != null && mPowerManager.isDeviceIdleMode()) { synchronized (mLock) { stopUnexemptedJobsForDoze(); stopLongRunningJobsLocked("deep doze"); stopOvertimeJobsLocked("deep doze"); } } break; case PowerManager.ACTION_POWER_SAVE_MODE_CHANGED: if (mPowerManager != null && mPowerManager.isPowerSaveMode()) { synchronized (mLock) { stopLongRunningJobsLocked("battery saver"); stopOvertimeJobsLocked("battery saver"); } } break; Loading Loading @@ -555,7 +555,7 @@ class JobConcurrencyManager { * execution guarantee. */ @GuardedBy("mLock") boolean isJobLongRunningLocked(@NonNull JobStatus job) { boolean isJobInOvertimeLocked(@NonNull JobStatus job) { if (!mRunningJobs.contains(job)) { return false; } Loading Loading @@ -1043,7 +1043,7 @@ class JobConcurrencyManager { } @GuardedBy("mLock") private void stopLongRunningJobsLocked(@NonNull String debugReason) { private void stopOvertimeJobsLocked(@NonNull String debugReason) { for (int i = 0; i < mActiveServices.size(); ++i) { final JobServiceContext jsc = mActiveServices.get(i); final JobStatus jobStatus = jsc.getRunningJobLocked(); Loading @@ -1060,7 +1060,7 @@ class JobConcurrencyManager { * restricted by the given {@link JobRestriction}. */ @GuardedBy("mLock") void maybeStopLongRunningJobsLocked(@NonNull JobRestriction restriction) { void maybeStopOvertimeJobsLocked(@NonNull JobRestriction restriction) { for (int i = mActiveServices.size() - 1; i >= 0; --i) { final JobServiceContext jsc = mActiveServices.get(i); final JobStatus jobStatus = jsc.getRunningJobLocked(); Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +6 −6 Original line number Diff line number Diff line Loading @@ -1870,10 +1870,10 @@ public class JobSchedulerService extends com.android.server.SystemService return mConcurrencyManager.isJobRunningLocked(job); } /** @see JobConcurrencyManager#isJobLongRunningLocked(JobStatus) */ /** @see JobConcurrencyManager#isJobInOvertimeLocked(JobStatus) */ @GuardedBy("mLock") public boolean isLongRunningLocked(JobStatus job) { return mConcurrencyManager.isJobLongRunningLocked(job); public boolean isJobInOvertimeLocked(JobStatus job) { return mConcurrencyManager.isJobInOvertimeLocked(job); } private void noteJobPending(JobStatus job) { Loading Loading @@ -2155,11 +2155,11 @@ public class JobSchedulerService extends com.android.server.SystemService @Override public void onRestrictionStateChanged(@NonNull JobRestriction restriction, boolean stopLongRunningJobs) { boolean stopOvertimeJobs) { mHandler.obtainMessage(MSG_CHECK_JOB).sendToTarget(); if (stopLongRunningJobs) { if (stopOvertimeJobs) { synchronized (mLock) { mConcurrencyManager.maybeStopLongRunningJobsLocked(restriction); mConcurrencyManager.maybeStopOvertimeJobsLocked(restriction); } } } Loading
apex/jobscheduler/service/java/com/android/server/job/StateChangedListener.java +3 −3 Original line number Diff line number Diff line Loading @@ -41,11 +41,11 @@ public interface StateChangedListener { * Called by a {@link com.android.server.job.restrictions.JobRestriction} to notify the * JobScheduler that it should check on the state of all jobs. * * @param stopLongRunningJobs Whether to stop any jobs that have run for more than their minimum * @param stopOvertimeJobs Whether to stop any jobs that have run for more than their minimum * execution guarantee and are restricted by the changed restriction */ void onRestrictionStateChanged(@NonNull JobRestriction restriction, boolean stopLongRunningJobs); boolean stopOvertimeJobs); /** * Called by the controller to notify the JobManager that regardless of the state of the task, Loading
apex/jobscheduler/service/java/com/android/server/job/restrictions/ThermalStatusRestriction.java +3 −3 Original line number Diff line number Diff line Loading @@ -90,11 +90,11 @@ public class ThermalStatusRestriction extends JobRestriction { final int priority = job.getEffectivePriority(); if (mThermalStatus >= HIGHER_PRIORITY_THRESHOLD) { // For moderate throttling, only let expedited jobs and high priority regular jobs that // haven't been running for long run. // haven't been running for a long time run. return !job.shouldTreatAsExpeditedJob() && !(priority == JobInfo.PRIORITY_HIGH && mService.isCurrentlyRunningLocked(job) && !mService.isLongRunningLocked(job)); && !mService.isJobInOvertimeLocked(job)); } if (mThermalStatus >= LOW_PRIORITY_THRESHOLD) { // For light throttling, throttle all min priority jobs and all low priority jobs that Loading @@ -102,7 +102,7 @@ public class ThermalStatusRestriction extends JobRestriction { return priority == JobInfo.PRIORITY_MIN || (priority == JobInfo.PRIORITY_LOW && (!mService.isCurrentlyRunningLocked(job) || mService.isLongRunningLocked(job))); || mService.isJobInOvertimeLocked(job))); } return false; } Loading
services/tests/mockingservicestests/src/com/android/server/job/restrictions/ThermalStatusRestrictionTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -184,8 +184,10 @@ public class ThermalStatusRestrictionTest { when(mJobSchedulerService.isCurrentlyRunningLocked(jobLowPriorityRunning)).thenReturn(true); when(mJobSchedulerService.isCurrentlyRunningLocked(jobHighPriorityRunning)) .thenReturn(true); when(mJobSchedulerService.isLongRunningLocked(jobLowPriorityRunningLong)).thenReturn(true); when(mJobSchedulerService.isLongRunningLocked(jobHighPriorityRunningLong)).thenReturn(true); when(mJobSchedulerService.isJobInOvertimeLocked(jobLowPriorityRunningLong)) .thenReturn(true); when(mJobSchedulerService.isJobInOvertimeLocked(jobHighPriorityRunningLong)) .thenReturn(true); assertFalse(mThermalStatusRestriction.isJobRestricted(jobMinPriority)); assertFalse(mThermalStatusRestriction.isJobRestricted(jobLowPriority)); Loading