Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5008e1be authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Documentation updates and data dumps."

parents 69df0530 32f4476f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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
}
+0 −5
Original line number Diff line number Diff line
@@ -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;
+30 −11
Original line number Diff line number Diff line
@@ -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));