[IdleController] Support dock scenario on idle or active judgement
In the current design, IdleController of Job service considers devices as ‘idle’ after 71 minutes of screen off. But under docking use scenario, devices screen might remain on for a very long time and it’s not necessary implying the device being interactive with users.
So create a mechanism for device to enter the ‘idle’ state that JobScheduler can kick off idle tasks.
Bug: 79183658
Test: atest DeviceStatesTest
Change-Id: I5b307ca51e28ffca63f79a9c43984c3b76e51629
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index b441baf..0b7c5b9 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -2961,6 +2961,18 @@
return 0;
}
+ void triggerDockState(boolean idleState) {
+ final Intent dockIntent;
+ if (idleState) {
+ dockIntent = new Intent(Intent.ACTION_DOCK_IDLE);
+ } else {
+ dockIntent = new Intent(Intent.ACTION_DOCK_ACTIVE);
+ }
+ dockIntent.setPackage("android");
+ dockIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
+ getContext().sendBroadcastAsUser(dockIntent, UserHandle.ALL);
+ }
+
private String printContextIdToJobMap(JobStatus[] map, String initial) {
StringBuilder s = new StringBuilder(initial + ": ");
for (int i=0; i<map.length; i++) {