Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +6 −14 Original line number Diff line number Diff line Loading @@ -2085,8 +2085,12 @@ public class JobSchedulerService extends com.android.server.SystemService if (DEBUG) { Slog.v(TAG, debugPrefix + " ready=" + jobReady); } if (!jobReady) { return job.getPendingJobReasons(); final JobRestriction restriction = checkIfRestricted(job); if (DEBUG) { Slog.v(TAG, debugPrefix + " restriction=" + restriction); } if (!jobReady || restriction != null) { return job.getPendingJobReasons(restriction); } final boolean userStarted = areUsersStartedLocked(job); Loading @@ -2106,18 +2110,6 @@ public class JobSchedulerService extends com.android.server.SystemService return new int[] { JobScheduler.PENDING_JOB_REASON_APP }; } final JobRestriction restriction = checkIfRestricted(job); if (DEBUG) { Slog.v(TAG, debugPrefix + " restriction=" + restriction); } if (restriction != null) { // Currently this will return _DEVICE_STATE because of thermal reasons. // TODO (b/372031023): does it make sense to move this along with the // pendingJobReasons() call above and also get the pending reasons from // all of the restriction controllers? return new int[] { restriction.getPendingReason() }; } // The following can be a little more expensive, so we are doing it later, // but still before checking with the package manager! final boolean jobPending = mPendingJobQueue.contains(job); Loading apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java +11 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import com.android.server.job.JobSchedulerService; import com.android.server.job.JobServerProtoEnums; import com.android.server.job.JobStatusDumpProto; import com.android.server.job.JobStatusShortInfoProto; import com.android.server.job.restrictions.JobRestriction; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -2179,11 +2180,20 @@ public final class JobStatus { * This will return all potential reasons why the job is pending. */ @NonNull public int[] getPendingJobReasons() { public int[] getPendingJobReasons(@Nullable JobRestriction restriction) { final int unsatisfiedConstraints = ~satisfiedConstraints & (requiredConstraints | mDynamicConstraints | IMPLICIT_CONSTRAINTS); final ArrayList<Integer> reasons = constraintsToPendingJobReasons(unsatisfiedConstraints); if (restriction != null) { // Currently only ThermalStatusRestriction extends the JobRestriction class and // returns PENDING_JOB_REASON_DEVICE_STATE if the job is restricted because of thermal. @JobScheduler.PendingJobReason final int reason = restriction.getPendingReason(); if (!reasons.contains(reason)) { reasons.addLast(reason); } } if (reasons.isEmpty()) { if (getEffectiveStandbyBucket() == NEVER_INDEX) { Slog.wtf(TAG, "App in NEVER bucket querying pending job reason"); Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +6 −14 Original line number Diff line number Diff line Loading @@ -2085,8 +2085,12 @@ public class JobSchedulerService extends com.android.server.SystemService if (DEBUG) { Slog.v(TAG, debugPrefix + " ready=" + jobReady); } if (!jobReady) { return job.getPendingJobReasons(); final JobRestriction restriction = checkIfRestricted(job); if (DEBUG) { Slog.v(TAG, debugPrefix + " restriction=" + restriction); } if (!jobReady || restriction != null) { return job.getPendingJobReasons(restriction); } final boolean userStarted = areUsersStartedLocked(job); Loading @@ -2106,18 +2110,6 @@ public class JobSchedulerService extends com.android.server.SystemService return new int[] { JobScheduler.PENDING_JOB_REASON_APP }; } final JobRestriction restriction = checkIfRestricted(job); if (DEBUG) { Slog.v(TAG, debugPrefix + " restriction=" + restriction); } if (restriction != null) { // Currently this will return _DEVICE_STATE because of thermal reasons. // TODO (b/372031023): does it make sense to move this along with the // pendingJobReasons() call above and also get the pending reasons from // all of the restriction controllers? return new int[] { restriction.getPendingReason() }; } // The following can be a little more expensive, so we are doing it later, // but still before checking with the package manager! final boolean jobPending = mPendingJobQueue.contains(job); Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/JobStatus.java +11 −1 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import com.android.server.job.JobSchedulerService; import com.android.server.job.JobServerProtoEnums; import com.android.server.job.JobStatusDumpProto; import com.android.server.job.JobStatusShortInfoProto; import com.android.server.job.restrictions.JobRestriction; import dalvik.annotation.optimization.NeverCompile; Loading Loading @@ -2179,11 +2180,20 @@ public final class JobStatus { * This will return all potential reasons why the job is pending. */ @NonNull public int[] getPendingJobReasons() { public int[] getPendingJobReasons(@Nullable JobRestriction restriction) { final int unsatisfiedConstraints = ~satisfiedConstraints & (requiredConstraints | mDynamicConstraints | IMPLICIT_CONSTRAINTS); final ArrayList<Integer> reasons = constraintsToPendingJobReasons(unsatisfiedConstraints); if (restriction != null) { // Currently only ThermalStatusRestriction extends the JobRestriction class and // returns PENDING_JOB_REASON_DEVICE_STATE if the job is restricted because of thermal. @JobScheduler.PendingJobReason final int reason = restriction.getPendingReason(); if (!reasons.contains(reason)) { reasons.addLast(reason); } } if (reasons.isEmpty()) { if (getEffectiveStandbyBucket() == NEVER_INDEX) { Slog.wtf(TAG, "App in NEVER bucket querying pending job reason"); Loading