Expose App Standby APIs for apps and system
Allow apps to query their own standby bucket.
Allow privileged apps with PACKAGE_USAGE_STATS permission to
query apps.
Allow privileged apps with CHANGE_APP_IDLE_STATE to set the
standby state for apps, but not for themselves.
Removed AppStandby class and moved constants into UsageStatsManager.
Bug: 63527785
Test: cts-tradefed run cts-dev -m CtsAppUsageHostTestCases
Change-Id: I3c1c20f6ecb6d54e248233696039286b243d663c
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 4af86a0..3f014b5 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -29,7 +29,7 @@
import android.app.job.JobScheduler;
import android.app.job.JobService;
import android.app.job.JobWorkItem;
-import android.app.usage.AppStandby;
+import android.app.usage.UsageStatsManager;
import android.app.usage.UsageStatsManagerInternal;
import android.app.usage.UsageStatsManagerInternal.AppIdleStateChangeListener;
import android.content.BroadcastReceiver;
@@ -2074,10 +2074,10 @@
public static int standbyBucketToBucketIndex(int bucket) {
// Normalize AppStandby constants to indices into our bookkeeping
- if (bucket == AppStandby.STANDBY_BUCKET_NEVER) return 4;
- else if (bucket >= AppStandby.STANDBY_BUCKET_RARE) return 3;
- else if (bucket >= AppStandby.STANDBY_BUCKET_FREQUENT) return 2;
- else if (bucket >= AppStandby.STANDBY_BUCKET_WORKING_SET) return 1;
+ 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;
}