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

Commit fd8807ac authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

More small fixes/adjustments to job scheduler.

- JobServiceEngine now takes a concrete Service instead of
generic Context in its constructor, since it really must be
associated with a real Service.

- Expand documentation of how dequeueWork() operates.

- Fix some job scheduler implementation to hopefully actually
match the docs: transfer remaining executing work to the new
job, and actually correctly transfer state from old and new
jobs if we are rescheduling due to a true return from onStopJob().

Test: bit CtsJobSchedulerTestCases:*
Change-Id: Ia66797049883eefb566264f930070afb69d469b1
parent d8837b6f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6890,7 +6890,7 @@ package android.app.job {
  }
  public abstract class JobServiceEngine {
    ctor public JobServiceEngine(android.content.Context);
    ctor public JobServiceEngine(android.app.Service);
    method public final android.os.IBinder getBinder();
    method public final void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
+1 −1
Original line number Diff line number Diff line
@@ -7324,7 +7324,7 @@ package android.app.job {
  }
  public abstract class JobServiceEngine {
    ctor public JobServiceEngine(android.content.Context);
    ctor public JobServiceEngine(android.app.Service);
    method public final android.os.IBinder getBinder();
    method public final void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
+1 −1
Original line number Diff line number Diff line
@@ -6920,7 +6920,7 @@ package android.app.job {
  }
  public abstract class JobServiceEngine {
    ctor public JobServiceEngine(android.content.Context);
    ctor public JobServiceEngine(android.app.Service);
    method public final android.os.IBinder getBinder();
    method public final void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
+14 −0
Original line number Diff line number Diff line
@@ -164,6 +164,20 @@ public class JobParameters implements Parcelable {
     * you should not call {@link JobService#jobFinished(JobParameters, boolean)} yourself
     * (otherwise you risk losing an upcoming JobWorkItem that is being enqueued at the same time).
     *
     * <p>Once you are done with the {@link JobWorkItem} returned by this method, you must call
     * {@link #completeWork(JobWorkItem)} with it to inform the system that you are done
     * executing the work.  The job will not be finished until all dequeued work has been
     * completed.  You do not, however, have to complete each returned work item before deqeueing
     * the next one -- you can use {@link #dequeueWork()} multiple times before completing
     * previous work if you want to process work in parallel, and you can complete the work
     * in whatever order you want.</p>
     *
     * <p>If the job runs to the end of its available time period before all work has been
     * completed, it will stop as normal.  You should return true from
     * {@link JobService#onStopJob(JobParameters)} in order to have the job rescheduled, and by
     * doing so any pending as well as remaining uncompleted work will be re-queued
     * for the next time the job runs.</p>
     *
     * @return Returns a new {@link JobWorkItem} if there is one pending, otherwise null.
     * If null is returned, the system will also stop the job if all work has also been completed.
     * (This means that for correct operation, you must always call dequeueWork() after you have
+5 −5
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public abstract class JobServiceEngine {
    /**
     * Context we are running in.
     */
    private final Context mContext;
    private final Service mService;

    private final IJobService mBinder;

@@ -182,12 +182,12 @@ public abstract class JobServiceEngine {
    /**
     * Create a new engine, ready for use.
     *
     * @param context The {@link Service} that is creating this engine.
     * @param service The {@link Service} that is creating this engine and in which it will run.
     */
    public JobServiceEngine(Context context) {
        mContext = context;
    public JobServiceEngine(Service service) {
        mService = service;
        mBinder = new JobInterface(this);
        mHandler = new JobHandler(mContext.getMainLooper());
        mHandler = new JobHandler(mService.getMainLooper());
    }

    /**
Loading