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

Commit 19f512ef authored by Kweku Adams's avatar Kweku Adams
Browse files

Increase max job limit to 150.

Bug: 171305774
Test: atest CtsJobSchedulerTestCases
Change-Id: Ie7221091ce03675d358d6d368e93b7df231b11cd
parent a8456872
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -59,6 +59,9 @@ import java.util.Objects;
 * constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an
 * constraint on the JobInfo object that you are creating. Otherwise, the builder would throw an
 * exception when building. From Android version {@link Build.VERSION_CODES#Q} and onwards, it is
 * exception when building. From Android version {@link Build.VERSION_CODES#Q} and onwards, it is
 * valid to schedule jobs with no constraints.
 * valid to schedule jobs with no constraints.
 * <p> Prior to Android version {@link Build.VERSION_CODES#S}, jobs could only have a maximum of 100
 * jobs scheduled at a time. Starting with Android version {@link Build.VERSION_CODES#S}, that limit
 * has been increased to 150. Expedited jobs also count towards the limit.
 * <p> In Android version {@link Build.VERSION_CODES#LOLLIPOP}, jobs had a maximum execution time
 * <p> In Android version {@link Build.VERSION_CODES#LOLLIPOP}, jobs had a maximum execution time
 * of one minute. Starting with Android version {@link Build.VERSION_CODES#M} and ending with
 * of one minute. Starting with Android version {@link Build.VERSION_CODES#M} and ending with
 * Android version {@link Build.VERSION_CODES#R}, jobs had a maximum execution time of 10 minutes.
 * Android version {@link Build.VERSION_CODES#R}, jobs had a maximum execution time of 10 minutes.
+3 −5
Original line number Original line Diff line number Diff line
@@ -147,10 +147,8 @@ public class JobSchedulerService extends com.android.server.SystemService


    /** The maximum number of concurrent jobs we run at one time. */
    /** The maximum number of concurrent jobs we run at one time. */
    static final int MAX_JOB_CONTEXTS_COUNT = 16;
    static final int MAX_JOB_CONTEXTS_COUNT = 16;
    /** Enforce a per-app limit on scheduled jobs? */
    /** The maximum number of jobs that we allow an app to schedule */
    private static final boolean ENFORCE_MAX_JOBS = true;
    private static final int MAX_JOBS_PER_APP = 150;
    /** The maximum number of jobs that we allow an unprivileged app to schedule */
    private static final int MAX_JOBS_PER_APP = 100;
    /** The number of the most recently completed jobs to keep track of for debugging purposes. */
    /** The number of the most recently completed jobs to keep track of for debugging purposes. */
    private static final int NUM_COMPLETED_JOB_HISTORY = 20;
    private static final int NUM_COMPLETED_JOB_HISTORY = 20;


@@ -1011,7 +1009,7 @@ public class JobSchedulerService extends com.android.server.SystemService


            if (DEBUG) Slog.d(TAG, "SCHEDULE: " + jobStatus.toShortString());
            if (DEBUG) Slog.d(TAG, "SCHEDULE: " + jobStatus.toShortString());
            // Jobs on behalf of others don't apply to the per-app job cap
            // Jobs on behalf of others don't apply to the per-app job cap
            if (ENFORCE_MAX_JOBS && packageName == null) {
            if (packageName == null) {
                if (mJobs.countJobsForUid(uId) > MAX_JOBS_PER_APP) {
                if (mJobs.countJobsForUid(uId) > MAX_JOBS_PER_APP) {
                    Slog.w(TAG, "Too many jobs for uid " + uId);
                    Slog.w(TAG, "Too many jobs for uid " + uId);
                    throw new IllegalStateException("Apps may not schedule more than "
                    throw new IllegalStateException("Apps may not schedule more than "