summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/job
diff options
context:
space:
mode:
authorMatthew Williams <mjwilliams@google.com>2014-07-09 12:46:53 -0700
committerMatthew Williams <mjwilliams@google.com>2014-07-10 16:51:27 -0700
commit900c67fc51fc2672458dd1c9641250f2ecc01a31 (patch)
tree6be17e409dd09f2f25a76e42a41ab439583120b9 /core/java/android/app/job
parent244911f9769946249aad1e0ed7187f2cb1d01831 (diff)
downloadframeworks_base-900c67fc51fc2672458dd1c9641250f2ecc01a31.zip
frameworks_base-900c67fc51fc2672458dd1c9641250f2ecc01a31.tar.gz
frameworks_base-900c67fc51fc2672458dd1c9641250f2ecc01a31.tar.bz2
Add job persistance as a setter in the API
Bug: 15936795 Change-Id: I11e5a722bab5838dc151670256ed09dfaa7fdaa7
Diffstat (limited to 'core/java/android/app/job')
-rw-r--r--core/java/android/app/job/JobInfo.java31
1 files changed, 25 insertions, 6 deletions
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java
index a22e4cd..70f6966 100644
--- a/core/java/android/app/job/JobInfo.java
+++ b/core/java/android/app/job/JobInfo.java
@@ -64,7 +64,6 @@ public class JobInfo implements Parcelable {
}
private final int jobId;
- // TODO: Change this to use PersistableBundle when that lands in master.
private final PersistableBundle extras;
private final ComponentName service;
private final boolean requireCharging;
@@ -75,6 +74,7 @@ public class JobInfo implements Parcelable {
private final long minLatencyMillis;
private final long maxExecutionDelayMillis;
private final boolean isPeriodic;
+ private final boolean isPersisted;
private final long intervalMillis;
private final long initialBackoffMillis;
private final int backoffPolicy;
@@ -145,6 +145,13 @@ public class JobInfo implements Parcelable {
}
/**
+ * @return Whether or not this job should be persisted across device reboots.
+ */
+ public boolean isPersisted() {
+ return isPersisted;
+ }
+
+ /**
* Set to the interval between occurrences of this job. This value is <b>not</b> set if the
* job does not recur periodically.
*/
@@ -197,6 +204,7 @@ public class JobInfo implements Parcelable {
minLatencyMillis = in.readLong();
maxExecutionDelayMillis = in.readLong();
isPeriodic = in.readInt() == 1;
+ isPersisted = in.readInt() == 1;
intervalMillis = in.readLong();
initialBackoffMillis = in.readLong();
backoffPolicy = in.readInt();
@@ -214,6 +222,7 @@ public class JobInfo implements Parcelable {
minLatencyMillis = b.mMinLatencyMillis;
maxExecutionDelayMillis = b.mMaxExecutionDelayMillis;
isPeriodic = b.mIsPeriodic;
+ isPersisted = b.mIsPersisted;
intervalMillis = b.mIntervalMillis;
initialBackoffMillis = b.mInitialBackoffMillis;
backoffPolicy = b.mBackoffPolicy;
@@ -237,6 +246,7 @@ public class JobInfo implements Parcelable {
out.writeLong(minLatencyMillis);
out.writeLong(maxExecutionDelayMillis);
out.writeInt(isPeriodic ? 1 : 0);
+ out.writeInt(isPersisted ? 1 : 0);
out.writeLong(intervalMillis);
out.writeLong(initialBackoffMillis);
out.writeInt(backoffPolicy);
@@ -265,6 +275,7 @@ public class JobInfo implements Parcelable {
private boolean mRequiresCharging;
private boolean mRequiresDeviceIdle;
private int mNetworkCapabilities;
+ private boolean mIsPersisted;
// One-off parameters.
private long mMinLatencyMillis;
private long mMaxExecutionDelayMillis;
@@ -342,11 +353,6 @@ public class JobInfo implements Parcelable {
* Specify that this job should recur with the provided interval, not more than once per
* period. You have no control over when within this interval this job will be executed,
* only the guarantee that it will be executed at most once within this interval.
- * A periodic job will be repeated until the phone is turned off, however it will only be
- * persisted beyond boot if the client app has declared the
- * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission. You can schedule
- * periodic jobs without this permission, they simply will cease to exist after the phone
- * restarts.
* Setting this function on the builder with {@link #setMinimumLatency(long)} or
* {@link #setOverrideDeadline(long)} will result in an error.
* @param intervalMillis Millisecond interval for which this job will repeat.
@@ -407,6 +413,19 @@ public class JobInfo implements Parcelable {
}
/**
+ * Set whether or not to persist this job across device reboots. This will only have an
+ * effect if your application holds the permission
+ * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}. Otherwise an exception will
+ * be thrown.
+ * @param isPersisted True to indicate that the job will be written to disk and loaded at
+ * boot.
+ */
+ public Builder setIsPersisted(boolean isPersisted) {
+ mIsPersisted = isPersisted;
+ return this;
+ }
+
+ /**
* @return The job object to hand to the JobScheduler. This object is immutable.
*/
public JobInfo build() {