blob: 425ec473bc8e19278b0d0d78dbbc49be0690a4b7 [file] [log] [blame]
Shreyas Basargecbf5ae92016-03-08 16:13:06 +00001/*
2 * Copyright (C) 2016 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
17package com.android.server.job;
18
Christopher Tate435c2f42018-01-18 12:59:15 -080019import android.annotation.UserIdInt;
Shreyas Basargecbf5ae92016-03-08 16:13:06 +000020import android.app.job.JobInfo;
21
22import java.util.List;
23
24/**
25 * JobScheduler local system service interface.
26 * {@hide} Only for use within the system server.
27 */
28public interface JobSchedulerInternal {
29
Christopher Tatea732f012017-10-26 17:26:53 -070030 // Bookkeeping about app standby bucket scheduling
31
32 /**
33 * The current bucket heartbeat ordinal
34 */
35 long currentHeartbeat();
36
37 /**
38 * Heartbeat ordinal at which the given standby bucket's jobs next become runnable
39 */
40 long nextHeartbeatForBucket(int bucket);
41
Shreyas Basargecbf5ae92016-03-08 16:13:06 +000042 /**
Christopher Tate435c2f42018-01-18 12:59:15 -080043 * Heartbeat ordinal for the given app. This is typically the heartbeat at which
44 * the app last ran jobs, so that a newly-scheduled job in an app that hasn't run
45 * jobs in a long time is immediately runnable even if the app is bucketed into
46 * an infrequent time allocation.
47 */
48 public long baseHeartbeatForApp(String packageName, @UserIdInt int userId, int appBucket);
49
50 /**
Christopher Tate325768c2018-03-07 16:07:56 -080051 * Tell the scheduler when a JobServiceContext starts running a job in an app
52 */
53 void noteJobStart(String packageName, int userId);
54
55 /**
Shreyas Basargecbf5ae92016-03-08 16:13:06 +000056 * Returns a list of pending jobs scheduled by the system service.
57 */
58 List<JobInfo> getSystemScheduledPendingJobs();
Dianne Hackbornf9bac162017-04-20 17:17:48 -070059
60 /**
Christopher Tate1d99c392017-12-07 16:54:04 -080061 * Cancel the jobs for a given uid (e.g. when app data is cleared)
62 */
63 void cancelJobsForUid(int uid, String reason);
64
65 /**
Dianne Hackbornf9bac162017-04-20 17:17:48 -070066 * These are for activity manager to communicate to use what is currently performing backups.
67 */
68 void addBackingUpUid(int uid);
69 void removeBackingUpUid(int uid);
70 void clearAllBackingUpUids();
Makoto Onukidd4b14f2017-08-17 14:03:48 -070071
Christopher Tated117b292018-01-05 17:32:36 -080072 /**
73 * The user has started interacting with the app. Take any appropriate action.
74 */
75 void reportAppUsage(String packageName, int userId);
76
77 /**
78 * Report a snapshot of sync-related jobs back to the sync manager
79 */
Makoto Onukie7b02982017-08-24 14:23:36 -070080 JobStorePersistStats getPersistStats();
81
Makoto Onukidd4b14f2017-08-17 14:03:48 -070082 /**
Makoto Onukie7b02982017-08-24 14:23:36 -070083 * Stats about the first load after boot and the most recent save.
Makoto Onukidd4b14f2017-08-17 14:03:48 -070084 */
Makoto Onukie7b02982017-08-24 14:23:36 -070085 public class JobStorePersistStats {
86 public int countAllJobsLoaded = -1;
87 public int countSystemServerJobsLoaded = -1;
88 public int countSystemSyncManagerJobsLoaded = -1;
89
90 public int countAllJobsSaved = -1;
91 public int countSystemServerJobsSaved = -1;
92 public int countSystemSyncManagerJobsSaved = -1;
93
94 public JobStorePersistStats() {
95 }
96
97 public JobStorePersistStats(JobStorePersistStats source) {
98 countAllJobsLoaded = source.countAllJobsLoaded;
99 countSystemServerJobsLoaded = source.countSystemServerJobsLoaded;
100 countSystemSyncManagerJobsLoaded = source.countSystemSyncManagerJobsLoaded;
101
102 countAllJobsSaved = source.countAllJobsSaved;
103 countSystemServerJobsSaved = source.countSystemServerJobsSaved;
104 countSystemSyncManagerJobsSaved = source.countSystemSyncManagerJobsSaved;
105 }
106
107 @Override
108 public String toString() {
109 return "FirstLoad: "
110 + countAllJobsLoaded + "/"
111 + countSystemServerJobsLoaded + "/"
112 + countSystemSyncManagerJobsLoaded
113 + " LastSave: "
114 + countAllJobsSaved + "/"
115 + countSystemServerJobsSaved + "/"
116 + countSystemSyncManagerJobsSaved;
117 }
118 }
Shreyas Basargecbf5ae92016-03-08 16:13:06 +0000119}