1fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate/*
2fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * Copyright (C) 2014 The Android Open Source Project
3fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate *
4fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * Licensed under the Apache License, Version 2.0 (the "License");
5fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * you may not use this file except in compliance with the License.
6fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * You may obtain a copy of the License at
7fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate *
8fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate *      http://www.apache.org/licenses/LICENSE-2.0
9fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate *
10fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * Unless required by applicable law or agreed to in writing, software
11fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * distributed under the License is distributed on an "AS IS" BASIS,
12fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * See the License for the specific language governing permissions and
14fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * limitations under the License.
15fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate */
16fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
17fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate// in android.app so ContextImpl has package access
18fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tatepackage android.app;
19fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
207060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tateimport android.app.job.JobInfo;
217060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tateimport android.app.job.JobScheduler;
227060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tateimport android.app.job.IJobScheduler;
23effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williamsimport android.os.RemoteException;
24fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
25fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tateimport java.util.List;
26fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
27fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
28fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate/**
297060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate * Concrete implementation of the JobScheduler interface
30fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * @hide
31fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate */
327060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tatepublic class JobSchedulerImpl extends JobScheduler {
337060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate    IJobScheduler mBinder;
34fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
357060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate    /* package */ JobSchedulerImpl(IJobScheduler binder) {
36fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate        mBinder = binder;
37fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    }
38fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
39fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    @Override
407060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate    public int schedule(JobInfo job) {
41effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        try {
427060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate            return mBinder.schedule(job);
43effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        } catch (RemoteException e) {
447060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate            return JobScheduler.RESULT_FAILURE;
45effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        }
46fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    }
47fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
48fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    @Override
497060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate    public void cancel(int jobId) {
50effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        try {
517060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate            mBinder.cancel(jobId);
52effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        } catch (RemoteException e) {}
53fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
54fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    }
55fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
56fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    @Override
57fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    public void cancelAll() {
58effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        try {
59effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams            mBinder.cancelAll();
60effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        } catch (RemoteException e) {}
61fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
62fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    }
63fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate
64fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    @Override
657060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate    public List<JobInfo> getAllPendingJobs() {
66effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        try {
677060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate            return mBinder.getAllPendingJobs();
68effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        } catch (RemoteException e) {
69effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams            return null;
70effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams        }
71fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate    }
72fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate}
73