Merge "Marking job deferral time in QuotaController." into qt-dev
am: f2079ee257
Change-Id: I7d6ef60cdf3b372a4052dde78af28d6a0aaf2a55
This commit is contained in:
@@ -2280,8 +2280,6 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
if (bucket >= mConstants.STANDBY_BEATS.length
|
||||
|| (mHeartbeat > appLastRan
|
||||
&& mHeartbeat < appLastRan + mConstants.STANDBY_BEATS[bucket])) {
|
||||
// TODO: log/trace that we're deferring the job due to bucketing if we
|
||||
// hit this
|
||||
if (job.getWhenStandbyDeferred() == 0) {
|
||||
if (DEBUG_STANDBY) {
|
||||
Slog.v(TAG, "Bucket deferral: " + mHeartbeat + " < "
|
||||
|
||||
@@ -617,7 +617,7 @@ public final class QuotaController extends StateController {
|
||||
jobStatus.setTrackingController(JobStatus.TRACKING_QUOTA);
|
||||
if (mShouldThrottle) {
|
||||
final boolean isWithinQuota = isWithinQuotaLocked(jobStatus);
|
||||
jobStatus.setQuotaConstraintSatisfied(isWithinQuota);
|
||||
setConstraintSatisfied(jobStatus, isWithinQuota);
|
||||
if (!isWithinQuota) {
|
||||
maybeScheduleStartAlarmLocked(userId, pkgName,
|
||||
getEffectiveStandbyBucket(jobStatus));
|
||||
@@ -1282,10 +1282,10 @@ public final class QuotaController extends StateController {
|
||||
// An app in the ACTIVE bucket may be out of quota while the job could be in quota
|
||||
// for some reason. Therefore, avoid setting the real value here and check each job
|
||||
// individually.
|
||||
changed |= js.setQuotaConstraintSatisfied(realInQuota);
|
||||
changed |= setConstraintSatisfied(js, realInQuota);
|
||||
} else {
|
||||
// This job is somehow exempted. Need to determine its own quota status.
|
||||
changed |= js.setQuotaConstraintSatisfied(isWithinQuotaLocked(js));
|
||||
changed |= setConstraintSatisfied(js, isWithinQuotaLocked(js));
|
||||
}
|
||||
}
|
||||
if (!realInQuota) {
|
||||
@@ -1310,7 +1310,7 @@ public final class QuotaController extends StateController {
|
||||
|
||||
@Override
|
||||
public void accept(JobStatus jobStatus) {
|
||||
wasJobChanged |= jobStatus.setQuotaConstraintSatisfied(isWithinQuotaLocked(jobStatus));
|
||||
wasJobChanged |= setConstraintSatisfied(jobStatus, isWithinQuotaLocked(jobStatus));
|
||||
final int userId = jobStatus.getSourceUserId();
|
||||
final String packageName = jobStatus.getSourcePackageName();
|
||||
final int realStandbyBucket = jobStatus.getStandbyBucket();
|
||||
@@ -1434,6 +1434,14 @@ public final class QuotaController extends StateController {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setConstraintSatisfied(@NonNull JobStatus jobStatus, boolean isWithinQuota) {
|
||||
if (!isWithinQuota && jobStatus.getWhenStandbyDeferred() == 0) {
|
||||
// Mark that the job is being deferred due to buckets.
|
||||
jobStatus.setWhenStandbyDeferred(sElapsedRealtimeClock.millis());
|
||||
}
|
||||
return jobStatus.setQuotaConstraintSatisfied(isWithinQuota);
|
||||
}
|
||||
|
||||
private final class ChargingTracker extends BroadcastReceiver {
|
||||
/**
|
||||
* Track whether we're charging. This has a slightly different definition than that of
|
||||
|
||||
@@ -2450,6 +2450,8 @@ public class QuotaControllerTest {
|
||||
timeout(remainingTimeMs + 2 * SECOND_IN_MILLIS).times(1))
|
||||
.onControllerStateChanged();
|
||||
assertFalse(jobStatus.isConstraintSatisfied(JobStatus.CONSTRAINT_WITHIN_QUOTA));
|
||||
assertEquals(JobSchedulerService.sElapsedRealtimeClock.millis(),
|
||||
jobStatus.getWhenStandbyDeferred());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2606,6 +2608,8 @@ public class QuotaControllerTest {
|
||||
"testStartAlarmScheduled_TimingSessionCount_AllowedTime", 42);
|
||||
mQuotaController.maybeStartTrackingJobLocked(throttledJob, null);
|
||||
assertFalse(throttledJob.isConstraintSatisfied(JobStatus.CONSTRAINT_WITHIN_QUOTA));
|
||||
assertEquals(JobSchedulerService.sElapsedRealtimeClock.millis(),
|
||||
throttledJob.getWhenStandbyDeferred());
|
||||
|
||||
ExecutionStats stats = mQuotaController.getExecutionStatsLocked(SOURCE_USER_ID,
|
||||
SOURCE_PACKAGE, standbyBucket);
|
||||
|
||||
Reference in New Issue
Block a user