diff options
| author | Shreyas Basarge <snb@google.com> | 2016-01-15 13:54:08 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-01-15 13:54:08 +0000 |
| commit | 17971e383f97db0d398b86ae537448605f70894e (patch) | |
| tree | c81bcc78fd12a104d684b283f694c04d3b9088ad /core/java | |
| parent | 8414c671bd6c490bbbfbe51d7b2f8f32a6fb58e4 (diff) | |
| parent | 5db09084c8e4efc6311754243c39962fc8e7a766 (diff) | |
Merge "Added priority to JobScheduler scheduling"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/job/JobInfo.java | 18 | ||||
| -rw-r--r-- | core/java/android/app/job/JobParameters.java | 27 |
2 files changed, 45 insertions, 0 deletions
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java index b899710c4feb..9ad35d4c1556 100644 --- a/core/java/android/app/job/JobInfo.java +++ b/core/java/android/app/job/JobInfo.java @@ -91,6 +91,7 @@ public class JobInfo implements Parcelable { private final long flexMillis; private final long initialBackoffMillis; private final int backoffPolicy; + private final int priority; /** * Unique job id associated with this class. This is assigned to your job by the scheduler. @@ -113,6 +114,11 @@ public class JobInfo implements Parcelable { return service; } + /** @hide */ + public int getPriority() { + return priority; + } + /** * Whether this job needs the device to be plugged in. */ @@ -237,6 +243,7 @@ public class JobInfo implements Parcelable { backoffPolicy = in.readInt(); hasEarlyConstraint = in.readInt() == 1; hasLateConstraint = in.readInt() == 1; + priority = in.readInt(); } private JobInfo(JobInfo.Builder b) { @@ -256,6 +263,7 @@ public class JobInfo implements Parcelable { backoffPolicy = b.mBackoffPolicy; hasEarlyConstraint = b.mHasEarlyConstraint; hasLateConstraint = b.mHasLateConstraint; + priority = b.mPriority; } @Override @@ -281,6 +289,7 @@ public class JobInfo implements Parcelable { out.writeInt(backoffPolicy); out.writeInt(hasEarlyConstraint ? 1 : 0); out.writeInt(hasLateConstraint ? 1 : 0); + out.writeInt(priority); } public static final Creator<JobInfo> CREATOR = new Creator<JobInfo>() { @@ -305,6 +314,7 @@ public class JobInfo implements Parcelable { private int mJobId; private PersistableBundle mExtras = PersistableBundle.EMPTY; private ComponentName mJobService; + private int mPriority; // Requirements. private boolean mRequiresCharging; private boolean mRequiresDeviceIdle; @@ -338,6 +348,14 @@ public class JobInfo implements Parcelable { } /** + * @hide + */ + public Builder setPriority(int priority) { + mPriority = priority; + return this; + } + + /** * Set optional extras. This is persisted, so we only allow primitive types. * @param extras Bundle containing extras you want the scheduler to hold on to for you. */ diff --git a/core/java/android/app/job/JobParameters.java b/core/java/android/app/job/JobParameters.java index 7ee39f5cd939..a0a60e8c53a0 100644 --- a/core/java/android/app/job/JobParameters.java +++ b/core/java/android/app/job/JobParameters.java @@ -28,10 +28,22 @@ import android.os.PersistableBundle; */ public class JobParameters implements Parcelable { + /** @hide */ + public static final int REASON_CANCELED = 0; + /** @hide */ + public static final int REASON_CONSTRAINTS_NOT_SATISFIED = 1; + /** @hide */ + public static final int REASON_PREEMPT = 2; + /** @hide */ + public static final int REASON_TIMEOUT = 3; + /** @hide */ + public static final int REASON_DEVICE_IDLE = 4; + private final int jobId; private final PersistableBundle extras; private final IBinder callback; private final boolean overrideDeadlineExpired; + private int stopReason; // Default value of stopReason is REASON_CANCELED /** @hide */ public JobParameters(IBinder callback, int jobId, PersistableBundle extras, @@ -50,6 +62,14 @@ public class JobParameters implements Parcelable { } /** + * Reason onStopJob() was called on this job. + * @hide + */ + public int getStopReason() { + return stopReason; + } + + /** * @return The extras you passed in when constructing this job with * {@link android.app.job.JobInfo.Builder#setExtras(android.os.PersistableBundle)}. This will * never be null. If you did not set any extras this will be an empty bundle. @@ -78,6 +98,12 @@ public class JobParameters implements Parcelable { extras = in.readPersistableBundle(); callback = in.readStrongBinder(); overrideDeadlineExpired = in.readInt() == 1; + stopReason = in.readInt(); + } + + /** @hide */ + public void setStopReason(int reason) { + stopReason = reason; } @Override @@ -91,6 +117,7 @@ public class JobParameters implements Parcelable { dest.writePersistableBundle(extras); dest.writeStrongBinder(callback); dest.writeInt(overrideDeadlineExpired ? 1 : 0); + dest.writeInt(stopReason); } public static final Creator<JobParameters> CREATOR = new Creator<JobParameters>() { |
