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; 237da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackbornimport android.app.job.JobWorkItem; 247da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackbornimport android.content.Intent; 25effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williamsimport android.os.RemoteException; 26fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 27fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tateimport java.util.List; 28fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 29fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 30fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate/** 317060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate * Concrete implementation of the JobScheduler interface 32fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate * @hide 33fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate */ 347060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tatepublic class JobSchedulerImpl extends JobScheduler { 357060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate IJobScheduler mBinder; 36fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 377060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate /* package */ JobSchedulerImpl(IJobScheduler binder) { 38fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate mBinder = binder; 39fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate } 40fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 41fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate @Override 427060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate public int schedule(JobInfo job) { 43effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams try { 447060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate return mBinder.schedule(job); 45effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } catch (RemoteException e) { 467060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate return JobScheduler.RESULT_FAILURE; 477da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn } 487da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn } 497da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn 507da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn @Override 517da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn public int enqueue(JobInfo job, JobWorkItem work) { 527da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn try { 537da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn return mBinder.enqueue(job, work); 547da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn } catch (RemoteException e) { 557da13d7c3e5b48c0410ae869c5679652de97e5aaDianne Hackborn return JobScheduler.RESULT_FAILURE; 56effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } 57fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate } 58fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 59fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate @Override 601085ff6ee531931ef7f55cbadbc83616f619b292Dianne Hackborn public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag) { 61968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge try { 621085ff6ee531931ef7f55cbadbc83616f619b292Dianne Hackborn return mBinder.scheduleAsPackage(job, packageName, userId, tag); 63968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge } catch (RemoteException e) { 64968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge return JobScheduler.RESULT_FAILURE; 65968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge } 66968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge } 67968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge 68968ac75c2048214a28e9eac3d0e2e0d23776f887Shreyas Basarge @Override 697060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate public void cancel(int jobId) { 70effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams try { 717060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate mBinder.cancel(jobId); 72effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } catch (RemoteException e) {} 73fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 74fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate } 75fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 76fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate @Override 77fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate public void cancelAll() { 78effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams try { 79effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams mBinder.cancelAll(); 80effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } catch (RemoteException e) {} 81fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 82fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate } 83fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate 84fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate @Override 857060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate public List<JobInfo> getAllPendingJobs() { 86effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams try { 877060b04f6d92351b67222e636ab378a0273bf3e7Christopher Tate return mBinder.getAllPendingJobs(); 88effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } catch (RemoteException e) { 89effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams return null; 90effacfa75bd9c2ebc889a7bc4f002c07f82f4c31Matthew Williams } 91fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate } 92f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey 93f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey @Override 94f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey public JobInfo getPendingJob(int jobId) { 95f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey try { 96f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey return mBinder.getPendingJob(jobId); 97f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey } catch (RemoteException e) { 98f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey return null; 99f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey } 100f07c7b9fd0a640bff4bf7690373613da217fe69bJeff Sharkey } 101fa380e982e41b0dcbbcf2201803abf26808016b5Christopher Tate} 102