1/*
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/job/enums.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";
32import "frameworks/base/core/proto/android/server/job/enums.proto";
33import "frameworks/base/core/proto/android/privacy.proto";
34
35// Next tag: 21
36message JobSchedulerServiceDumpProto {
37    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
38
39    optional ConstantsProto settings = 1;
40
41    optional int32 current_heartbeat = 14;
42    repeated int32 next_heartbeat = 15;
43    optional int64 last_heartbeat_time_millis = 16;
44    optional int64 next_heartbeat_time_millis = 17;
45    optional bool in_parole = 18;
46    optional bool in_thermal = 19;
47
48    repeated int32 started_users = 2;
49
50    message RegisteredJob {
51        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
52
53        optional JobStatusShortInfoProto info = 1;
54        optional JobStatusDumpProto dump = 2;
55
56        // A job is ready to be executed if:
57        // is_job_ready && is_user_started && !is_job_pending &&
58        // !is_job_currently_active && !is_uid_backing_up &&
59        // is_component_present.
60        optional bool is_job_ready = 3;
61        optional bool is_user_started = 4;
62        optional bool is_job_pending = 5;
63        optional bool is_job_currently_active = 6;
64        optional bool is_uid_backing_up = 7;
65        optional bool is_component_present = 8;
66
67        optional int64 last_run_heartbeat = 9;
68    }
69    repeated RegisteredJob registered_jobs = 3;
70
71    repeated StateControllerProto controllers = 4;
72
73    // Which uids are currently in the foreground.
74    message PriorityOverride {
75        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
76
77        optional int32 uid = 1;
78        // Use sint32 instead of an enum since priorities can technically be
79        // negative.
80        optional sint32 override_value = 2;
81    }
82    repeated PriorityOverride priority_overrides = 5;
83
84    // UIDs that are currently performing backups, so their jobs won't be
85    // allowed to run.
86    repeated int32 backing_up_uids = 6;
87
88    optional JobPackageHistoryProto history = 7;
89    optional JobPackageTrackerDumpProto package_tracker = 8;
90
91    message PendingJob {
92        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
93
94        optional JobStatusShortInfoProto info = 1;
95        optional JobStatusDumpProto dump = 2;
96        optional sint32 evaluated_priority = 3;
97        // How long this job has been pending.
98        optional int64 enqueued_duration_ms = 4;
99    }
100    repeated PendingJob pending_jobs = 9;
101
102    // From a service that has currently active or pending jobs.
103    message ActiveJob {
104        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
105
106        message InactiveJob {
107            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
108
109            optional int64 time_since_stopped_ms = 1;
110            // This is not always provided.
111            optional string stopped_reason = 2;
112        }
113        message RunningJob {
114            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
115
116            optional JobStatusShortInfoProto info = 1;
117            // How long this job has been running for.
118            optional int64 running_duration_ms = 2;
119            optional int64 time_until_timeout_ms = 3;
120
121            optional JobStatusDumpProto dump = 4;
122
123            optional sint32 evaluated_priority = 5;
124
125            optional int64 time_since_made_active_ms = 6;
126            // How long this job has been pending.
127            optional int64 pending_duration_ms = 7;
128        }
129        oneof job {
130            InactiveJob inactive = 1;
131            RunningJob running = 2;
132        }
133    }
134    repeated ActiveJob active_jobs = 10;
135
136    // True when JobScheduler is allowed to run third party apps.
137    optional bool is_ready_to_rock = 11;
138    // What was last reported to DeviceIdleController about whether the device
139    // is active.
140    optional bool reported_active = 12;
141    // The current limit on the number of concurrent JobServiceContext entries
142    // we want to keep actively running a job.
143    optional int32 max_active_jobs = 13;
144
145    // Dump from JobConcurrencyManager.
146    optional JobConcurrencyManagerProto concurrency_manager = 20;
147}
148
149// A com.android.server.job.JobSchedulerService.Constants object.
150// Next tag: 29
151message ConstantsProto {
152    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
153
154    // Minimum # of idle jobs that must be ready in order to force the JMS to
155    // schedule things early.
156    optional int32 min_idle_count = 1;
157    // Minimum # of charging jobs that must be ready in order to force the JMS
158    // to schedule things early.
159    optional int32 min_charging_count = 2;
160    // Minimum # of "battery not low" jobs that must be ready in order to force
161    // the JMS to schedule things early.
162    optional int32 min_battery_not_low_count = 3;
163    // Minimum # of "storage not low" jobs that must be ready in order to force
164    // the JMS to schedule things early.
165    optional int32 min_storage_not_low_count = 4;
166    // Minimum # of connectivity jobs that must be ready in order to force the
167    // JMS to schedule things early. 1 == Run connectivity jobs as soon as
168    // ready.
169    optional int32 min_connectivity_count = 5;
170    // Minimum # of content trigger jobs that must be ready in order to force
171    // the JMS to schedule things early.
172    optional int32 min_content_count = 6;
173    // Minimum # of jobs (with no particular constraints) for which the JMS will
174    // be happy running some work early. This (and thus the other min counts)
175    // is now set to 1, to prevent any batching at this level. Since we now do
176    // batching through doze, that is a much better mechanism.
177    optional int32 min_ready_jobs_count = 7;
178    // This is the job execution factor that is considered to be heavy use of
179    // the system.
180    optional double heavy_use_factor = 8;
181    // This is the job execution factor that is considered to be moderate use of
182    // the system.
183    optional double moderate_use_factor = 9;
184    // The number of MAX_JOB_CONTEXTS_COUNT we reserve for the foreground app.
185    optional int32 fg_job_count = 10;
186    // The maximum number of background jobs we allow when the system is in a
187    // normal memory state.
188    optional int32 bg_normal_job_count = 11;
189    // The maximum number of background jobs we allow when the system is in a
190    // moderate memory state.
191    optional int32 bg_moderate_job_count = 12;
192    // The maximum number of background jobs we allow when the system is in a
193    // low memory state.
194    optional int32 bg_low_job_count = 13;
195    // The maximum number of background jobs we allow when the system is in a
196    // critical memory state.
197    optional int32 bg_critical_job_count = 14;
198    // The maximum number of times we allow a job to have itself rescheduled
199    // before giving up on it, for standard jobs.
200    optional int32 max_standard_reschedule_count = 15;
201    // The maximum number of times we allow a job to have itself rescheduled
202    // before giving up on it, for jobs that are executing work.
203    optional int32 max_work_reschedule_count = 16;
204    // The minimum backoff time to allow for linear backoff.
205    optional int64 min_linear_backoff_time_ms = 17;
206    // The minimum backoff time to allow for exponential backoff.
207    optional int64 min_exp_backoff_time_ms = 18;
208    // How often we recalculate runnability based on apps' standby bucket
209    // assignment. This should be prime relative to common time interval lengths
210    // such as a quarter-hour or day, so that the heartbeat drifts relative to
211    // wall-clock milestones.
212    optional int64 standby_heartbeat_time_ms = 19;
213    // Mapping: standby bucket -> number of heartbeats between each sweep of
214    // that bucket's jobs.
215    // Bucket assignments as recorded in the JobStatus objects are normalized to
216    // be indices into this array, rather than the raw constants used by
217    // AppIdleHistory.
218    repeated int32 standby_beats = 20;
219    // The fraction of a job's running window that must pass before we
220    // consider running it when the network is congested.
221    optional double conn_congestion_delay_frac = 21;
222    // The fraction of a prefetch job's running window that must pass before
223    // we consider matching it against a metered network.
224    optional double conn_prefetch_relax_frac = 22;
225    // Whether to use heartbeats or rolling window for quota management. True
226    // will use heartbeats, false will use a rolling window.
227    optional bool use_heartbeats = 23;
228
229    message TimeController {
230        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
231
232        // Whether or not TimeController should skip setting wakeup alarms for jobs that aren't
233        // ready now.
234        optional bool skip_not_ready_jobs = 1;
235        // Whether or not TimeController will use a non-wakeup alarm for delay constraints.
236        optional bool use_non_wakeup_alarm_for_delay = 2;
237    }
238    optional TimeController time_controller = 25;
239
240    message QuotaController {
241        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
242
243        // How much time each app will have to run jobs within their standby bucket window.
244        optional int64 allowed_time_per_period_ms = 1;
245        // How much time the package should have before transitioning from out-of-quota to in-quota.
246        // This should not affect processing if the package is already in-quota.
247        optional int64 in_quota_buffer_ms = 2;
248        // The quota window size of the particular standby bucket. Apps in this standby bucket are
249        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
250        // WINDOW_SIZE_MS.
251        optional int64 active_window_size_ms = 3;
252        // The quota window size of the particular standby bucket. Apps in this standby bucket are
253        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
254        // WINDOW_SIZE_MS.
255        optional int64 working_window_size_ms = 4;
256        // The quota window size of the particular standby bucket. Apps in this standby bucket are
257        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
258        // WINDOW_SIZE_MS.
259        optional int64 frequent_window_size_ms = 5;
260        // The quota window size of the particular standby bucket. Apps in this standby bucket are
261        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
262        // WINDOW_SIZE_MS.
263        optional int64 rare_window_size_ms = 6;
264        // The maximum amount of time an app can have its jobs running within a 24 hour window.
265        optional int64 max_execution_time_ms = 7;
266        // The maximum number of jobs an app can run within this particular standby bucket's
267        // window size.
268        optional int32 max_job_count_active = 8;
269        // The maximum number of jobs an app can run within this particular standby bucket's
270        // window size.
271        optional int32 max_job_count_working = 9;
272        // The maximum number of jobs an app can run within this particular standby bucket's
273        // window size.
274        optional int32 max_job_count_frequent = 10;
275        // The maximum number of jobs an app can run within this particular standby bucket's
276        // window size.
277        optional int32 max_job_count_rare = 11;
278        // The period of time used to rate limit recently run jobs.
279        optional int32 rate_limiting_window_ms = 19;
280        // The maximum number of jobs that should be allowed to run in the past
281        // rate_limiting_window_ms.
282        optional int32 max_job_count_per_rate_limiting_window = 12;
283        // The maximum number of timing sessions an app can run within this particular standby
284        // bucket's window size.
285        optional int32 max_session_count_active = 13;
286        // The maximum number of timing sessions an app can run within this particular standby
287        // bucket's window size.
288        optional int32 max_session_count_working = 14;
289        // The maximum number of timing sessions an app can run within this particular standby
290        // bucket's window size.
291        optional int32 max_session_count_frequent = 15;
292        // The maximum number of timing sessions an app can run within this particular standby
293        // bucket's window size.
294        optional int32 max_session_count_rare = 16;
295        // The maximum number of timing sessions that should be allowed to run in the past
296        // rate_limiting_window_ms.
297        optional int32 max_session_count_per_rate_limiting_window = 17;
298        // Treat two distinct {@link TimingSession}s as the same if they start and end within this
299        // amount of time of each other.
300        optional int64 timing_session_coalescing_duration_ms = 18;
301    }
302    optional QuotaController quota_controller = 24;
303
304    // Max number of jobs, when screen is ON.
305    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_on = 26;
306
307    // Max number of jobs, when screen is OFF.
308    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_off = 27;
309
310    // In this time after screen turns on, we increase job concurrency.
311    optional int32 screen_off_job_concurrency_increase_delay_ms = 28;
312}
313
314// Next tag: 4
315message MaxJobCountsProto {
316    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
317
318    // Total number of jobs to run simultaneously.
319    optional int32 total_jobs = 1;
320
321    // Max number of BG (== owned by non-TOP apps) jobs to run simultaneously.
322    optional int32 max_bg = 2;
323
324    // We try to run at least this many BG (== owned by non-TOP apps) jobs, when there are any
325    // pending, rather than always running the TOTAL number of FG jobs.
326    optional int32 min_bg = 3;
327}
328
329// Next tag: 5
330message MaxJobCountsPerMemoryTrimLevelProto {
331    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
332
333    optional MaxJobCountsProto normal = 1;
334    optional MaxJobCountsProto moderate = 2;
335    optional MaxJobCountsProto low = 3;
336    optional MaxJobCountsProto critical = 4;
337}
338
339message StateControllerProto {
340    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
341
342    message BackgroundJobsController {
343        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
344
345        optional com.android.server.ForceAppStandbyTrackerProto force_app_standby_tracker = 1;
346
347        message TrackedJob {
348            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
349
350            optional JobStatusShortInfoProto info = 1;
351            optional int32 source_uid = 2;
352            optional string source_package_name = 3;
353            optional bool is_in_foreground = 4;
354            optional bool is_whitelisted = 5;
355            optional bool can_run_any_in_background = 6;
356            // If the constraints are satisfied, then the controller will mark
357            // the job as RUNNABLE, otherwise, it will be WAITING.
358            optional bool are_constraints_satisfied = 7;
359        }
360        repeated TrackedJob tracked_jobs = 2;
361    }
362    message BatteryController {
363        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
364
365        optional bool is_on_stable_power = 1;
366        optional bool is_battery_not_low = 2;
367
368        // Whether or not the controller is monitoring battery changes.
369        optional bool is_monitoring = 3;
370        // Only valid if is_monitoring is true.
371        optional int32 last_broadcast_sequence_number = 4;
372
373        message TrackedJob {
374            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
375
376            optional JobStatusShortInfoProto info = 1;
377            optional int32 source_uid = 2;
378        }
379        repeated TrackedJob tracked_jobs = 5;
380    }
381    message ConnectivityController {
382        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
383
384        optional bool is_connected = 1;
385
386        message TrackedJob {
387            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
388
389            optional JobStatusShortInfoProto info = 1;
390            optional int32 source_uid = 2;
391            optional .android.net.NetworkRequestProto required_network = 3;
392        }
393        repeated TrackedJob tracked_jobs = 2;
394    }
395    message ContentObserverController {
396        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
397
398        message TrackedJob {
399            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
400
401            optional JobStatusShortInfoProto info = 1;
402            optional int32 source_uid = 2;
403        }
404        repeated TrackedJob tracked_jobs = 1;
405
406        message Observer {
407            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
408
409            optional int32 user_id = 1;
410
411            message TriggerContentData {
412                option (.android.msg_privacy).dest = DEST_AUTOMATIC;
413
414                optional string uri = 1 [
415                    (.android.privacy).dest = DEST_EXPLICIT
416                ];
417                optional int32 flags = 2;
418
419                // A
420                // com.android.server.job.controllers.ContentObserverController.JobInstance
421                // object.
422                message JobInstance {
423                    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
424
425                    optional JobStatusShortInfoProto info = 1;
426                    optional int32 source_uid = 2;
427
428                    optional int64 trigger_content_update_delay_ms = 3;
429                    optional int64 trigger_content_max_delay_ms = 4;
430
431                    repeated string changed_authorities = 5 [
432                        (.android.privacy).dest = DEST_EXPLICIT
433                    ];
434                    repeated string changed_uris = 6 [
435                        (.android.privacy).dest = DEST_EXPLICIT
436                    ];
437                }
438                repeated JobInstance jobs = 3;
439            }
440            repeated TriggerContentData triggers = 2;
441        }
442        repeated Observer observers = 2;
443    }
444    message DeviceIdleJobsController {
445        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
446
447        // True when in device idle mode.
448        optional bool is_device_idle_mode = 1;
449
450        message TrackedJob {
451            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
452
453            optional JobStatusShortInfoProto info = 1;
454            optional int32 source_uid = 2;
455            optional string source_package_name = 3;
456            // If the constraints are satisfied, then the controller will mark
457            // the job as RUNNABLE, otherwise, it will be WAITING.
458            optional bool are_constraints_satisfied = 4;
459            optional bool is_doze_whitelisted = 5;
460            // A job that is exempted from Doze when the app is temp whitelisted
461            // or in the foreground.
462            optional bool is_allowed_in_doze = 6;
463        }
464        repeated TrackedJob tracked_jobs = 2;
465    }
466    message IdleController {
467        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
468
469        optional bool is_idle = 1;
470
471        message TrackedJob {
472            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
473
474            optional JobStatusShortInfoProto info = 1;
475            optional int32 source_uid = 2;
476        }
477        repeated TrackedJob tracked_jobs = 2;
478    }
479    message QuotaController {
480        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
481
482        optional bool is_charging = 1;
483        optional bool is_in_parole = 2;
484        optional int64 elapsed_realtime = 6;
485
486        // List of UIDs currently in the foreground.
487        repeated int32 foreground_uids = 3;
488
489        message TrackedJob {
490            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
491
492            optional JobStatusShortInfoProto info = 1;
493            optional int32 source_uid = 2;
494            optional JobStatusDumpProto.Bucket effective_standby_bucket = 3;
495            // If the job started while the app was in the TOP state.
496            optional bool is_top_started_job = 4;
497            optional bool has_quota = 5;
498            // The amount of time that this job has remaining in its quota. This
499            // can be negative if the job is out of quota.
500            optional int64 remaining_quota_ms = 6;
501        }
502        repeated TrackedJob tracked_jobs = 4;
503
504        message AlarmListener {
505            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
506
507            // Whether the listener is waiting for an alarm or not.
508            optional bool is_waiting = 1;
509            // The time at which the alarm should go off, in the elapsed realtime timebase. Only
510            // valid if is_waiting is true.
511            optional int64 trigger_time_elapsed = 2;
512        }
513
514        message ExecutionStats {
515            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
516
517            optional JobStatusDumpProto.Bucket standby_bucket = 1;
518
519            // The time after which this record should be considered invalid (out of date), in the
520            // elapsed realtime timebase.
521            optional int64 expiration_time_elapsed = 2;
522            optional int64 window_size_ms = 3;
523
524            optional int32 job_count_limit = 14;
525            optional int32 session_count_limit = 15;
526
527            // The total amount of time the app ran in its respective bucket window size.
528            optional int64 execution_time_in_window_ms = 4;
529            optional int32 bg_job_count_in_window = 5;
530
531            // The total amount of time the app ran in the last
532            // {@link QuotaController#MAX_PERIOD_MS}.
533            optional int64 execution_time_in_max_period_ms = 6;
534            optional int32 bg_job_count_in_max_period = 7;
535
536            // The number of {@link TimingSession}s within the bucket window size. This will include
537            // sessions that started before the window as long as they end within the window.
538            optional int32 session_count_in_window = 11;
539
540            // The time after which the app will be under the bucket quota. This is only valid if
541            // execution_time_in_window_ms >=
542            //   ConstantsProto.QuotaController.allowed_time_per_period_ms
543            // or
544            // execution_time_in_max_period_ms >=
545            //   ConstantsProto.QuotaController.max_execution_time_ms
546            // or
547            // bg_job_count_in_window >= job_count_limit
548            // or
549            // session_count_in_window >= session_count_limit.
550            optional int64 in_quota_time_elapsed = 8;
551
552            // The time after which job_count_in_rate_limiting_window should be considered invalid,
553            // in the elapsed realtime timebase.
554            optional int64 job_count_expiration_time_elapsed = 9;
555
556            // The number of jobs that ran in at least the last
557            // ConstantsProto.QuotaController.rate_limiting_window_ms.
558            // It may contain a few stale entries since cleanup won't happen exactly every
559            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be
560            // considered valid before elapsed realtime has reached
561            // job_count_expiration_time_elapsed.
562            optional int32 job_count_in_rate_limiting_window = 10;
563
564            // The time after which {@link #timingSessionCountInAllowedTime} should be considered
565            // invalid, in the elapsed realtime timebase.
566            optional int64 session_count_expiration_time_elapsed = 12;
567
568            // The number of {@link TimingSession}s that ran in at least the last
569            // ConstantsProto.QuotaController.rate_limiting_window_ms. It may contain a few stale
570            // entries since cleanup won't happen exactly every
571            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be considered
572            // valid before elapsed realtime has reached session_count_expiration_time_elapsed.
573            optional int32 session_count_in_rate_limiting_window = 13;
574        }
575
576        message Package {
577            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
578
579            optional int32 user_id = 1;
580            optional string name = 2;
581        }
582
583        message TimingSession {
584            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
585
586            optional int64 start_time_elapsed = 1;
587            optional int64 end_time_elapsed = 2;
588            // The number of background jobs that ran during this session.
589            optional int32 bg_job_count = 3;
590        }
591
592        message Timer {
593            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
594
595            optional Package pkg = 1;
596            // True if the Timer is actively tracking jobs.
597            optional bool is_active = 2;
598            // The time this timer last became active. Only valid if is_active is true.
599            optional int64 start_time_elapsed = 3;
600            // How many background jobs are currently running. Valid only if the device is_active
601            // is true.
602            optional int32 bg_job_count = 4;
603            // All of the jobs that the Timer is currently tracking.
604            repeated JobStatusShortInfoProto running_jobs = 5;
605        }
606
607        message PackageStats {
608            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
609
610            optional Package pkg = 1;
611
612            optional Timer timer = 2;
613
614            repeated TimingSession saved_sessions = 3;
615
616            repeated ExecutionStats execution_stats = 4;
617
618            optional AlarmListener in_quota_alarm_listener = 5;
619        }
620        repeated PackageStats package_stats = 5;
621    }
622    message StorageController {
623        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
624
625        optional bool is_storage_not_low = 1;
626        optional int32 last_broadcast_sequence_number = 2;
627
628        message TrackedJob {
629            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
630
631            optional JobStatusShortInfoProto info = 1;
632            optional int32 source_uid = 2;
633        }
634        repeated TrackedJob tracked_jobs = 3;
635    }
636    message TimeController {
637        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
638
639        optional int64 now_elapsed_realtime = 1;
640        optional int64 time_until_next_delay_alarm_ms = 2;
641        optional int64 time_until_next_deadline_alarm_ms = 3;
642
643        message TrackedJob {
644            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
645
646            optional JobStatusShortInfoProto info = 1;
647            optional int32 source_uid = 2;
648
649            optional bool has_timing_delay_constraint = 3;
650            // Only valid if has_timing_delay_constraint is true. Can be
651            // negative if the delay is in the past.
652            optional int64 delay_time_remaining_ms = 4;
653
654            optional bool has_deadline_constraint = 5;
655            // Only valid if has_timing_delay_constraint is true. Can be
656            // negative in certain situations.
657            optional int64 time_remaining_until_deadline_ms = 6;
658        }
659        repeated TrackedJob tracked_jobs = 4;
660    }
661    oneof controller {
662        BackgroundJobsController background = 1;
663        BatteryController battery = 2;
664        ConnectivityController connectivity = 3;
665        ContentObserverController content_observer = 4;
666        DeviceIdleJobsController device_idle = 5;
667        IdleController idle = 6;
668        QuotaController quota = 9;
669        StorageController storage = 7;
670        TimeController time = 8;
671        // Next tag: 10
672    }
673}
674
675// A com.android.server.job.JobPackageTracker.DataSet object.
676message DataSetProto {
677    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
678
679    optional int64 start_clock_time_ms = 1;
680    // How much time has elapsed since the DataSet was instantiated.
681    optional int64 elapsed_time_ms = 2;
682    optional int64 period_ms = 3;
683
684    // Represents a com.android.server.job.JobPackageTracker.PackageEntry
685    // object, but with some extra data.
686    message PackageEntryProto {
687        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
688
689        optional int32 uid = 1;
690        optional string package_name = 2;
691
692        message State {
693            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
694
695            optional int64 duration_ms = 1;
696            optional int32 count = 2;
697        }
698        optional State pending_state = 3;
699        optional State active_state = 4;
700        optional State active_top_state = 5;
701
702        // True if the PackageEntry is currently pending or has been pending in
703        // the past.
704        optional bool pending = 6;
705        // True if the PackageEntry is currently active or has been active in
706        // the past.
707        optional bool active = 7;
708        // True if the PackageEntry is currently active top or has been active
709        // top in the past.
710        optional bool active_top = 8;
711
712        message StopReasonCount {
713            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
714
715            optional .android.app.job.StopReasonEnum reason = 1;
716            optional int32 count = 2;
717        }
718        repeated StopReasonCount stop_reasons = 9;
719    }
720    repeated PackageEntryProto package_entries = 4;
721
722    optional int32 max_concurrency = 5;
723    optional int32 max_foreground_concurrency = 6;
724}
725
726// Dump from com.android.server.job.GrantedUriPermissions.
727message GrantedUriPermissionsDumpProto {
728    option (.android.msg_privacy).dest = DEST_EXPLICIT;
729
730    optional int32 flags = 1 [ (.android.privacy).dest = DEST_AUTOMATIC ];
731    optional int32 source_user_id = 2 [
732        (.android.privacy).dest = DEST_AUTOMATIC
733    ];
734    optional string tag = 3;
735    optional string permission_owner = 4;
736    repeated string uris = 5;
737}
738
739message JobPackageTrackerDumpProto {
740    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
741
742    repeated DataSetProto historical_stats = 1;
743    optional DataSetProto current_stats = 2;
744}
745
746message JobPackageHistoryProto {
747    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
748
749    enum Event {
750        UNKNOWN = 0;
751        START_JOB = 1;
752        STOP_JOB = 2;
753        START_PERIODIC_JOB = 3;
754        STOP_PERIODIC_JOB = 4;
755    }
756    message HistoryEvent {
757        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
758
759        optional Event event = 1;
760        optional int64 time_since_event_ms = 2;
761        optional int32 uid = 3;
762        // Job IDs can technically be negative.
763        optional int32 job_id = 4;
764        optional string tag = 5;
765        // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events.
766        optional .android.app.job.StopReasonEnum stop_reason = 6;
767    }
768    repeated HistoryEvent history_event = 1;
769}
770
771message JobStatusShortInfoProto {
772    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
773
774    optional int32 calling_uid = 1;
775    // Job IDs can technically be negative.
776    optional int32 job_id = 2;
777    optional string battery_name = 3;
778}
779
780// Dump from a com.android.server.job.controllers.JobStatus object.
781message JobStatusDumpProto {
782    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
783
784    // The UID that scheduled the job.
785    optional int32 calling_uid = 1;
786    optional string tag = 2;
787
788    // The UID for which the job is being run.
789    optional int32 source_uid = 3;
790    optional int32 source_user_id = 4;
791    // The package for which the job is being run.
792    optional string source_package_name = 5;
793
794    // Custom dump of android.app.job.JobInfo object.
795    message JobInfo {
796        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
797
798        optional .android.content.ComponentNameProto service = 1;
799
800        optional bool is_periodic = 2;
801        // Only valid if is_periodic is true.
802        optional int64 period_interval_ms = 3;
803        // Only valid if is_periodic is true.
804        optional int64 period_flex_ms = 4;
805
806        optional bool is_persisted = 5;
807        optional sint32 priority = 6;
808        optional int32 flags = 7;
809
810        optional bool requires_charging = 8;
811        optional bool requires_battery_not_low = 9;
812        optional bool requires_device_idle = 10;
813
814        message TriggerContentUri {
815            optional int32 flags = 1 [
816                (.android.privacy).dest = DEST_AUTOMATIC
817            ];
818            optional string uri = 2 [ (.android.privacy).dest = DEST_EXPLICIT ];
819        }
820        repeated TriggerContentUri trigger_content_uris = 11;
821        optional int64 trigger_content_update_delay_ms = 12;
822        optional int64 trigger_content_max_delay_ms = 13;
823
824        optional .android.os.PersistableBundleProto extras = 14;
825        optional .android.os.BundleProto transient_extras = 15;
826        // ClipData of information that is returned to the application at
827        // execution time, but not persisted by the system. This is provided by
828        // the app and the main purpose of providing a ClipData is to allow
829        // granting of URI permissions for data associated with the clip.  The
830        // exact kind of permission grant to perform is specified in the flags
831        // field.
832        optional .android.content.ClipDataProto clip_data = 16;
833
834        optional GrantedUriPermissionsDumpProto granted_uri_permissions = 17;
835
836        optional .android.net.NetworkRequestProto required_network = 18;
837
838        optional int64 total_network_bytes = 19;
839
840        optional int64 min_latency_ms = 20;
841        optional int64 max_execution_delay_ms = 21;
842
843        message Backoff {
844            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
845
846            enum Policy {
847                BACKOFF_POLICY_LINEAR = 0;
848                BACKOFF_POLICY_EXPONENTIAL = 1;
849            }
850            optional Policy policy = 1;
851            optional int64 initial_backoff_ms = 2;
852        }
853        optional Backoff backoff_policy = 22;
854
855        optional bool has_early_constraint = 23;
856        optional bool has_late_constraint = 24;
857    }
858    optional JobInfo job_info = 6;
859
860    repeated ConstraintEnum required_constraints = 7;
861    repeated ConstraintEnum satisfied_constraints = 8;
862    repeated ConstraintEnum unsatisfied_constraints = 9;
863    optional bool is_doze_whitelisted = 10;
864    optional bool is_uid_active = 26;
865
866    message ImplicitConstraints {
867        // The device isn't Dozing or this job will be in the foreground. This
868        // implicit constraint must be satisfied for the job to run.
869        optional bool is_not_dozing = 1;
870        // The job is not restricted from running in the background (due to
871        // Battery Saver). This implicit constraint must be satisfied for the
872        // job to run.
873        optional bool is_not_restricted_in_bg = 2;
874    }
875    optional ImplicitConstraints implicit_constraints = 25;
876
877    enum TrackingController {
878        TRACKING_BATTERY = 0;
879        TRACKING_CONNECTIVITY = 1;
880        TRACKING_CONTENT = 2;
881        TRACKING_IDLE = 3;
882        TRACKING_STORAGE = 4;
883        TRACKING_TIME = 5;
884        TRACKING_QUOTA = 6;
885    }
886    // Controllers that are currently tracking the job.
887    repeated TrackingController tracking_controllers = 11;
888
889    repeated string changed_authorities = 12 [
890        (.android.privacy).dest = DEST_EXPLICIT
891    ];
892    repeated string changed_uris = 13 [
893        (.android.privacy).dest = DEST_EXPLICIT
894    ];
895
896    optional .android.net.NetworkProto network = 14;
897
898    // Only the desired data from an android.app.job.JobWorkItem object.
899    message JobWorkItem {
900        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
901
902        optional int32 work_id = 1;
903        optional int32 delivery_count = 2;
904        optional .android.content.IntentProto intent = 3;
905        optional GrantedUriPermissionsDumpProto uri_grants = 4;
906    }
907    repeated JobWorkItem pending_work = 15;
908    repeated JobWorkItem executing_work = 16;
909
910    enum Bucket {
911        ACTIVE = 0;
912        WORKING_SET = 1;
913        FREQUENT = 2;
914        RARE = 3;
915        NEVER = 4;
916    }
917    optional Bucket standby_bucket = 17;
918    optional bool is_exempted_from_app_standby = 27;
919
920    optional int64 enqueue_duration_ms = 18;
921    // Can be negative if the earliest runtime deadline has passed.
922    optional sint64 time_until_earliest_runtime_ms = 19;
923    // Can be negative if the latest runtime deadline has passed.
924    optional sint64 time_until_latest_runtime_ms = 20;
925
926    optional int32 num_failures = 21;
927
928    optional int64 last_successful_run_time = 22;
929    optional int64 last_failed_run_time = 23;
930
931    optional int64 internal_flags = 24;
932
933    // Next tag: 28
934}
935
936// Dump from com.android.server.job.JobConcurrencyManager.
937// Next tag: 7
938message JobConcurrencyManagerProto {
939    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
940
941    // Whether the device is interactive (== screen on) now or not.
942    optional bool current_interactive = 1;
943    // Similar to current_interactive, screen on or not, but it takes into account the off timeout.
944    optional bool effective_interactive = 2;
945    // How many milliseconds have passed since the last screen on. (i.e. 1000 == 1 sec ago)
946    optional int64 time_since_last_screen_on_ms = 3;
947    // How many milliseconds have passed since the last screen off. (i.e. 1000 == 1 sec ago)
948    optional int64 time_since_last_screen_off_ms = 4;
949    // Current max number of jobs.
950    optional JobCountTrackerProto job_count_tracker = 5;
951    // Current memory trim level.
952    optional int32 memory_trim_level = 6;
953}
954
955// Dump from com.android.server.job.JobConcurrencyManager.JobCountTracker.
956// Next tag: 8
957message JobCountTrackerProto {
958    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
959
960    // Number of total jos that can run simultaneously.
961    optional int32 config_num_max_total_jobs = 1;
962    // Number of background jos that can run simultaneously.
963    optional int32 config_num_max_bg_jobs = 2;
964    // Out of total jobs, this many background jobs should be guaranteed to be executed, even if
965    // there are the config_num_max_total_jobs count of foreground jobs pending.
966    optional int32 config_num_min_bg_jobs = 3;
967
968    // Number of running foreground jobs.
969    optional int32 num_running_fg_jobs = 4;
970    // Number of running background jobs.
971    optional int32 num_running_bg_jobs = 5;
972
973    // Number of pending foreground jobs.
974    optional int32 num_pending_fg_jobs = 6;
975    // Number of pending background jobs.
976    optional int32 num_pending_bg_jobs = 7;
977}
978