summaryrefslogtreecommitdiffstats
path: root/core/java/android/app/job
diff options
context:
space:
mode:
authorMatthew Williams <mjwilliams@google.com>2014-08-08 11:51:06 -0700
committerMatthew Williams <mjwilliams@google.com>2014-08-21 20:37:06 +0000
commitbafeeb98135a7580cbcdd657818cd78f7bda35d8 (patch)
treef507ef08821a19103834f75808e5ba907e6a906d /core/java/android/app/job
parentde3af82ce0c533a284df8d5afc49a475b003ea46 (diff)
downloadframeworks_base-bafeeb98135a7580cbcdd657818cd78f7bda35d8.zip
frameworks_base-bafeeb98135a7580cbcdd657818cd78f7bda35d8.tar.gz
frameworks_base-bafeeb98135a7580cbcdd657818cd78f7bda35d8.tar.bz2
JobScheduler needs to flush queue on charging
Also make it illegal to schedule a job with no constraints. BUG: 16877705 Change-Id: Iae57286bc4f73163a7e3c9d2d531623fd50f1f72
Diffstat (limited to 'core/java/android/app/job')
-rw-r--r--core/java/android/app/job/JobInfo.java6
-rw-r--r--core/java/android/app/job/JobScheduler.java8
2 files changed, 13 insertions, 1 deletions
diff --git a/core/java/android/app/job/JobInfo.java b/core/java/android/app/job/JobInfo.java
index 936e205..b7af544 100644
--- a/core/java/android/app/job/JobInfo.java
+++ b/core/java/android/app/job/JobInfo.java
@@ -434,6 +434,12 @@ public class JobInfo implements Parcelable {
* @return The job object to hand to the JobScheduler. This object is immutable.
*/
public JobInfo build() {
+ // Allow tasks with no constraints. What am I, a database?
+ if (!mHasEarlyConstraint && !mHasLateConstraint && !mRequiresCharging &&
+ !mRequiresDeviceIdle && mNetworkCapabilities == NetworkType.NONE) {
+ throw new IllegalArgumentException("You're trying to build a job with no " +
+ "constraints, this is not allowed.");
+ }
mExtras = new PersistableBundle(mExtras); // Make our own copy.
// Check that a deadline was not set on a periodic job.
if (mIsPeriodic && (mMaxExecutionDelayMillis != 0L)) {
diff --git a/core/java/android/app/job/JobScheduler.java b/core/java/android/app/job/JobScheduler.java
index 7fe192c..ca7022d 100644
--- a/core/java/android/app/job/JobScheduler.java
+++ b/core/java/android/app/job/JobScheduler.java
@@ -22,7 +22,13 @@ import android.content.Context;
/**
* Class for scheduling various types of jobs with the scheduling framework on the device.
- *
+ * See {@link android.app.job.JobInfo} for more description of the types of jobs that can be run
+ * and how to construct them.
+ * The framework will be intelligent about when you receive your callbacks, and attempt to batch
+ * and defer them as much as possible. Typically if you don't specify a deadline on your job, it
+ * can be run at any moment depending on the current state of the JobScheduler's internal queue,
+ * however it might be deferred as long as until the next time the device is connected to a power
+ * source.
* <p>You do not
* instantiate this class directly; instead, retrieve it through
* {@link android.content.Context#getSystemService