diff options
| author | Dianne Hackborn <hackbod@google.com> | 2017-04-04 17:17:35 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2017-04-11 13:57:15 -0700 |
| commit | 7da13d7c3e5b48c0410ae869c5679652de97e5aa (patch) | |
| tree | aae8983e62d1417a6e60944a4103023792b4c139 /core/java/android/app/JobSchedulerImpl.java | |
| parent | 4a306894145340a4fe08b70b569eaa31641b38e6 (diff) | |
Add new "work queue" feature to JobScheduler.
This gives semantics similar to the start command
queue of services.
The implementation is currently lacking in URI permission
grant handling of the work intents; that will be coming
in a follow-up change.
This includes a first step of adjusting/fixing locking
within JobSchedulerService. The JobServiceContext class
has a bunch of stuff it does that assumes it doesn't need
locking because it schedules the work on a handler. However,
to be able to correctly implement the work finish flow (that
takes care of stopping the job when there is no more work),
we can't dispatch these asynchronously so need to get rid of
that and just do explicit locking.
The switch to explicit locking is half-way there (again the
remaining part will be a follow-on CL). Right now we have
the locking, but still also the handler. But it turns out
there were a number of things we were doing without a lock
held where we actually should have been holding a lock, so
this is better anyway.
Test: new tests added
Change-Id: Iebd098046209b28e60fd2f4d855d7f91cd3a8b03
Diffstat (limited to 'core/java/android/app/JobSchedulerImpl.java')
| -rw-r--r-- | core/java/android/app/JobSchedulerImpl.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/app/JobSchedulerImpl.java b/core/java/android/app/JobSchedulerImpl.java index e30b96fd692a..4ac44f79a4ec 100644 --- a/core/java/android/app/JobSchedulerImpl.java +++ b/core/java/android/app/JobSchedulerImpl.java @@ -20,6 +20,8 @@ package android.app; import android.app.job.JobInfo; import android.app.job.JobScheduler; import android.app.job.IJobScheduler; +import android.app.job.JobWorkItem; +import android.content.Intent; import android.os.RemoteException; import java.util.List; @@ -46,6 +48,15 @@ public class JobSchedulerImpl extends JobScheduler { } @Override + public int enqueue(JobInfo job, JobWorkItem work) { + try { + return mBinder.enqueue(job, work); + } catch (RemoteException e) { + return JobScheduler.RESULT_FAILURE; + } + } + + @Override public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag) { try { return mBinder.scheduleAsPackage(job, packageName, userId, tag); |
