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