Treat named standby states as ceilings of behavioral categories
For purposes of alarm dispatch & job execution, intermediate standby
states are now treated as the ceilings of the range associated with each
bucket, rather than as the floor. So, for example, a value that is
between STANDBY_BUCKET_WORKING_SET and STANDBY_BUCKET_ACTIVE is now
treated as equivalent to STANDBY_BUCKET_WORKING_SET.
Bug: 77154340
Test: atest CtsJobSchedulerTestCases
Change-Id: I84d010863eecaac011dd117205980254487bfa64
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 736aa46..0135085 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -248,6 +248,7 @@
static final int WORKING_INDEX = 1;
static final int FREQUENT_INDEX = 2;
static final int RARE_INDEX = 3;
+ static final int NEVER_INDEX = 4;
/**
* Bookkeeping about when jobs last run. We keep our own record in heartbeat time,
@@ -2432,11 +2433,11 @@
public static int standbyBucketToBucketIndex(int bucket) {
// Normalize AppStandby constants to indices into our bookkeeping
- if (bucket == UsageStatsManager.STANDBY_BUCKET_NEVER) return 4;
- else if (bucket >= UsageStatsManager.STANDBY_BUCKET_RARE) return 3;
- else if (bucket >= UsageStatsManager.STANDBY_BUCKET_FREQUENT) return 2;
- else if (bucket >= UsageStatsManager.STANDBY_BUCKET_WORKING_SET) return 1;
- else return 0;
+ if (bucket == UsageStatsManager.STANDBY_BUCKET_NEVER) return NEVER_INDEX;
+ else if (bucket > UsageStatsManager.STANDBY_BUCKET_FREQUENT) return RARE_INDEX;
+ else if (bucket > UsageStatsManager.STANDBY_BUCKET_WORKING_SET) return FREQUENT_INDEX;
+ else if (bucket > UsageStatsManager.STANDBY_BUCKET_ACTIVE) return WORKING_INDEX;
+ else return ACTIVE_INDEX;
}
// Static to support external callers