diff options
| author | 2018-11-12 23:23:21 +0000 | |
|---|---|---|
| committer | 2018-11-12 23:23:21 +0000 | |
| commit | 5008e1beec3ea3c7d47fbd3d3b6e3af26a68555e (patch) | |
| tree | 08bf1d58856c9c3690f89456981481a27e887e40 | |
| parent | 69df0530686ae7c1e7a3278d9e62f5d245a8dba6 (diff) | |
| parent | 32f4476fc62daee62475b838b3f6521943512cf2 (diff) | |
Merge "Documentation updates and data dumps."
3 files changed, 43 insertions, 16 deletions
diff --git a/core/proto/android/server/jobscheduler.proto b/core/proto/android/server/jobscheduler.proto index 54f0934457e3..e83a2bfac77a 100644 --- a/core/proto/android/server/jobscheduler.proto +++ b/core/proto/android/server/jobscheduler.proto @@ -609,6 +609,17 @@ message JobStatusDumpProto { repeated Constraint unsatisfied_constraints = 9; optional bool is_doze_whitelisted = 10; + message ImplicitConstraints { + // The device isn't Dozing or this job will be in the foreground. This + // implicit constraint must be satisfied for the job to run. + optional bool is_not_dozing = 1; + // The job is not restricted from running in the background (due to + // Battery Saver). This implicit constraint must be satisfied for the + // job to run. + optional bool is_not_restricted_in_bg = 2; + } + optional ImplicitConstraints implicit_constraints = 25; + enum TrackingController { TRACKING_BATTERY = 0; TRACKING_CONNECTIVITY = 1; @@ -662,4 +673,6 @@ message JobStatusDumpProto { optional int64 last_failed_run_time = 23; optional int64 internal_flags = 24; + + // Next tag: 26 } diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java index dd993b842aca..b3f0629ea2d3 100644 --- a/services/core/java/com/android/server/job/JobSchedulerService.java +++ b/services/core/java/com/android/server/job/JobSchedulerService.java @@ -1740,11 +1740,6 @@ public class JobSchedulerService extends com.android.server.SystemService /** * The state of at least one job has changed. Here is where we could enforce various * policies on when we want to execute jobs. - * Right now the policy is such: - * If >1 of the ready jobs is idle mode we send all of them off - * if more than 2 network connectivity jobs are ready we send them all off. - * If more than 4 jobs total are ready we send them all off. - * TODO: It would be nice to consolidate these sort of high-level policies somewhere. */ final class MaybeReadyJobQueueFunctor implements Consumer<JobStatus> { int chargingCount; diff --git a/services/core/java/com/android/server/job/controllers/JobStatus.java b/services/core/java/com/android/server/job/controllers/JobStatus.java index 4ece538d6d31..35fc29ee69fc 100644 --- a/services/core/java/com/android/server/job/controllers/JobStatus.java +++ b/services/core/java/com/android/server/job/controllers/JobStatus.java @@ -68,10 +68,10 @@ public final class JobStatus { public static final long NO_LATEST_RUNTIME = Long.MAX_VALUE; public static final long NO_EARLIEST_RUNTIME = 0L; - static final int CONSTRAINT_CHARGING = JobInfo.CONSTRAINT_FLAG_CHARGING; - static final int CONSTRAINT_IDLE = JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE; - static final int CONSTRAINT_BATTERY_NOT_LOW = JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW; - static final int CONSTRAINT_STORAGE_NOT_LOW = JobInfo.CONSTRAINT_FLAG_STORAGE_NOT_LOW; + static final int CONSTRAINT_CHARGING = JobInfo.CONSTRAINT_FLAG_CHARGING; // 1 < 0 + static final int CONSTRAINT_IDLE = JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE; // 1 << 2 + static final int CONSTRAINT_BATTERY_NOT_LOW = JobInfo.CONSTRAINT_FLAG_BATTERY_NOT_LOW; // 1 << 1 + static final int CONSTRAINT_STORAGE_NOT_LOW = JobInfo.CONSTRAINT_FLAG_STORAGE_NOT_LOW; // 1 << 3 static final int CONSTRAINT_TIMING_DELAY = 1<<31; static final int CONSTRAINT_DEADLINE = 1<<30; static final int CONSTRAINT_CONNECTIVITY = 1<<28; @@ -975,8 +975,7 @@ public final class JobStatus { } /** - * @return Whether or not this job is ready to run, based on its requirements. This is true if - * the constraints are satisfied <strong>or</strong> the deadline on the job has expired. + * @return Whether or not this job is ready to run, based on its requirements. */ public boolean isReady() { // Deadline constraint trumps other constraints (except for periodic jobs where deadline @@ -1234,16 +1233,18 @@ public final class JobStatus { proto.end(token); } - // normalized bucket indices, not the AppStandby constants - private String bucketName(int bucket) { - switch (bucket) { + /** + * Returns a bucket name based on the normalized bucket indices, not the AppStandby constants. + */ + String getBucketName() { + switch (standbyBucket) { case 0: return "ACTIVE"; case 1: return "WORKING_SET"; case 2: return "FREQUENT"; case 3: return "RARE"; case 4: return "NEVER"; default: - return "Unknown: " + bucket; + return "Unknown: " + standbyBucket; } } @@ -1385,6 +1386,17 @@ public final class JobStatus { if ((trackingControllers&TRACKING_TIME) != 0) pw.print(" TIME"); pw.println(); } + + pw.print(prefix); pw.println("Implicit constraints:"); + pw.print(prefix); pw.print(" readyNotDozing: "); + pw.println(mReadyNotDozing); + pw.print(prefix); pw.print(" readyNotRestrictedInBg: "); + pw.println(mReadyNotRestrictedInBg); + if (!job.isPeriodic() && hasDeadlineConstraint()) { + pw.print(prefix); pw.print(" readyDeadlineSatisfied: "); + pw.println(mReadyDeadlineSatisfied); + } + if (changedAuthorities != null) { pw.print(prefix); pw.println("Changed authorities:"); for (int i=0; i<changedAuthorities.size(); i++) { @@ -1413,7 +1425,7 @@ public final class JobStatus { } } pw.print(prefix); pw.print("Standby bucket: "); - pw.println(bucketName(standbyBucket)); + pw.println(getBucketName()); if (standbyBucket > 0) { pw.print(prefix); pw.print("Base heartbeat: "); pw.println(baseHeartbeat); @@ -1564,6 +1576,13 @@ public final class JobStatus { JobStatusDumpProto.TRACKING_TIME); } + // Implicit constraints + final long icToken = proto.start(JobStatusDumpProto.IMPLICIT_CONSTRAINTS); + proto.write(JobStatusDumpProto.ImplicitConstraints.IS_NOT_DOZING, mReadyNotDozing); + proto.write(JobStatusDumpProto.ImplicitConstraints.IS_NOT_RESTRICTED_IN_BG, + mReadyNotRestrictedInBg); + proto.end(icToken); + if (changedAuthorities != null) { for (int k = 0; k < changedAuthorities.size(); k++) { proto.write(JobStatusDumpProto.CHANGED_AUTHORITIES, changedAuthorities.valueAt(k)); |