• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // in android.app so ContextImpl has package access
18 package android.app;
19 
20 import android.app.job.JobInfo;
21 import android.app.job.JobScheduler;
22 import android.app.job.IJobScheduler;
23 import android.os.RemoteException;
24 
25 import java.util.List;
26 
27 
28 /**
29  * Concrete implementation of the JobScheduler interface
30  * @hide
31  */
32 public class JobSchedulerImpl extends JobScheduler {
33     IJobScheduler mBinder;
34 
JobSchedulerImpl(IJobScheduler binder)35     /* package */ JobSchedulerImpl(IJobScheduler binder) {
36         mBinder = binder;
37     }
38 
39     @Override
schedule(JobInfo job)40     public int schedule(JobInfo job) {
41         try {
42             return mBinder.schedule(job);
43         } catch (RemoteException e) {
44             return JobScheduler.RESULT_FAILURE;
45         }
46     }
47 
48     @Override
scheduleAsPackage(JobInfo job, String packageName, int userId, String tag)49     public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag) {
50         try {
51             return mBinder.scheduleAsPackage(job, packageName, userId, tag);
52         } catch (RemoteException e) {
53             return JobScheduler.RESULT_FAILURE;
54         }
55     }
56 
57     @Override
cancel(int jobId)58     public void cancel(int jobId) {
59         try {
60             mBinder.cancel(jobId);
61         } catch (RemoteException e) {}
62 
63     }
64 
65     @Override
cancelAll()66     public void cancelAll() {
67         try {
68             mBinder.cancelAll();
69         } catch (RemoteException e) {}
70 
71     }
72 
73     @Override
getAllPendingJobs()74     public List<JobInfo> getAllPendingJobs() {
75         try {
76             return mBinder.getAllPendingJobs();
77         } catch (RemoteException e) {
78             return null;
79         }
80     }
81 
82     @Override
getPendingJob(int jobId)83     public JobInfo getPendingJob(int jobId) {
84         try {
85             return mBinder.getPendingJob(jobId);
86         } catch (RemoteException e) {
87             return null;
88         }
89     }
90 }
91