TimeController skips alarms for jobs that wouldn't be ready.
If a job runs out of quota, the deadline alarm will not make it ready to
run. Similarly, there are two other implicit constraints (device not
dozing and not-restricted-in-background) that will stop a job from
running even if the deadline constraint has been satisfied. As such, it
doesn't make much sense to set an alarm to wake up the device when those
constraints aren't satisfied. When those constraints are updated,
TimeController is told to recheck its jobs, so this should have no
negative impact on jobs, but should reduce the number of wakeups the
device has from JobScheduler.
Bug: 117846754
Bug: 111423978
Test: atest com.android.server.job.controllers.TimeControllerTest
Change-Id: Ia0c09400079154287dff9ff2ac622d8870ef4110
diff --git a/services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java b/services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java
index effb5a7..5df37ac 100644
--- a/services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/job/controllers/QuotaControllerTest.java
@@ -579,8 +579,8 @@
// Start in ACTIVE bucket.
mQuotaController.maybeScheduleStartAlarmLocked(0, "com.android.test", ACTIVE_INDEX);
- inOrder.verify(mAlarmManager, never()).set(anyInt(), anyLong(), eq(TAG_QUOTA_CHECK), any(),
- any());
+ inOrder.verify(mAlarmManager, never())
+ .set(anyInt(), anyLong(), eq(TAG_QUOTA_CHECK), any(), any());
inOrder.verify(mAlarmManager, never()).cancel(any(AlarmManager.OnAlarmListener.class));
// And down from there.