blob: b3a486f450bfe27ea05399d15ce3a4f663ab8527 [file] [log] [blame]
Christopher Tatefa380e92014-05-19 13:46:29 -07001/*
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
18package android.app;
19
Christopher Tate7060b042014-06-09 19:50:00 -070020import android.app.job.JobInfo;
21import android.app.job.JobScheduler;
22import android.app.job.IJobScheduler;
Matthew Williamseffacfa2014-06-05 20:56:40 -070023import android.os.RemoteException;
Christopher Tatefa380e92014-05-19 13:46:29 -070024
25import java.util.List;
26
27
28/**
Christopher Tate7060b042014-06-09 19:50:00 -070029 * Concrete implementation of the JobScheduler interface
Christopher Tatefa380e92014-05-19 13:46:29 -070030 * @hide
31 */
Christopher Tate7060b042014-06-09 19:50:00 -070032public class JobSchedulerImpl extends JobScheduler {
33 IJobScheduler mBinder;
Christopher Tatefa380e92014-05-19 13:46:29 -070034
Christopher Tate7060b042014-06-09 19:50:00 -070035 /* package */ JobSchedulerImpl(IJobScheduler binder) {
Christopher Tatefa380e92014-05-19 13:46:29 -070036 mBinder = binder;
37 }
38
39 @Override
Christopher Tate7060b042014-06-09 19:50:00 -070040 public int schedule(JobInfo job) {
Matthew Williamseffacfa2014-06-05 20:56:40 -070041 try {
Christopher Tate7060b042014-06-09 19:50:00 -070042 return mBinder.schedule(job);
Matthew Williamseffacfa2014-06-05 20:56:40 -070043 } catch (RemoteException e) {
Christopher Tate7060b042014-06-09 19:50:00 -070044 return JobScheduler.RESULT_FAILURE;
Matthew Williamseffacfa2014-06-05 20:56:40 -070045 }
Christopher Tatefa380e92014-05-19 13:46:29 -070046 }
47
48 @Override
Dianne Hackborn1085ff62016-02-23 17:04:58 -080049 public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag) {
Shreyas Basarge968ac752016-01-11 23:09:26 +000050 try {
Dianne Hackborn1085ff62016-02-23 17:04:58 -080051 return mBinder.scheduleAsPackage(job, packageName, userId, tag);
Shreyas Basarge968ac752016-01-11 23:09:26 +000052 } catch (RemoteException e) {
53 return JobScheduler.RESULT_FAILURE;
54 }
55 }
56
57 @Override
Christopher Tate7060b042014-06-09 19:50:00 -070058 public void cancel(int jobId) {
Matthew Williamseffacfa2014-06-05 20:56:40 -070059 try {
Christopher Tate7060b042014-06-09 19:50:00 -070060 mBinder.cancel(jobId);
Matthew Williamseffacfa2014-06-05 20:56:40 -070061 } catch (RemoteException e) {}
Christopher Tatefa380e92014-05-19 13:46:29 -070062
63 }
64
65 @Override
66 public void cancelAll() {
Matthew Williamseffacfa2014-06-05 20:56:40 -070067 try {
68 mBinder.cancelAll();
69 } catch (RemoteException e) {}
Christopher Tatefa380e92014-05-19 13:46:29 -070070
71 }
72
73 @Override
Christopher Tate7060b042014-06-09 19:50:00 -070074 public List<JobInfo> getAllPendingJobs() {
Matthew Williamseffacfa2014-06-05 20:56:40 -070075 try {
Christopher Tate7060b042014-06-09 19:50:00 -070076 return mBinder.getAllPendingJobs();
Matthew Williamseffacfa2014-06-05 20:56:40 -070077 } catch (RemoteException e) {
78 return null;
79 }
Christopher Tatefa380e92014-05-19 13:46:29 -070080 }
Christopher Tatefa380e92014-05-19 13:46:29 -070081}