Debian Codegraph @

apex/jobscheduler/framework/java/android/app/JobSchedulerImpl.java

raw symbols SCIP
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 package android.app;
18
19 import android.annotation.NonNull;
20 import android.annotation.RequiresPermission;
21 import android.app.job.IJobScheduler;
22 import android.app.job.IUserVisibleJobObserver;
23 import android.app.job.JobInfo;
24 import android.app.job.JobScheduler;
25 import android.app.job.JobSnapshot;
26 import android.app.job.JobWorkItem;
27 import android.os.RemoteException;
28
29 import java.util.List;
30
31
32 /**
33 * Concrete implementation of the JobScheduler interface
34 *
35 * Note android.app.job is the better package to put this class, but we can't move it there
36 * because that'd break robolectric. Grr.
37 *
38 * @hide
39 */
40 public class JobSchedulerImpl extends JobScheduler {
41 IJobScheduler mBinder;
42
43 public JobSchedulerImpl(IJobScheduler binder) {
44 mBinder = binder;
45 }
46
47 @Override
48 public int schedule(JobInfo job) {
49 try {
50 return mBinder.schedule(job);
51 } catch (RemoteException e) {
52 return JobScheduler.RESULT_FAILURE;
53 }
54 }
55
56 @Override
57 public int enqueue(JobInfo job, JobWorkItem work) {
58 try {
59 return mBinder.enqueue(job, work);
60 } catch (RemoteException e) {
61 return JobScheduler.RESULT_FAILURE;
62 }
63 }
64
65 @Override
66 public int scheduleAsPackage(JobInfo job, String packageName, int userId, String tag) {
67 try {
68 return mBinder.scheduleAsPackage(job, packageName, userId, tag);
69 } catch (RemoteException e) {
70 return JobScheduler.RESULT_FAILURE;
71 }
72 }
73
74 @Override
75 public void cancel(int jobId) {
76 try {
77 mBinder.cancel(jobId);
78 } catch (RemoteException e) {}
79
80 }
81
82 @Override
83 public void cancelAll() {
84 try {
85 mBinder.cancelAll();
86 } catch (RemoteException e) {}
87
88 }
89
90 @Override
91 public List<JobInfo> getAllPendingJobs() {
92 try {
93 return mBinder.getAllPendingJobs().getList();
94 } catch (RemoteException e) {
95 return null;
96 }
97 }
98
99 @Override
100 public JobInfo getPendingJob(int jobId) {
101 try {
102 return mBinder.getPendingJob(jobId);
103 } catch (RemoteException e) {
104 return null;
105 }
106 }
107
108 @Override
109 public List<JobInfo> getStartedJobs() {
110 try {
111 return mBinder.getStartedJobs();
112 } catch (RemoteException e) {
113 return null;
114 }
115 }
116
117 @Override
118 public List<JobSnapshot> getAllJobSnapshots() {
119 try {
120 return mBinder.getAllJobSnapshots().getList();
121 } catch (RemoteException e) {
122 return null;
123 }
124 }
125
126 @RequiresPermission(allOf = {
127 android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
128 android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
129 @Override
130 public void registerUserVisibleJobObserver(@NonNull IUserVisibleJobObserver observer) {
131 // TODO(255767350): implement
132 }
133
134 @RequiresPermission(allOf = {
135 android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
136 android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
137 @Override
138 public void unregisterUserVisibleJobObserver(@NonNull IUserVisibleJobObserver observer) {
139 // TODO(255767350): implement
140 }
141
142 @RequiresPermission(allOf = {
143 android.Manifest.permission.MANAGE_ACTIVITY_TASKS,
144 android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})
145 @Override
146 public void stopUserVisibleJobsForUser(@NonNull String packageName, int userId) {
147 // TODO(255767350): implement
148 }
149 }