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

Commit 28d1b661 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Address various JobScheduler API feedback.

- New sample code.
- Fix/improve some docs.
- Hide JobWorkItem Parcl constructor.

Also:

- Add new JobWorkItem API to get the number of times it has been
delivered.
- Do a bit more optimization of checking if a job is ready.

Bug: 37534393  API Review: JobInfo.Builder
Bug: 37544057  API Review: JobServiceEngine
Bug: 37544153  API Review: JobWorkItem

Test: bit CtsJobSchedulerTestCases:*
Change-Id: I66891a038fba752f45dcaed43e615fa9209b71fc
parent 31eeb08b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -6893,15 +6893,15 @@ package android.app.job {
  public abstract class JobServiceEngine {
    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 void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
    method public abstract boolean onStopJob(android.app.job.JobParameters);
  }
  public final class JobWorkItem implements android.os.Parcelable {
    ctor public JobWorkItem(android.content.Intent);
    ctor public JobWorkItem(android.os.Parcel);
    method public int describeContents();
    method public int getDeliveryCount();
    method public android.content.Intent getIntent();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
+2 −2
Original line number Diff line number Diff line
@@ -7329,15 +7329,15 @@ package android.app.job {
  public abstract class JobServiceEngine {
    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 void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
    method public abstract boolean onStopJob(android.app.job.JobParameters);
  }
  public final class JobWorkItem implements android.os.Parcelable {
    ctor public JobWorkItem(android.content.Intent);
    ctor public JobWorkItem(android.os.Parcel);
    method public int describeContents();
    method public int getDeliveryCount();
    method public android.content.Intent getIntent();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
+2 −2
Original line number Diff line number Diff line
@@ -6923,15 +6923,15 @@ package android.app.job {
  public abstract class JobServiceEngine {
    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 void jobFinished(android.app.job.JobParameters, boolean);
    method public abstract boolean onStartJob(android.app.job.JobParameters);
    method public abstract boolean onStopJob(android.app.job.JobParameters);
  }
  public final class JobWorkItem implements android.os.Parcelable {
    ctor public JobWorkItem(android.content.Intent);
    ctor public JobWorkItem(android.os.Parcel);
    method public int describeContents();
    method public int getDeliveryCount();
    method public android.content.Intent getIntent();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.job.JobWorkItem> CREATOR;
+6 −2
Original line number Diff line number Diff line
@@ -837,8 +837,12 @@ public class JobInfo implements Parcelable {
        }

        /**
         * Set optional transient extras. This is incompatible with jobs that are also
         * persisted with {@link #setPersisted(boolean)}; mixing the two is not allowed.
         * Set optional transient extras.
         *
         * <p>Because setting this property is not compatible with persisted
         * jobs, doing so will throw an {@link java.lang.IllegalArgumentException} when
         * {@link android.app.job.JobInfo.Builder#build()} is called.</p>
         *
         * @param extras Bundle containing extras you want the scheduler to hold on to for you.
         */
        public Builder setTransientExtras(@NonNull Bundle extras) {
+6 −0
Original line number Diff line number Diff line
@@ -180,6 +180,12 @@ public class JobParameters implements Parcelable {
     * doing so any pending as well as remaining uncompleted work will be re-queued
     * for the next time the job runs.</p>
     *
     * <p>This example shows how to construct a JobService that will serially dequeue and
     * process work that is available for it:</p>
     *
     * {@sample development/samples/ApiDemos/src/com/example/android/apis/app/JobWorkService.java
     *      service}
     *
     * @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
Loading