Loading services/core/java/com/android/server/job/JobSchedulerService.java +0 −2 Original line number Diff line number Diff line Loading @@ -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 + " < " Loading services/core/java/com/android/server/job/controllers/QuotaController.java +12 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading Loading @@ -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) { Loading @@ -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(); Loading Loading @@ -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 Loading services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()); } /** Loading Loading @@ -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); Loading Loading
services/core/java/com/android/server/job/JobSchedulerService.java +0 −2 Original line number Diff line number Diff line Loading @@ -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 + " < " Loading
services/core/java/com/android/server/job/controllers/QuotaController.java +12 −4 Original line number Diff line number Diff line Loading @@ -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)); Loading Loading @@ -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) { Loading @@ -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(); Loading Loading @@ -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 Loading
services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java +4 −0 Original line number Diff line number Diff line Loading @@ -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()); } /** Loading Loading @@ -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); Loading