OSDN Git Service

Merge "VD: Update the fillColor default as transparent" into lmp-dev
[android-x86/frameworks-base.git] / core / java / android / app / job / JobScheduler.java
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16
17 package android.app.job;
18
19 import java.util.List;
20
21 import android.content.Context;
22
23 /**
24  * Class for scheduling various types of jobs with the scheduling framework on the device.
25  * See {@link android.app.job.JobInfo} for more description of the types of jobs that can be run
26  * and how to construct them.
27  * The framework will be intelligent about when you receive your callbacks, and attempt to batch
28  * and defer them as much as possible. Typically if you don't specify a deadline on your job, it
29  * can be run at any moment depending on the current state of the JobScheduler's internal queue,
30  * however it might be deferred as long as until the next time the device is connected to a power
31  * source.
32  * <p>You do not
33  * instantiate this class directly; instead, retrieve it through
34  * {@link android.content.Context#getSystemService
35  * Context.getSystemService(Context.JOB_SCHEDULER_SERVICE)}.
36  */
37 public abstract class JobScheduler {
38     /**
39      * Returned from {@link #schedule(JobInfo)} when an invalid parameter was supplied. This can occur
40      * if the run-time for your job is too short, or perhaps the system can't resolve the
41      * requisite {@link JobService} in your package.
42      */
43     public static final int RESULT_FAILURE = 0;
44     /**
45      * Returned from {@link #schedule(JobInfo)} if this application has made too many requests for
46      * work over too short a time.
47      */
48     // TODO: Determine if this is necessary.
49     public static final int RESULT_SUCCESS = 1;
50
51     /**
52      * @param job The job you wish scheduled. See
53      * {@link android.app.job.JobInfo.Builder JobInfo.Builder} for more detail on the sorts of jobs
54      * you can schedule.
55      * @return If >0, this int returns the jobId of the successfully scheduled job.
56      * Otherwise you have to compare the return value to the error codes defined in this class.
57      */
58     public abstract int schedule(JobInfo job);
59
60     /**
61      * Cancel a job that is pending in the JobScheduler.
62      * @param jobId unique identifier for this job. Obtain this value from the jobs returned by
63      * {@link #getAllPendingJobs()}.
64      * @return
65      */
66     public abstract void cancel(int jobId);
67
68     /**
69      * Cancel all jobs that have been registered with the JobScheduler by this package.
70      */
71     public abstract void cancelAll();
72
73     /**
74      * @return a list of all the jobs registered by this package that have not yet been executed.
75      */
76     public abstract List<JobInfo> getAllPendingJobs();
77
78 }