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 cancel(int jobId)49 public void cancel(int jobId) { 50 try { 51 mBinder.cancel(jobId); 52 } catch (RemoteException e) {} 53 54 } 55 56 @Override cancelAll()57 public void cancelAll() { 58 try { 59 mBinder.cancelAll(); 60 } catch (RemoteException e) {} 61 62 } 63 64 @Override getAllPendingJobs()65 public List<JobInfo> getAllPendingJobs() { 66 try { 67 return mBinder.getAllPendingJobs(); 68 } catch (RemoteException e) { 69 return null; 70 } 71 } 72 } 73