Loading apex/jobscheduler/framework/java/android/app/job/JobInfo.java +46 −23 Original line number Diff line number Diff line Loading @@ -281,11 +281,11 @@ public class JobInfo implements Parcelable { public static final int FLAG_EXEMPT_FROM_APP_STANDBY = 1 << 3; /** * Whether it's a so-called "HPJ" or not. * Whether it's an expedited job or not. * * @hide */ public static final int FLAG_FOREGROUND_JOB = 1 << 4; public static final int FLAG_EXPEDITED = 1 << 4; /** * @hide Loading Loading @@ -586,10 +586,19 @@ public class JobInfo implements Parcelable { } /** * @see JobInfo.Builder#setForeground(boolean) * @see JobInfo.Builder#setExpedited(boolean) */ public boolean isExpedited() { return (flags & FLAG_EXPEDITED) != 0; } /** * @see JobInfo.Builder#setExpedited(boolean) * @deprecated Use {@link #isExpedited()} instead */ @Deprecated public boolean isForegroundJob() { return (flags & FLAG_FOREGROUND_JOB) != 0; return (flags & FLAG_EXPEDITED) != 0; } /** Loading Loading @@ -1458,7 +1467,7 @@ public class JobInfo implements Parcelable { /** * Setting this to true indicates that this job is important and needs to run as soon as * possible with stronger guarantees than regular jobs. These "foreground" jobs will: * possible with stronger guarantees than regular jobs. These "expedited" jobs will: * <ol> * <li>Run as soon as possible</li> * <li>Be exempted from Doze and battery saver restrictions</li> Loading @@ -1466,27 +1475,41 @@ public class JobInfo implements Parcelable { * </ol> * * Since these jobs have stronger guarantees than regular jobs, they will be subject to * stricter quotas. As long as an app has available foreground quota, jobs scheduled with * stricter quotas. As long as an app has available expedited quota, jobs scheduled with * this set to true will run with these guarantees. If an app has run out of available * foreground quota, any pending foreground jobs will run as regular jobs. * {@link JobParameters#isForegroundJob()} can be used to know whether the executing job * has foreground guarantees or not. In addition, {@link JobScheduler#schedule(JobInfo)} * expedited quota, any pending expedited jobs will run as regular jobs. * {@link JobParameters#isExpeditedJob()} can be used to know whether the executing job * has expedited guarantees or not. In addition, {@link JobScheduler#schedule(JobInfo)} * will immediately return {@link JobScheduler#RESULT_FAILURE} if the app does not have * available quota (and the job will not be successfully scheduled). * * Foreground jobs may only set network constraints. No other constraints are allowed. * Expedited jobs may only set network constraints. No other constraints are allowed. * * Note: Even though foreground jobs are meant to run as soon as possible, they may be * Note: Even though expedited jobs are meant to run as soon as possible, they may be * deferred if the system is under heavy load or the network constraint is satisfied * * @see JobInfo#isForegroundJob() * @see JobInfo#isExpedited() */ @NonNull public Builder setExpedited(boolean expedited) { if (expedited) { mFlags |= FLAG_EXPEDITED; } else { mFlags &= (~FLAG_EXPEDITED); } return this; } /** * @deprecated Use {@link #setExpedited(boolean)} instead. */ @Deprecated @NonNull public Builder setForeground(boolean foreground) { if (foreground) { mFlags |= FLAG_FOREGROUND_JOB; mFlags |= FLAG_EXPEDITED; } else { mFlags &= (~FLAG_FOREGROUND_JOB); mFlags &= (~FLAG_EXPEDITED); } return this; } Loading @@ -1506,7 +1529,7 @@ public class JobInfo implements Parcelable { * @param importantWhileForeground whether to relax doze restrictions for this job when the * app is in the foreground. False by default. * @see JobInfo#isImportantWhileForeground() * @deprecated Use {@link #setForeground(boolean)} instead. * @deprecated Use {@link #setExpedited(boolean)} instead. */ @Deprecated public Builder setImportantWhileForeground(boolean importantWhileForeground) { Loading Loading @@ -1633,26 +1656,26 @@ public class JobInfo implements Parcelable { "An important while foreground job cannot have a time delay"); } if ((flags & FLAG_FOREGROUND_JOB) != 0) { if ((flags & FLAG_EXPEDITED) != 0) { if (hasEarlyConstraint) { throw new IllegalArgumentException("A foreground job cannot have a time delay"); throw new IllegalArgumentException("An expedited job cannot have a time delay"); } if (hasLateConstraint) { throw new IllegalArgumentException("A foreground job cannot have a deadline"); throw new IllegalArgumentException("An expedited job cannot have a deadline"); } if (isPeriodic) { throw new IllegalArgumentException("A foreground job cannot be periodic"); throw new IllegalArgumentException("An expedited job cannot be periodic"); } if (isPersisted) { throw new IllegalArgumentException("A foreground job cannot be persisted"); throw new IllegalArgumentException("An expedited job cannot be persisted"); } if (constraintFlags != 0 || (flags & ~FLAG_FOREGROUND_JOB) != 0) { if (constraintFlags != 0 || (flags & ~FLAG_EXPEDITED) != 0) { throw new IllegalArgumentException( "A foreground job can only have network constraints"); "An expedited job can only have network constraints"); } if (triggerContentUris != null && triggerContentUris.length > 0) { throw new IllegalArgumentException( "Can't call addTriggerContentUri() on a foreground job"); "Can't call addTriggerContentUri() on an expedited job"); } } } Loading apex/jobscheduler/framework/java/android/app/job/JobParameters.java +18 −12 Original line number Diff line number Diff line Loading @@ -111,9 +111,7 @@ public class JobParameters implements Parcelable { @UnsupportedAppUsage private final IBinder callback; private final boolean overrideDeadlineExpired; // HPJs = foreground jobs. // TODO(171305774): clean up naming private final boolean mIsHpj; private final boolean mIsExpedited; private final Uri[] mTriggeredContentUris; private final String[] mTriggeredContentAuthorities; private final Network network; Loading @@ -124,7 +122,7 @@ public class JobParameters implements Parcelable { /** @hide */ public JobParameters(IBinder callback, int jobId, PersistableBundle extras, Bundle transientExtras, ClipData clipData, int clipGrantFlags, boolean overrideDeadlineExpired, boolean isHpj, Uri[] triggeredContentUris, boolean overrideDeadlineExpired, boolean isExpedited, Uri[] triggeredContentUris, String[] triggeredContentAuthorities, Network network) { this.jobId = jobId; this.extras = extras; Loading @@ -133,7 +131,7 @@ public class JobParameters implements Parcelable { this.clipGrantFlags = clipGrantFlags; this.callback = callback; this.overrideDeadlineExpired = overrideDeadlineExpired; this.mIsHpj = isHpj; this.mIsExpedited = isExpedited; this.mTriggeredContentUris = triggeredContentUris; this.mTriggeredContentAuthorities = triggeredContentAuthorities; this.network = network; Loading Loading @@ -199,14 +197,22 @@ public class JobParameters implements Parcelable { } /** * @return Whether this job is running as a foreground job or not. A job is guaranteed to have * all foreground job guarantees for the duration of the job execution if this returns * @return Whether this job is running as an expedited job or not. A job is guaranteed to have * all expedited job guarantees for the duration of the job execution if this returns * {@code true}. This will return {@code false} if the job that wasn't requested to run as a * foreground job, or if it was requested to run as a foreground job but the app didn't have * any remaining foreground job quota at the time of execution. * expedited job, or if it was requested to run as an expedited job but the app didn't have * any remaining expedited job quota at the time of execution. */ public boolean isExpeditedJob() { return mIsExpedited; } /** * @deprecated Use {@link #isExpeditedJob()} instead. */ @Deprecated public boolean isForegroundJob() { return mIsHpj; return mIsExpedited; } /** Loading Loading @@ -352,7 +358,7 @@ public class JobParameters implements Parcelable { } callback = in.readStrongBinder(); overrideDeadlineExpired = in.readInt() == 1; mIsHpj = in.readBoolean(); mIsExpedited = in.readBoolean(); mTriggeredContentUris = in.createTypedArray(Uri.CREATOR); mTriggeredContentAuthorities = in.createStringArray(); if (in.readInt() != 0) { Loading Loading @@ -389,7 +395,7 @@ public class JobParameters implements Parcelable { } dest.writeStrongBinder(callback); dest.writeInt(overrideDeadlineExpired ? 1 : 0); dest.writeBoolean(mIsHpj); dest.writeBoolean(mIsExpedited); dest.writeTypedArray(mTriggeredContentUris, flags); dest.writeStringArray(mTriggeredContentAuthorities); if (network != null) { Loading apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class JobConcurrencyManager { private boolean isFgJob(JobStatus job) { // (It's super confusing PRIORITY_BOUND_FOREGROUND_SERVICE isn't FG here) return job.lastEvaluatedPriority >= JobInfo.PRIORITY_TOP_APP || job.shouldTreatAsForegroundJob(); || job.shouldTreatAsExpeditedJob(); } @GuardedBy("mLock") Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +10 −9 Original line number Diff line number Diff line Loading @@ -835,9 +835,10 @@ public class JobSchedulerService extends com.android.server.SystemService return o2.overrideState - o1.overrideState; } if (o1.getSourceUid() == o2.getSourceUid()) { final boolean o1FGJ = o1.isRequestedForegroundJob(); if (o1FGJ != o2.isRequestedForegroundJob()) { // Attempt to run requested HPJs ahead of regular jobs, regardless of HPJ quota. final boolean o1FGJ = o1.isRequestedExpeditedJob(); if (o1FGJ != o2.isRequestedExpeditedJob()) { // Attempt to run requested expedited jobs ahead of regular jobs, regardless of // expedited job quota. return o1FGJ ? -1 : 1; } } Loading Loading @@ -1143,9 +1144,9 @@ public class JobSchedulerService extends com.android.server.SystemService JobStatus jobStatus = JobStatus.createFromJobInfo(job, uId, packageName, userId, tag); // Return failure early if HPJ quota used up. if (jobStatus.isRequestedForegroundJob() && !mQuotaController.isWithinHpjQuotaLocked(jobStatus)) { // Return failure early if expedited job quota used up. if (jobStatus.isRequestedExpeditedJob() && !mQuotaController.isWithinEJQuotaLocked(jobStatus)) { return JobScheduler.RESULT_FAILURE; } Loading Loading @@ -1897,9 +1898,9 @@ public class JobSchedulerService extends com.android.server.SystemService Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); } // Intentionally not checking HPJ quota here. An app can't find out if it's run out of quota // when it asks JS to reschedule an HPJ. Instead, the rescheduled HPJ will just be demoted // to a regular job if the app has no HPJ quota left. // Intentionally not checking expedited job quota here. An app can't find out if it's run // out of quota when it asks JS to reschedule an expedited job. Instead, the rescheduled // EJ will just be demoted to a regular job if the app has no EJ quota left. // If the job wants to be rescheduled, we first need to make the next upcoming // job so we can transfer any appropriate state over from the previous job when Loading apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −6 Original line number Diff line number Diff line Loading @@ -76,10 +76,10 @@ public final class JobServiceContext implements ServiceConnection { /** Amount of time a job is allowed to execute for before being considered timed-out. */ public static final long DEFAULT_EXECUTING_TIMESLICE_MILLIS = 10 * 60 * 1000; // 10mins. /** * Amount of time a RESTRICTED HPJ is allowed to execute for before being considered * Amount of time a RESTRICTED expedited job is allowed to execute for before being considered * timed-out. */ public static final long DEFAULT_RESTRICTED_HPJ_EXECUTING_TIMESLICE_MILLIS = public static final long DEFAULT_RESTRICTED_EXPEDITED_JOB_EXECUTING_TIMESLICE_MILLIS = DEFAULT_EXECUTING_TIMESLICE_MILLIS / 2; /** Amount of time the JobScheduler waits for the initial service launch+bind. */ private static final long OP_BIND_TIMEOUT_MILLIS = 18 * 1000; Loading Loading @@ -231,7 +231,7 @@ public final class JobServiceContext implements ServiceConnection { final JobInfo ji = job.getJob(); mParams = new JobParameters(mRunningCallback, job.getJobId(), ji.getExtras(), ji.getTransientExtras(), ji.getClipData(), ji.getClipGrantFlags(), isDeadlineExpired, job.shouldTreatAsForegroundJob(), isDeadlineExpired, job.shouldTreatAsExpeditedJob(), triggeredUris, triggeredAuthorities, job.network); mExecutionStartTimeElapsed = sElapsedRealtimeClock.millis(); Loading Loading @@ -259,7 +259,7 @@ public final class JobServiceContext implements ServiceConnection { boolean binding = false; try { final int bindFlags; if (job.shouldTreatAsForegroundJob()) { if (job.shouldTreatAsExpeditedJob()) { // Add BIND_FOREGROUND_SERVICE to make it BFGS. Without it, it'll be // PROCESS_STATE_IMPORTANT_FOREGROUND. Unclear which is better here. // TODO(171305774): The job should run on the little cores. We'll probably need Loading Loading @@ -865,9 +865,9 @@ public final class JobServiceContext implements ServiceConnection { final long timeoutMillis; switch (mVerb) { case VERB_EXECUTING: timeoutMillis = mRunningJob.shouldTreatAsForegroundJob() timeoutMillis = mRunningJob.shouldTreatAsExpeditedJob() && mRunningJob.getStandbyBucket() == RESTRICTED_INDEX ? DEFAULT_RESTRICTED_HPJ_EXECUTING_TIMESLICE_MILLIS ? DEFAULT_RESTRICTED_EXPEDITED_JOB_EXECUTING_TIMESLICE_MILLIS : DEFAULT_EXECUTING_TIMESLICE_MILLIS; break; Loading Loading
apex/jobscheduler/framework/java/android/app/job/JobInfo.java +46 −23 Original line number Diff line number Diff line Loading @@ -281,11 +281,11 @@ public class JobInfo implements Parcelable { public static final int FLAG_EXEMPT_FROM_APP_STANDBY = 1 << 3; /** * Whether it's a so-called "HPJ" or not. * Whether it's an expedited job or not. * * @hide */ public static final int FLAG_FOREGROUND_JOB = 1 << 4; public static final int FLAG_EXPEDITED = 1 << 4; /** * @hide Loading Loading @@ -586,10 +586,19 @@ public class JobInfo implements Parcelable { } /** * @see JobInfo.Builder#setForeground(boolean) * @see JobInfo.Builder#setExpedited(boolean) */ public boolean isExpedited() { return (flags & FLAG_EXPEDITED) != 0; } /** * @see JobInfo.Builder#setExpedited(boolean) * @deprecated Use {@link #isExpedited()} instead */ @Deprecated public boolean isForegroundJob() { return (flags & FLAG_FOREGROUND_JOB) != 0; return (flags & FLAG_EXPEDITED) != 0; } /** Loading Loading @@ -1458,7 +1467,7 @@ public class JobInfo implements Parcelable { /** * Setting this to true indicates that this job is important and needs to run as soon as * possible with stronger guarantees than regular jobs. These "foreground" jobs will: * possible with stronger guarantees than regular jobs. These "expedited" jobs will: * <ol> * <li>Run as soon as possible</li> * <li>Be exempted from Doze and battery saver restrictions</li> Loading @@ -1466,27 +1475,41 @@ public class JobInfo implements Parcelable { * </ol> * * Since these jobs have stronger guarantees than regular jobs, they will be subject to * stricter quotas. As long as an app has available foreground quota, jobs scheduled with * stricter quotas. As long as an app has available expedited quota, jobs scheduled with * this set to true will run with these guarantees. If an app has run out of available * foreground quota, any pending foreground jobs will run as regular jobs. * {@link JobParameters#isForegroundJob()} can be used to know whether the executing job * has foreground guarantees or not. In addition, {@link JobScheduler#schedule(JobInfo)} * expedited quota, any pending expedited jobs will run as regular jobs. * {@link JobParameters#isExpeditedJob()} can be used to know whether the executing job * has expedited guarantees or not. In addition, {@link JobScheduler#schedule(JobInfo)} * will immediately return {@link JobScheduler#RESULT_FAILURE} if the app does not have * available quota (and the job will not be successfully scheduled). * * Foreground jobs may only set network constraints. No other constraints are allowed. * Expedited jobs may only set network constraints. No other constraints are allowed. * * Note: Even though foreground jobs are meant to run as soon as possible, they may be * Note: Even though expedited jobs are meant to run as soon as possible, they may be * deferred if the system is under heavy load or the network constraint is satisfied * * @see JobInfo#isForegroundJob() * @see JobInfo#isExpedited() */ @NonNull public Builder setExpedited(boolean expedited) { if (expedited) { mFlags |= FLAG_EXPEDITED; } else { mFlags &= (~FLAG_EXPEDITED); } return this; } /** * @deprecated Use {@link #setExpedited(boolean)} instead. */ @Deprecated @NonNull public Builder setForeground(boolean foreground) { if (foreground) { mFlags |= FLAG_FOREGROUND_JOB; mFlags |= FLAG_EXPEDITED; } else { mFlags &= (~FLAG_FOREGROUND_JOB); mFlags &= (~FLAG_EXPEDITED); } return this; } Loading @@ -1506,7 +1529,7 @@ public class JobInfo implements Parcelable { * @param importantWhileForeground whether to relax doze restrictions for this job when the * app is in the foreground. False by default. * @see JobInfo#isImportantWhileForeground() * @deprecated Use {@link #setForeground(boolean)} instead. * @deprecated Use {@link #setExpedited(boolean)} instead. */ @Deprecated public Builder setImportantWhileForeground(boolean importantWhileForeground) { Loading Loading @@ -1633,26 +1656,26 @@ public class JobInfo implements Parcelable { "An important while foreground job cannot have a time delay"); } if ((flags & FLAG_FOREGROUND_JOB) != 0) { if ((flags & FLAG_EXPEDITED) != 0) { if (hasEarlyConstraint) { throw new IllegalArgumentException("A foreground job cannot have a time delay"); throw new IllegalArgumentException("An expedited job cannot have a time delay"); } if (hasLateConstraint) { throw new IllegalArgumentException("A foreground job cannot have a deadline"); throw new IllegalArgumentException("An expedited job cannot have a deadline"); } if (isPeriodic) { throw new IllegalArgumentException("A foreground job cannot be periodic"); throw new IllegalArgumentException("An expedited job cannot be periodic"); } if (isPersisted) { throw new IllegalArgumentException("A foreground job cannot be persisted"); throw new IllegalArgumentException("An expedited job cannot be persisted"); } if (constraintFlags != 0 || (flags & ~FLAG_FOREGROUND_JOB) != 0) { if (constraintFlags != 0 || (flags & ~FLAG_EXPEDITED) != 0) { throw new IllegalArgumentException( "A foreground job can only have network constraints"); "An expedited job can only have network constraints"); } if (triggerContentUris != null && triggerContentUris.length > 0) { throw new IllegalArgumentException( "Can't call addTriggerContentUri() on a foreground job"); "Can't call addTriggerContentUri() on an expedited job"); } } } Loading
apex/jobscheduler/framework/java/android/app/job/JobParameters.java +18 −12 Original line number Diff line number Diff line Loading @@ -111,9 +111,7 @@ public class JobParameters implements Parcelable { @UnsupportedAppUsage private final IBinder callback; private final boolean overrideDeadlineExpired; // HPJs = foreground jobs. // TODO(171305774): clean up naming private final boolean mIsHpj; private final boolean mIsExpedited; private final Uri[] mTriggeredContentUris; private final String[] mTriggeredContentAuthorities; private final Network network; Loading @@ -124,7 +122,7 @@ public class JobParameters implements Parcelable { /** @hide */ public JobParameters(IBinder callback, int jobId, PersistableBundle extras, Bundle transientExtras, ClipData clipData, int clipGrantFlags, boolean overrideDeadlineExpired, boolean isHpj, Uri[] triggeredContentUris, boolean overrideDeadlineExpired, boolean isExpedited, Uri[] triggeredContentUris, String[] triggeredContentAuthorities, Network network) { this.jobId = jobId; this.extras = extras; Loading @@ -133,7 +131,7 @@ public class JobParameters implements Parcelable { this.clipGrantFlags = clipGrantFlags; this.callback = callback; this.overrideDeadlineExpired = overrideDeadlineExpired; this.mIsHpj = isHpj; this.mIsExpedited = isExpedited; this.mTriggeredContentUris = triggeredContentUris; this.mTriggeredContentAuthorities = triggeredContentAuthorities; this.network = network; Loading Loading @@ -199,14 +197,22 @@ public class JobParameters implements Parcelable { } /** * @return Whether this job is running as a foreground job or not. A job is guaranteed to have * all foreground job guarantees for the duration of the job execution if this returns * @return Whether this job is running as an expedited job or not. A job is guaranteed to have * all expedited job guarantees for the duration of the job execution if this returns * {@code true}. This will return {@code false} if the job that wasn't requested to run as a * foreground job, or if it was requested to run as a foreground job but the app didn't have * any remaining foreground job quota at the time of execution. * expedited job, or if it was requested to run as an expedited job but the app didn't have * any remaining expedited job quota at the time of execution. */ public boolean isExpeditedJob() { return mIsExpedited; } /** * @deprecated Use {@link #isExpeditedJob()} instead. */ @Deprecated public boolean isForegroundJob() { return mIsHpj; return mIsExpedited; } /** Loading Loading @@ -352,7 +358,7 @@ public class JobParameters implements Parcelable { } callback = in.readStrongBinder(); overrideDeadlineExpired = in.readInt() == 1; mIsHpj = in.readBoolean(); mIsExpedited = in.readBoolean(); mTriggeredContentUris = in.createTypedArray(Uri.CREATOR); mTriggeredContentAuthorities = in.createStringArray(); if (in.readInt() != 0) { Loading Loading @@ -389,7 +395,7 @@ public class JobParameters implements Parcelable { } dest.writeStrongBinder(callback); dest.writeInt(overrideDeadlineExpired ? 1 : 0); dest.writeBoolean(mIsHpj); dest.writeBoolean(mIsExpedited); dest.writeTypedArray(mTriggeredContentUris, flags); dest.writeStringArray(mTriggeredContentAuthorities); if (network != null) { Loading
apex/jobscheduler/service/java/com/android/server/job/JobConcurrencyManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ class JobConcurrencyManager { private boolean isFgJob(JobStatus job) { // (It's super confusing PRIORITY_BOUND_FOREGROUND_SERVICE isn't FG here) return job.lastEvaluatedPriority >= JobInfo.PRIORITY_TOP_APP || job.shouldTreatAsForegroundJob(); || job.shouldTreatAsExpeditedJob(); } @GuardedBy("mLock") Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +10 −9 Original line number Diff line number Diff line Loading @@ -835,9 +835,10 @@ public class JobSchedulerService extends com.android.server.SystemService return o2.overrideState - o1.overrideState; } if (o1.getSourceUid() == o2.getSourceUid()) { final boolean o1FGJ = o1.isRequestedForegroundJob(); if (o1FGJ != o2.isRequestedForegroundJob()) { // Attempt to run requested HPJs ahead of regular jobs, regardless of HPJ quota. final boolean o1FGJ = o1.isRequestedExpeditedJob(); if (o1FGJ != o2.isRequestedExpeditedJob()) { // Attempt to run requested expedited jobs ahead of regular jobs, regardless of // expedited job quota. return o1FGJ ? -1 : 1; } } Loading Loading @@ -1143,9 +1144,9 @@ public class JobSchedulerService extends com.android.server.SystemService JobStatus jobStatus = JobStatus.createFromJobInfo(job, uId, packageName, userId, tag); // Return failure early if HPJ quota used up. if (jobStatus.isRequestedForegroundJob() && !mQuotaController.isWithinHpjQuotaLocked(jobStatus)) { // Return failure early if expedited job quota used up. if (jobStatus.isRequestedExpeditedJob() && !mQuotaController.isWithinEJQuotaLocked(jobStatus)) { return JobScheduler.RESULT_FAILURE; } Loading Loading @@ -1897,9 +1898,9 @@ public class JobSchedulerService extends com.android.server.SystemService Slog.d(TAG, "Completed " + jobStatus + ", reschedule=" + needsReschedule); } // Intentionally not checking HPJ quota here. An app can't find out if it's run out of quota // when it asks JS to reschedule an HPJ. Instead, the rescheduled HPJ will just be demoted // to a regular job if the app has no HPJ quota left. // Intentionally not checking expedited job quota here. An app can't find out if it's run // out of quota when it asks JS to reschedule an expedited job. Instead, the rescheduled // EJ will just be demoted to a regular job if the app has no EJ quota left. // If the job wants to be rescheduled, we first need to make the next upcoming // job so we can transfer any appropriate state over from the previous job when Loading
apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +6 −6 Original line number Diff line number Diff line Loading @@ -76,10 +76,10 @@ public final class JobServiceContext implements ServiceConnection { /** Amount of time a job is allowed to execute for before being considered timed-out. */ public static final long DEFAULT_EXECUTING_TIMESLICE_MILLIS = 10 * 60 * 1000; // 10mins. /** * Amount of time a RESTRICTED HPJ is allowed to execute for before being considered * Amount of time a RESTRICTED expedited job is allowed to execute for before being considered * timed-out. */ public static final long DEFAULT_RESTRICTED_HPJ_EXECUTING_TIMESLICE_MILLIS = public static final long DEFAULT_RESTRICTED_EXPEDITED_JOB_EXECUTING_TIMESLICE_MILLIS = DEFAULT_EXECUTING_TIMESLICE_MILLIS / 2; /** Amount of time the JobScheduler waits for the initial service launch+bind. */ private static final long OP_BIND_TIMEOUT_MILLIS = 18 * 1000; Loading Loading @@ -231,7 +231,7 @@ public final class JobServiceContext implements ServiceConnection { final JobInfo ji = job.getJob(); mParams = new JobParameters(mRunningCallback, job.getJobId(), ji.getExtras(), ji.getTransientExtras(), ji.getClipData(), ji.getClipGrantFlags(), isDeadlineExpired, job.shouldTreatAsForegroundJob(), isDeadlineExpired, job.shouldTreatAsExpeditedJob(), triggeredUris, triggeredAuthorities, job.network); mExecutionStartTimeElapsed = sElapsedRealtimeClock.millis(); Loading Loading @@ -259,7 +259,7 @@ public final class JobServiceContext implements ServiceConnection { boolean binding = false; try { final int bindFlags; if (job.shouldTreatAsForegroundJob()) { if (job.shouldTreatAsExpeditedJob()) { // Add BIND_FOREGROUND_SERVICE to make it BFGS. Without it, it'll be // PROCESS_STATE_IMPORTANT_FOREGROUND. Unclear which is better here. // TODO(171305774): The job should run on the little cores. We'll probably need Loading Loading @@ -865,9 +865,9 @@ public final class JobServiceContext implements ServiceConnection { final long timeoutMillis; switch (mVerb) { case VERB_EXECUTING: timeoutMillis = mRunningJob.shouldTreatAsForegroundJob() timeoutMillis = mRunningJob.shouldTreatAsExpeditedJob() && mRunningJob.getStandbyBucket() == RESTRICTED_INDEX ? DEFAULT_RESTRICTED_HPJ_EXECUTING_TIMESLICE_MILLIS ? DEFAULT_RESTRICTED_EXPEDITED_JOB_EXECUTING_TIMESLICE_MILLIS : DEFAULT_EXECUTING_TIMESLICE_MILLIS; break; Loading