1 /**
2  * Copyright 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.job;
18 
19 import android.app.Notification;
20 import android.app.job.JobWorkItem;
21 
22 /**
23  * The server side of the JobScheduler IPC protocols.  The app-side implementation
24  * invokes on this interface to indicate completion of the (asynchronous) instructions
25  * issued by the server.
26  *
27  * In all cases, the 'who' parameter is the caller's service binder, used to track
28  * which Job Service instance is reporting.
29  *
30  * {@hide}
31  */
32 interface IJobCallback {
33     /**
34      * Immediate callback to the system after sending a data transfer download progress request
35      * signal; used to quickly detect ANR.
36      *
37      * @param jobId Unique integer used to identify this job.
38      * @param workId Unique integer used to identify a specific work item.
39      * @param transferredBytes How much data has been downloaded, in bytes.
40      */
acknowledgeGetTransferredDownloadBytesMessage(int jobId, int workId, long transferredBytes)41     void acknowledgeGetTransferredDownloadBytesMessage(int jobId, int workId,
42             long transferredBytes);
43     /**
44      * Immediate callback to the system after sending a data transfer upload progress request
45      * signal; used to quickly detect ANR.
46      *
47      * @param jobId Unique integer used to identify this job.
48      * @param workId Unique integer used to identify a specific work item.
49      * @param transferredBytes How much data has been uploaded, in bytes.
50      */
acknowledgeGetTransferredUploadBytesMessage(int jobId, int workId, long transferredBytes)51     void acknowledgeGetTransferredUploadBytesMessage(int jobId, int workId, long transferredBytes);
52     /**
53      * Immediate callback to the system after sending a start signal, used to quickly detect ANR.
54      *
55      * @param jobId Unique integer used to identify this job.
56      * @param ongoing True to indicate that the client is processing the job. False if the job is
57      * complete
58      */
59     @UnsupportedAppUsage
acknowledgeStartMessage(int jobId, boolean ongoing)60     void acknowledgeStartMessage(int jobId, boolean ongoing);
61     /**
62      * Immediate callback to the system after sending a stop signal, used to quickly detect ANR.
63      *
64      * @param jobId Unique integer used to identify this job.
65      * @param reschedule Whether or not to reschedule this job.
66      */
67     @UnsupportedAppUsage
acknowledgeStopMessage(int jobId, boolean reschedule)68     void acknowledgeStopMessage(int jobId, boolean reschedule);
69     /*
70      * Called to deqeue next work item for the job.
71      */
72     @UnsupportedAppUsage
dequeueWork(int jobId)73     JobWorkItem dequeueWork(int jobId);
74     /*
75      * Called to report that job has completed processing a work item.
76      */
77     @UnsupportedAppUsage
completeWork(int jobId, int workId)78     boolean completeWork(int jobId, int workId);
79     /*
80      * Tell the job manager that the client is done with its execution, so that it can go on to
81      * the next one and stop attributing wakelock time to us etc.
82      *
83      * @param jobId Unique integer used to identify this job.
84      * @param reschedule Whether or not to reschedule this job.
85      */
86     @UnsupportedAppUsage
jobFinished(int jobId, boolean reschedule)87     void jobFinished(int jobId, boolean reschedule);
88     /*
89      * Inform JobScheduler of a change in the estimated transfer payload.
90      *
91      * @param jobId Unique integer used to identify this job.
92      * @param item The particular JobWorkItem this progress is associated with, if any.
93      * @param downloadBytes How many bytes the app expects to download.
94      * @param uploadBytes How many bytes the app expects to upload.
95      */
updateEstimatedNetworkBytes(int jobId, in JobWorkItem item, long downloadBytes, long uploadBytes)96     void updateEstimatedNetworkBytes(int jobId, in JobWorkItem item,
97             long downloadBytes, long uploadBytes);
98     /*
99      * Update JobScheduler of how much data the job has successfully transferred.
100      *
101      * @param jobId Unique integer used to identify this job.
102      * @param item The particular JobWorkItem this progress is associated with, if any.
103      * @param transferredDownloadBytes The number of bytes that have successfully been downloaded.
104      * @param transferredUploadBytes The number of bytes that have successfully been uploaded.
105      */
updateTransferredNetworkBytes(int jobId, in JobWorkItem item, long transferredDownloadBytes, long transferredUploadBytes)106     void updateTransferredNetworkBytes(int jobId, in JobWorkItem item,
107             long transferredDownloadBytes, long transferredUploadBytes);
108     /**
109      * Provide JobScheduler with a notification to post and tie to this job's
110      * lifecycle.
111      * This is required for all user-initiated job and optional for other jobs.
112      *
113      * @param jobId Unique integer used to identify this job.
114      * @param notificationId The ID for this notification, as per
115      *                       {@link android.app.NotificationManager#notify(int, Notification)}.
116      * @param notification The notification to be displayed.
117      * @param jobEndNotificationPolicy The policy to apply to the notification when the job stops.
118      */
setNotification(int jobId, int notificationId, in Notification notification, int jobEndNotificationPolicy)119     void setNotification(int jobId, int notificationId,
120             in Notification notification, int jobEndNotificationPolicy);
121 }
122