blob: f72ca623de10dd16dc81bbd78b0d09608dd7fca4 [file] [log] [blame]
Kweku Adams85f2fbc2017-12-18 12:04:12 -08001/*
2 * Copyright (C) 2017 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
17syntax = "proto2";
18
19package com.android.server.job;
20
21option java_multiple_files = true;
22
23import "frameworks/base/core/proto/android/app/jobparameters.proto";
24import "frameworks/base/core/proto/android/content/clipdata.proto";
25import "frameworks/base/core/proto/android/content/component_name.proto";
26import "frameworks/base/core/proto/android/content/intent.proto";
27import "frameworks/base/core/proto/android/net/network.proto";
28import "frameworks/base/core/proto/android/net/networkrequest.proto";
29import "frameworks/base/core/proto/android/os/bundle.proto";
30import "frameworks/base/core/proto/android/os/persistablebundle.proto";
31import "frameworks/base/core/proto/android/server/forceappstandbytracker.proto";
32
33message JobSchedulerServiceDumpProto {
34 optional ConstantsProto settings = 1;
35
36 repeated int32 started_users = 2;
37
38 message RegisteredJob {
39 optional JobStatusShortInfoProto info = 1;
40 optional JobStatusDumpProto dump = 2;
41
42 // A job is ready to be executed if:
43 // is_job_ready && is_user_started && !is_job_pending &&
44 // !is_job_currently_active && !is_uid_backing_up &&
45 // is_component_present.
46 optional bool is_job_ready = 3;
47 optional bool is_user_started = 4;
48 optional bool is_job_pending = 5;
49 optional bool is_job_currently_active = 6;
50 optional bool is_uid_backing_up = 7;
51 optional bool is_component_present = 8;
52 }
53 repeated RegisteredJob registered_jobs = 3;
54
55 repeated StateControllerProto controllers = 4;
56
57 // Which uids are currently in the foreground.
58 message PriorityOverride {
59 optional int32 uid = 1;
60 // Use sint32 instead of an enum since priorities can technically be
61 // negative.
62 optional sint32 override_value = 2;
63 }
64 repeated PriorityOverride priority_overrides = 5;
65
66 // UIDs that are currently performing backups, so their jobs won't be
67 // allowed to run.
68 repeated int32 backing_up_uids = 6;
69
70 optional JobPackageHistoryProto history = 7;
71 optional JobPackageTrackerDumpProto package_tracker = 8;
72
73 message PendingJob {
74 optional JobStatusShortInfoProto info = 1;
75 optional JobStatusDumpProto dump = 2;
76 optional sint32 evaluated_priority = 3;
77 // How long this job has been pending.
78 optional int64 enqueued_duration_ms = 4;
79 }
80 repeated PendingJob pending_jobs = 9;
81
82 // From a service that has currently active or pending jobs.
83 message ActiveJob {
84 message InactiveJob {
85 optional int64 time_since_stopped_ms = 1;
86 // This is not always provided.
87 optional string stopped_reason = 2;
88 }
89 message RunningJob {
90 optional JobStatusShortInfoProto info = 1;
91 // How long this job has been running for.
92 optional int64 running_duration_ms = 2;
93 optional int64 time_until_timeout_ms = 3;
94
95 optional JobStatusDumpProto dump = 4;
96
97 optional sint32 evaluated_priority = 5;
98
99 optional int64 time_since_made_active_ms = 6;
100 // How long this job has been pending.
101 optional int64 pending_duration_ms = 7;
102 }
103 oneof job {
104 InactiveJob inactive = 1;
105 RunningJob running = 2;
106 }
107 }
108 repeated ActiveJob active_jobs = 10;
109
110 // True when JobScheduler is allowed to run third party apps.
111 optional bool is_ready_to_rock = 11;
112 // What was last reported to DeviceIdleController about whether the device
113 // is active.
114 optional bool reported_active = 12;
115 // The current limit on the number of concurrent JobServiceContext entries
116 // we want to keep actively running a job.
117 optional int32 max_active_jobs = 13;
118}
119
120// A com.android.server.job.JobSchedulerService.Constants object.
121message ConstantsProto {
122 // Minimum # of idle jobs that must be ready in order to force the JMS to
123 // schedule things early.
124 optional int32 min_idle_count = 1;
125 // Minimum # of charging jobs that must be ready in order to force the JMS
126 // to schedule things early.
127 optional int32 min_charging_count = 2;
128 // Minimum # of "battery not low" jobs that must be ready in order to force
129 // the JMS to schedule things early.
130 optional int32 min_battery_not_low_count = 3;
131 // Minimum # of "storage not low" jobs that must be ready in order to force
132 // the JMS to schedule things early.
133 optional int32 min_storage_not_low_count = 4;
134 // Minimum # of connectivity jobs that must be ready in order to force the
135 // JMS to schedule things early. 1 == Run connectivity jobs as soon as
136 // ready.
137 optional int32 min_connectivity_count = 5;
138 // Minimum # of content trigger jobs that must be ready in order to force
139 // the JMS to schedule things early.
140 optional int32 min_content_count = 6;
141 // Minimum # of jobs (with no particular constraints) for which the JMS will
142 // be happy running some work early. This (and thus the other min counts)
143 // is now set to 1, to prevent any batching at this level. Since we now do
144 // batching through doze, that is a much better mechanism.
145 optional int32 min_ready_jobs_count = 7;
146 // This is the job execution factor that is considered to be heavy use of
147 // the system.
148 optional double heavy_use_factor = 8;
149 // This is the job execution factor that is considered to be moderate use of
150 // the system.
151 optional double moderate_use_factor = 9;
152 // The number of MAX_JOB_CONTEXTS_COUNT we reserve for the foreground app.
153 optional int32 fg_job_count = 10;
154 // The maximum number of background jobs we allow when the system is in a
155 // normal memory state.
156 optional int32 bg_normal_job_count = 11;
157 // The maximum number of background jobs we allow when the system is in a
158 // moderate memory state.
159 optional int32 bg_moderate_job_count = 12;
160 // The maximum number of background jobs we allow when the system is in a
161 // low memory state.
162 optional int32 bg_low_job_count = 13;
163 // The maximum number of background jobs we allow when the system is in a
164 // critical memory state.
165 optional int32 bg_critical_job_count = 14;
166 // The maximum number of times we allow a job to have itself rescheduled
167 // before giving up on it, for standard jobs.
168 optional int32 max_standard_reschedule_count = 15;
169 // The maximum number of times we allow a job to have itself rescheduled
170 // before giving up on it, for jobs that are executing work.
171 optional int32 max_work_reschedule_count = 16;
172 // The minimum backoff time to allow for linear backoff.
173 optional int64 min_linear_backoff_time_ms = 17;
174 // The minimum backoff time to allow for exponential backoff.
175 optional int64 min_exp_backoff_time_ms = 18;
176 // How often we recalculate runnability based on apps' standby bucket
177 // assignment. This should be prime relative to common time interval lengths
178 // such as a quarter-hour or day, so that the heartbeat drifts relative to
179 // wall-clock milestones.
180 optional int64 standby_heartbeat_time_ms = 19;
181 // Mapping: standby bucket -> number of heartbeats between each sweep of
182 // that bucket's jobs.
183 // Bucket assignments as recorded in the JobStatus objects are normalized to
184 // be indices into this array, rather than the raw constants used by
185 // AppIdleHistory.
186 repeated int32 standby_beats = 20;
187}
188
189message StateControllerProto {
190 message AppIdleController {
191 optional bool is_parole_on = 1;
192
193 message TrackedJob {
194 optional JobStatusShortInfoProto info = 1;
195 optional int32 source_uid = 2;
196 optional string source_package_name = 3;
197 // If the constraints are satisfied, then the controller will mark
198 // the job as RUNNABLE, otherwise, it will be WAITING.
199 optional bool are_constraints_satisfied = 4;
200 }
201 repeated TrackedJob tracked_jobs = 2;
202 }
203 message BackgroundJobsController {
204 optional com.android.server.ForceAppStandbyTrackerProto force_app_standby_tracker = 1;
205
206 message TrackedJob {
207 optional JobStatusShortInfoProto info = 1;
208 optional int32 source_uid = 2;
209 optional string source_package_name = 3;
210 optional bool is_in_foreground = 4;
211 optional bool is_whitelisted = 5;
212 optional bool can_run_any_in_background = 6;
213 // If the constraints are satisfied, then the controller will mark
214 // the job as RUNNABLE, otherwise, it will be WAITING.
215 optional bool are_constraints_satisfied = 7;
216 }
217 repeated TrackedJob tracked_jobs = 2;
218 }
219 message BatteryController {
220 optional bool is_on_stable_power = 1;
221 optional bool is_battery_not_low = 2;
222
223 // Whether or not the controller is monitoring battery changes.
224 optional bool is_monitoring = 3;
225 // Only valid if is_monitoring is true.
226 optional int32 last_broadcast_sequence_number = 4;
227
228 message TrackedJob {
229 optional JobStatusShortInfoProto info = 1;
230 optional int32 source_uid = 2;
231 }
232 repeated TrackedJob tracked_jobs = 5;
233 }
234 message ConnectivityController {
235 optional bool is_connected = 1;
236
237 message TrackedJob {
238 optional JobStatusShortInfoProto info = 1;
239 optional int32 source_uid = 2;
240 optional .android.net.NetworkRequestProto required_network = 3;
241 }
242 repeated TrackedJob tracked_jobs = 2;
243 }
244 message ContentObserverController {
245 message TrackedJob {
246 optional JobStatusShortInfoProto info = 1;
247 optional int32 source_uid = 2;
248 }
249 repeated TrackedJob tracked_jobs = 1;
250
251 message Observer {
252 optional int32 user_id = 1;
253
254 message TriggerContentData {
255 optional string uri = 1;
256 optional int32 flags = 2;
257
258 // A
259 // com.android.server.job.controllers.ContentObserverController.JobInstance
260 // object.
261 message JobInstance {
262 optional JobStatusShortInfoProto info = 1;
263 optional int32 source_uid = 2;
264
265 optional int64 trigger_content_update_delay_ms = 3;
266 optional int64 trigger_content_max_delay_ms = 4;
267
268 repeated string changed_authorities = 5;
269 repeated string changed_uris = 6;
270 }
271 repeated JobInstance jobs = 3;
272 }
273 repeated TriggerContentData triggers = 2;
274 }
275 repeated Observer observers = 2;
276 }
277 message DeviceIdleJobsController {
278 // True when in device idle mode.
279 optional bool is_device_idle_mode = 1;
280
281 message TrackedJob {
282 optional JobStatusShortInfoProto info = 1;
283 optional int32 source_uid = 2;
284 optional string source_package_name = 3;
285 // If the constraints are satisfied, then the controller will mark
286 // the job as RUNNABLE, otherwise, it will be WAITING.
287 optional bool are_constraints_satisfied = 4;
288 optional bool is_doze_whitelisted = 5;
289 // A job that is exempted from Doze when the app is temp whitelisted
290 // or in the foreground.
291 optional bool is_allowed_in_doze = 6;
292 }
293 repeated TrackedJob tracked_jobs = 2;
294 }
295 message IdleController {
296 optional bool is_idle = 1;
297
298 message TrackedJob {
299 optional JobStatusShortInfoProto info = 1;
300 optional int32 source_uid = 2;
301 }
302 repeated TrackedJob tracked_jobs = 2;
303 }
304 message StorageController {
305 optional bool is_storage_not_low = 1;
306 optional int32 last_broadcast_sequence_number = 2;
307
308 message TrackedJob {
309 optional JobStatusShortInfoProto info = 1;
310 optional int32 source_uid = 2;
311 }
312 repeated TrackedJob tracked_jobs = 3;
313 }
314 message TimeController {
315 optional int64 now_elapsed_realtime = 1;
316 optional int64 time_until_next_delay_alarm_ms = 2;
317 optional int64 time_until_next_deadline_alarm_ms = 3;
318
319 message TrackedJob {
320 optional JobStatusShortInfoProto info = 1;
321 optional int32 source_uid = 2;
322
323 optional bool has_timing_delay_constraint = 3;
324 // Only valid if has_timing_delay_constraint is true. Can be
325 // negative if the delay is in the past.
326 optional int64 delay_time_remaining_ms = 4;
327
328 optional bool has_deadline_constraint = 5;
329 // Only valid if has_timing_delay_constraint is true. Can be
330 // negative in certain situations.
331 optional int64 time_remaining_until_deadline_ms = 6;
332 }
333 repeated TrackedJob tracked_jobs = 4;
334 }
335 oneof controller {
336 AppIdleController app_idle = 1;
337 BackgroundJobsController background = 2;
338 BatteryController battery = 3;
339 ConnectivityController connectivity = 4;
340 ContentObserverController content_observer = 5;
341 DeviceIdleJobsController device_idle = 6;
342 IdleController idle = 7;
343 StorageController storage = 8;
344 TimeController time = 9;
345 }
346}
347
348// A com.android.server.job.JobPackageTracker.DataSet object.
349message DataSetProto {
350 optional int64 start_clock_time_ms = 1;
351 // How much time has elapsed since the DataSet was instantiated.
352 optional int64 elapsed_time_ms = 2;
353 optional int64 period_ms = 3;
354
355 // Represents a com.android.server.job.JobPackageTracker.PackageEntry
356 // object, but with some extra data.
357 message PackageEntryProto {
358 optional int32 uid = 1;
359 optional string package_name = 2;
360
361 message State {
362 optional int64 duration_ms = 1;
363 optional int32 count = 2;
364 }
365 optional State pending_state = 3;
366 optional State active_state = 4;
367 optional State active_top_state = 5;
368
369 // True if the PackageEntry is currently pending or has been pending in
370 // the past.
371 optional bool pending = 6;
372 // True if the PackageEntry is currently active or has been active in
373 // the past.
374 optional bool active = 7;
375 // True if the PackageEntry is currently active top or has been active
376 // top in the past.
377 optional bool active_top = 8;
378
379 message StopReasonCount {
380 optional .android.app.JobParametersProto.CancelReason reason = 1;
381 optional int32 count = 2;
382 }
383 repeated StopReasonCount stop_reasons = 9;
384 }
385 repeated PackageEntryProto package_entries = 4;
386
387 optional int32 max_concurrency = 5;
388 optional int32 max_foreground_concurrency = 6;
389}
390
391// Dump from com.android.server.job.GrantedUriPermissions.
392message GrantedUriPermissionsDumpProto {
393 optional int32 flags = 1;
394 optional int32 source_user_id = 2;
395 optional string tag = 3;
396 optional string permission_owner = 4;
397 repeated string uris = 5;
398}
399
400message JobPackageTrackerDumpProto {
401 repeated DataSetProto historical_stats = 1;
402 optional DataSetProto current_stats = 2;
403}
404
405message JobPackageHistoryProto {
406 enum Event {
407 UNKNOWN = 0;
408 START_JOB = 1;
409 STOP_JOB = 2;
410 START_PERIODIC_JOB = 3;
411 STOP_PERIODIC_JOB = 4;
412 }
413 message HistoryEvent {
414 optional Event event = 1;
415 optional int64 time_since_event_ms = 2;
416 optional int32 uid = 3;
417 // Job IDs can technically be negative.
418 optional int32 job_id = 4;
419 optional string tag = 5;
420 // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events.
421 optional .android.app.JobParametersProto.CancelReason stop_reason = 6;
422 }
423 repeated HistoryEvent history_event = 1;
424}
425
426message JobStatusShortInfoProto {
427 optional int32 calling_uid = 1;
428 // Job IDs can technically be negative.
429 optional int32 job_id = 2;
430 optional string battery_name = 3;
431}
432
433// Dump from a com.android.server.job.controllers.JobStatus object.
434message JobStatusDumpProto {
435 // The UID that scheduled the job.
436 optional int32 calling_uid = 1;
437 optional string tag = 2;
438
439 // The UID for which the job is being run.
440 optional int32 source_uid = 3;
441 optional int32 source_user_id = 4;
442 // The package for which the job is being run.
443 optional string source_package_name = 5;
444
445 // Custom dump of android.app.job.JobInfo object.
446 message JobInfo {
447 optional .android.content.ComponentNameProto service = 1;
448
449 optional bool is_periodic = 2;
450 // Only valid if is_periodic is true.
451 optional int64 period_interval_ms = 3;
452 // Only valid if is_periodic is true.
453 optional int64 period_flex_ms = 4;
454
455 optional bool is_persisted = 5;
456 optional sint32 priority = 6;
457 optional int32 flags = 7;
458
459 optional bool requires_charging = 8;
460 optional bool requires_battery_not_low = 9;
461 optional bool requires_device_idle = 10;
462
463 message TriggerContentUri {
464 optional int32 flags = 1;
465 optional string uri = 2;
466 }
467 repeated TriggerContentUri trigger_content_uris = 11;
468 optional int64 trigger_content_update_delay_ms = 12;
469 optional int64 trigger_content_max_delay_ms = 13;
470
471 optional .android.os.PersistableBundleProto extras = 14;
472 optional .android.os.BundleProto transient_extras = 15;
473 optional .android.content.ClipDataProto clip_data = 16;
474
475 optional GrantedUriPermissionsDumpProto granted_uri_permissions = 17;
476
477 optional .android.net.NetworkRequestProto required_network = 18;
478
479 optional int64 total_network_bytes = 19;
480
481 optional int64 min_latency_ms = 20;
482 optional int64 max_execution_delay_ms = 21;
483
484 message Backoff {
485 enum Policy {
486 BACKOFF_POLICY_LINEAR = 0;
487 BACKOFF_POLICY_EXPONENTIAL = 1;
488 }
489 optional Policy policy = 1;
490 optional int64 initial_backoff_ms = 2;
491 }
492 optional Backoff backoff_policy = 22;
493
494 optional bool has_early_constraint = 23;
495 optional bool has_late_constraint = 24;
496 }
497 optional JobInfo job_info = 6;
498
499 enum Constraint {
500 CONSTRAINT_CHARGING = 1;
501 CONSTRAINT_BATTERY_NOT_LOW = 2;
502 CONSTRAINT_STORAGE_NOT_LOW = 3;
503 CONSTRAINT_TIMING_DELAY = 4;
504 CONSTRAINT_DEADLINE = 5;
505 CONSTRAINT_IDLE = 6;
506 CONSTRAINT_CONNECTIVITY = 7;
507 CONSTRAINT_APP_NOT_IDLE = 8;
508 CONSTRAINT_CONTENT_TRIGGER = 9;
509 CONSTRAINT_DEVICE_NOT_DOZING = 10;
510 }
511 repeated Constraint required_constraints = 7;
512 repeated Constraint satisfied_constraints = 8;
513 repeated Constraint unsatisfied_constraints = 9;
514 optional bool is_doze_whitelisted = 10;
515
516 enum TrackingController {
517 TRACKING_BATTERY = 0;
518 TRACKING_CONNECTIVITY = 1;
519 TRACKING_CONTENT = 2;
520 TRACKING_IDLE = 3;
521 TRACKING_STORAGE = 4;
522 TRACKING_TIME = 5;
523 }
524 // Controllers that are currently tracking the job.
525 repeated TrackingController tracking_controllers = 11;
526
527 repeated string changed_authorities = 12;
528 repeated string changed_uris = 13;
529
530 optional .android.net.NetworkProto network = 14;
531
532 // Only the desired data from an android.app.job.JobWorkItem object.
533 message JobWorkItem {
534 optional int32 work_id = 1;
535 optional int32 delivery_count = 2;
536 optional .android.content.IntentProto intent = 3;
537 optional GrantedUriPermissionsDumpProto uri_grants = 4;
538 }
539 repeated JobWorkItem pending_work = 15;
540 repeated JobWorkItem executing_work = 16;
541
542 enum Bucket {
543 ACTIVE = 0;
544 WORKING_SET = 1;
545 FREQUENT = 2;
546 RARE = 3;
547 NEVER = 4;
548 }
549 optional Bucket standby_bucket = 17;
550
551 optional int64 enqueue_duration_ms = 18;
552 // Can be negative if the earliest runtime deadline has passed.
553 optional sint64 time_until_earliest_runtime_ms = 19;
554 // Can be negative if the latest runtime deadline has passed.
555 optional sint64 time_until_latest_runtime_ms = 20;
556
557 optional int32 num_failures = 21;
558
559 optional int64 last_successful_run_time = 22;
560 optional int64 last_failed_run_time = 23;
561}