Rename "long running" to "overtime".

Use "overtime job" instead of "long running" to refer to jobs that
have been running longer than their minimum execution timeout and
are thus running in overtime to avoid naming collision with new long
running job features.

Bug: 141645789
Test: Android builds
Change-Id: I7298f69aa16a422c9887b07a51d1f53314635978
This commit is contained in:
Kweku Adams
2022-10-27 19:04:18 +00:00
parent bd224c8afb
commit 1ff568de49
5 changed files with 21 additions and 19 deletions

View File

@@ -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;
@@ -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;
}
@@ -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();
@@ -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();

View File

@@ -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) {
@@ -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);
}
}
}

View File

@@ -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
* execution guarantee and are restricted by the changed restriction
* @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,

View File

@@ -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
@@ -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;
}

View File

@@ -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));