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/appstatetracker.proto";
32import "frameworks/base/core/proto/android/server/job/enums.proto";
33import "frameworks/base/core/proto/android/server/statlogger.proto";
34import "frameworks/base/core/proto/android/privacy.proto";
35import "frameworks/base/core/proto/android/util/quotatracker.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.StopReasonEnum 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        // Next tag: 24
317    }
318    optional QuotaController quota_controller = 24;
319
320    message TimeController {
321        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
322
323        // Whether or not TimeController should skip setting wakeup alarms for jobs that aren't
324        // ready now.
325        reserved 1; // skip_not_ready_jobs
326        // Whether or not TimeController will use a non-wakeup alarm for delay constraints.
327        optional bool use_non_wakeup_alarm_for_delay = 2;
328    }
329    optional TimeController time_controller = 25;
330
331    // Max number of jobs, when screen is ON.
332    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_on = 26;
333
334    // Max number of jobs, when screen is OFF.
335    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_off = 27;
336
337    // In this time after screen turns on, we increase job concurrency.
338    optional int32 screen_off_job_concurrency_increase_delay_ms = 28;
339
340    // Next tag: 36
341}
342
343// Next tag: 4
344message MaxJobCountsProto {
345    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
346
347    // Total number of jobs to run simultaneously.
348    optional int32 total_jobs = 1;
349
350    // Max number of BG (== owned by non-TOP apps) jobs to run simultaneously.
351    optional int32 max_bg = 2;
352
353    // We try to run at least this many BG (== owned by non-TOP apps) jobs, when there are any
354    // pending, rather than always running the TOTAL number of FG jobs.
355    optional int32 min_bg = 3;
356}
357
358// Next tag: 5
359message MaxJobCountsPerMemoryTrimLevelProto {
360    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
361
362    optional MaxJobCountsProto normal = 1;
363    optional MaxJobCountsProto moderate = 2;
364    optional MaxJobCountsProto low = 3;
365    optional MaxJobCountsProto critical = 4;
366}
367
368message StateControllerProto {
369    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
370
371    message BackgroundJobsController {
372        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
373
374        optional com.android.server.AppStateTrackerProto app_state_tracker = 1;
375
376        message TrackedJob {
377            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
378
379            optional JobStatusShortInfoProto info = 1;
380            optional int32 source_uid = 2;
381            optional string source_package_name = 3;
382            optional bool is_in_foreground = 4;
383            optional bool is_whitelisted = 5;
384            optional bool can_run_any_in_background = 6;
385            // If the constraints are satisfied, then the controller will mark
386            // the job as RUNNABLE, otherwise, it will be WAITING.
387            optional bool are_constraints_satisfied = 7;
388        }
389        repeated TrackedJob tracked_jobs = 2;
390    }
391    message BatteryController {
392        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
393
394        optional bool is_on_stable_power = 1;
395        optional bool is_battery_not_low = 2;
396
397        // Whether or not the controller is monitoring battery changes.
398        optional bool is_monitoring = 3;
399        // Only valid if is_monitoring is true.
400        optional int32 last_broadcast_sequence_number = 4;
401
402        message TrackedJob {
403            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
404
405            optional JobStatusShortInfoProto info = 1;
406            optional int32 source_uid = 2;
407        }
408        repeated TrackedJob tracked_jobs = 5;
409    }
410    message ConnectivityController {
411        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
412
413        reserved 1; // is_connected
414
415        message TrackedJob {
416            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
417
418            optional JobStatusShortInfoProto info = 1;
419            optional int32 source_uid = 2;
420            optional .android.net.NetworkRequestProto required_network = 3;
421        }
422        repeated TrackedJob tracked_jobs = 2;
423
424        // List of the UIDs that ConnectivityController has requested that NetworkPolicyManager
425        // grant an exception to in the app standby chain.
426        repeated int32 requested_standby_exception_uids = 3;
427
428        repeated .android.net.NetworkProto available_networks = 4;
429    }
430    message ContentObserverController {
431        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
432
433        message TrackedJob {
434            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
435
436            optional JobStatusShortInfoProto info = 1;
437            optional int32 source_uid = 2;
438        }
439        repeated TrackedJob tracked_jobs = 1;
440
441        message Observer {
442            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
443
444            optional int32 user_id = 1;
445
446            message TriggerContentData {
447                option (.android.msg_privacy).dest = DEST_AUTOMATIC;
448
449                optional string uri = 1 [
450                    (.android.privacy).dest = DEST_EXPLICIT
451                ];
452                optional int32 flags = 2;
453
454                // A
455                // com.android.server.job.controllers.ContentObserverController.JobInstance
456                // object.
457                message JobInstance {
458                    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
459
460                    optional JobStatusShortInfoProto info = 1;
461                    optional int32 source_uid = 2;
462
463                    optional int64 trigger_content_update_delay_ms = 3;
464                    optional int64 trigger_content_max_delay_ms = 4;
465
466                    repeated string changed_authorities = 5 [
467                        (.android.privacy).dest = DEST_EXPLICIT
468                    ];
469                    repeated string changed_uris = 6 [
470                        (.android.privacy).dest = DEST_EXPLICIT
471                    ];
472                }
473                repeated JobInstance jobs = 3;
474            }
475            repeated TriggerContentData triggers = 2;
476        }
477        repeated Observer observers = 2;
478    }
479    message DeviceIdleJobsController {
480        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
481
482        // True when in device idle mode.
483        optional bool is_device_idle_mode = 1;
484
485        message TrackedJob {
486            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
487
488            optional JobStatusShortInfoProto info = 1;
489            optional int32 source_uid = 2;
490            optional string source_package_name = 3;
491            // If the constraints are satisfied, then the controller will mark
492            // the job as RUNNABLE, otherwise, it will be WAITING.
493            optional bool are_constraints_satisfied = 4;
494            optional bool is_doze_whitelisted = 5;
495            // A job that is exempted from Doze when the app is temp whitelisted
496            // or in the foreground.
497            optional bool is_allowed_in_doze = 6;
498        }
499        repeated TrackedJob tracked_jobs = 2;
500    }
501    message IdleController {
502        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
503
504        optional bool is_idle = 1;
505
506        message TrackedJob {
507            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
508
509            optional JobStatusShortInfoProto info = 1;
510            optional int32 source_uid = 2;
511        }
512        repeated TrackedJob tracked_jobs = 2;
513
514        message IdlenessTracker {
515            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
516
517            message CarIdlenessTracker {
518                option (.android.msg_privacy).dest = DEST_AUTOMATIC;
519
520                optional bool is_idle = 1;
521                optional bool is_garage_mode_on = 2;
522            }
523
524            message DeviceIdlenessTracker {
525                option (.android.msg_privacy).dest = DEST_AUTOMATIC;
526
527                optional bool is_idle = 1;
528                optional bool is_screen_on = 2;
529                optional bool is_dock_idle = 3;
530                optional bool in_car_mode = 4;
531            }
532
533            oneof active_tracker {
534                DeviceIdlenessTracker device_idleness_tracker = 1;
535                CarIdlenessTracker car_idleness_tracker = 2;
536            }
537        }
538        optional IdlenessTracker idleness_tracker = 3;
539    }
540    message QuotaController {
541        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
542
543        optional bool is_charging = 1;
544        reserved 2; // is_in_parole
545        optional int64 elapsed_realtime = 6;
546
547        // List of UIDs currently in the foreground.
548        repeated int32 foreground_uids = 3;
549
550        message TrackedJob {
551            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
552
553            optional JobStatusShortInfoProto info = 1;
554            optional int32 source_uid = 2;
555            optional JobStatusDumpProto.Bucket effective_standby_bucket = 3;
556            // If the job started while the app was in the TOP state.
557            optional bool is_top_started_job = 4;
558            optional bool has_quota = 5;
559            // The amount of time that this job has remaining in its quota. This
560            // can be negative if the job is out of quota.
561            optional int64 remaining_quota_ms = 6;
562        }
563        repeated TrackedJob tracked_jobs = 4;
564
565        message AlarmListener {
566            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
567
568            // Whether the listener is waiting for an alarm or not.
569            optional bool is_waiting = 1;
570            // The time at which the alarm should go off, in the elapsed realtime timebase. Only
571            // valid if is_waiting is true.
572            optional int64 trigger_time_elapsed = 2;
573        }
574
575        message ExecutionStats {
576            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
577
578            optional JobStatusDumpProto.Bucket standby_bucket = 1;
579
580            // The time after which this record should be considered invalid (out of date), in the
581            // elapsed realtime timebase.
582            optional int64 expiration_time_elapsed = 2;
583            optional int64 window_size_ms = 3;
584
585            optional int32 job_count_limit = 14;
586            optional int32 session_count_limit = 15;
587
588            // The total amount of time the app ran in its respective bucket window size.
589            optional int64 execution_time_in_window_ms = 4;
590            optional int32 bg_job_count_in_window = 5;
591
592            // The total amount of time the app ran in the last
593            // {@link QuotaController#MAX_PERIOD_MS}.
594            optional int64 execution_time_in_max_period_ms = 6;
595            optional int32 bg_job_count_in_max_period = 7;
596
597            // The number of {@link TimingSession}s within the bucket window size. This will include
598            // sessions that started before the window as long as they end within the window.
599            optional int32 session_count_in_window = 11;
600
601            // The time after which the app will be under the bucket quota. This is only valid if
602            // execution_time_in_window_ms >=
603            //   ConstantsProto.QuotaController.allowed_time_per_period_ms
604            // or
605            // execution_time_in_max_period_ms >=
606            //   ConstantsProto.QuotaController.max_execution_time_ms
607            // or
608            // bg_job_count_in_window >= job_count_limit
609            // or
610            // session_count_in_window >= session_count_limit.
611            optional int64 in_quota_time_elapsed = 8;
612
613            // The time after which job_count_in_rate_limiting_window should be considered invalid,
614            // in the elapsed realtime timebase.
615            optional int64 job_count_expiration_time_elapsed = 9;
616
617            // The number of jobs that ran in at least the last
618            // ConstantsProto.QuotaController.rate_limiting_window_ms.
619            // It may contain a few stale entries since cleanup won't happen exactly every
620            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be
621            // considered valid before elapsed realtime has reached
622            // job_count_expiration_time_elapsed.
623            optional int32 job_count_in_rate_limiting_window = 10;
624
625            // The time after which {@link #timingSessionCountInAllowedTime} should be considered
626            // invalid, in the elapsed realtime timebase.
627            optional int64 session_count_expiration_time_elapsed = 12;
628
629            // The number of {@link TimingSession}s that ran in at least the last
630            // ConstantsProto.QuotaController.rate_limiting_window_ms. It may contain a few stale
631            // entries since cleanup won't happen exactly every
632            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be considered
633            // valid before elapsed realtime has reached session_count_expiration_time_elapsed.
634            optional int32 session_count_in_rate_limiting_window = 13;
635        }
636
637        message Package {
638            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
639
640            optional int32 user_id = 1;
641            optional string name = 2;
642        }
643
644        message TimingSession {
645            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
646
647            optional int64 start_time_elapsed = 1;
648            optional int64 end_time_elapsed = 2;
649            // The number of background jobs that ran during this session.
650            optional int32 bg_job_count = 3;
651        }
652
653        message Timer {
654            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
655
656            optional Package pkg = 1;
657            // True if the Timer is actively tracking jobs.
658            optional bool is_active = 2;
659            // The time this timer last became active. Only valid if is_active is true.
660            optional int64 start_time_elapsed = 3;
661            // How many background jobs are currently running. Valid only if is_active is true.
662            optional int32 bg_job_count = 4;
663            // All of the jobs that the Timer is currently tracking.
664            repeated JobStatusShortInfoProto running_jobs = 5;
665        }
666
667        message PackageStats {
668            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
669
670            optional Package pkg = 1;
671
672            optional Timer timer = 2;
673
674            repeated TimingSession saved_sessions = 3;
675
676            repeated ExecutionStats execution_stats = 4;
677
678            reserved 5; // in_quota_alarm_listener
679        }
680        repeated PackageStats package_stats = 5;
681
682        // Set of package names for each UID.
683        message UidPackageMapping {
684            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
685
686            optional int32 uid = 1;
687            repeated string package_names = 2;
688        }
689        repeated UidPackageMapping uid_to_package_cache = 7;
690
691        message InQuotaAlarmListener {
692            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
693
694            // The time at which the alarm is set to go off, in the elapsed realtime timebase.
695            optional int64 trigger_time_elapsed = 1;
696
697            message Alarm {
698                option (.android.msg_privacy).dest = DEST_AUTOMATIC;
699
700                optional Package pkg = 1;
701
702                // The time at which the package will be in quota, in the elapsed realtime timebase.
703                optional int64 in_quota_time_elapsed = 2;
704            }
705            repeated Alarm alarms = 2;
706        }
707        optional InQuotaAlarmListener in_quota_alarm_listener = 8;
708
709        // Next tag: 9
710    }
711    message StorageController {
712        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
713
714        optional bool is_storage_not_low = 1;
715        optional int32 last_broadcast_sequence_number = 2;
716
717        message TrackedJob {
718            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
719
720            optional JobStatusShortInfoProto info = 1;
721            optional int32 source_uid = 2;
722        }
723        repeated TrackedJob tracked_jobs = 3;
724    }
725    message TimeController {
726        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
727
728        optional int64 now_elapsed_realtime = 1;
729        optional int64 time_until_next_delay_alarm_ms = 2;
730        optional int64 time_until_next_deadline_alarm_ms = 3;
731
732        message TrackedJob {
733            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
734
735            optional JobStatusShortInfoProto info = 1;
736            optional int32 source_uid = 2;
737
738            optional bool has_timing_delay_constraint = 3;
739            // Only valid if has_timing_delay_constraint is true. Can be
740            // negative if the delay is in the past.
741            optional int64 delay_time_remaining_ms = 4;
742
743            optional bool has_deadline_constraint = 5;
744            // Only valid if has_timing_delay_constraint is true. Can be
745            // negative in certain situations.
746            optional int64 time_remaining_until_deadline_ms = 6;
747        }
748        repeated TrackedJob tracked_jobs = 4;
749    }
750    oneof controller {
751        BackgroundJobsController background = 1;
752        BatteryController battery = 2;
753        ConnectivityController connectivity = 3;
754        ContentObserverController content_observer = 4;
755        DeviceIdleJobsController device_idle = 5;
756        IdleController idle = 6;
757        QuotaController quota = 9;
758        StorageController storage = 7;
759        TimeController time = 8;
760        // Next tag: 10
761    }
762}
763
764// A com.android.server.job.JobPackageTracker.DataSet object.
765message DataSetProto {
766    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
767
768    optional int64 start_clock_time_ms = 1;
769    // How much time has elapsed since the DataSet was instantiated.
770    optional int64 elapsed_time_ms = 2;
771    optional int64 period_ms = 3;
772
773    // Represents a com.android.server.job.JobPackageTracker.PackageEntry
774    // object, but with some extra data.
775    message PackageEntryProto {
776        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
777
778        optional int32 uid = 1;
779        optional string package_name = 2;
780
781        message State {
782            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
783
784            optional int64 duration_ms = 1;
785            optional int32 count = 2;
786        }
787        optional State pending_state = 3;
788        optional State active_state = 4;
789        optional State active_top_state = 5;
790
791        // True if the PackageEntry is currently pending or has been pending in
792        // the past.
793        optional bool pending = 6;
794        // True if the PackageEntry is currently active or has been active in
795        // the past.
796        optional bool active = 7;
797        // True if the PackageEntry is currently active top or has been active
798        // top in the past.
799        optional bool active_top = 8;
800
801        message StopReasonCount {
802            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
803
804            optional .android.app.job.StopReasonEnum reason = 1;
805            optional int32 count = 2;
806        }
807        repeated StopReasonCount stop_reasons = 9;
808    }
809    repeated PackageEntryProto package_entries = 4;
810
811    optional int32 max_concurrency = 5;
812    optional int32 max_foreground_concurrency = 6;
813}
814
815// Dump from com.android.server.job.GrantedUriPermissions.
816message GrantedUriPermissionsDumpProto {
817    option (.android.msg_privacy).dest = DEST_EXPLICIT;
818
819    optional int32 flags = 1 [ (.android.privacy).dest = DEST_AUTOMATIC ];
820    optional int32 source_user_id = 2 [
821        (.android.privacy).dest = DEST_AUTOMATIC
822    ];
823    optional string tag = 3;
824    optional string permission_owner = 4;
825    repeated string uris = 5;
826}
827
828message JobPackageTrackerDumpProto {
829    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
830
831    repeated DataSetProto historical_stats = 1;
832    optional DataSetProto current_stats = 2;
833}
834
835message JobPackageHistoryProto {
836    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
837
838    enum Event {
839        UNKNOWN = 0;
840        START_JOB = 1;
841        STOP_JOB = 2;
842        START_PERIODIC_JOB = 3;
843        STOP_PERIODIC_JOB = 4;
844    }
845    message HistoryEvent {
846        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
847
848        optional Event event = 1;
849        optional int64 time_since_event_ms = 2;
850        optional int32 uid = 3;
851        // Job IDs can technically be negative.
852        optional int32 job_id = 4;
853        optional string tag = 5;
854        // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events.
855        optional .android.app.job.StopReasonEnum stop_reason = 6;
856    }
857    repeated HistoryEvent history_event = 1;
858}
859
860message JobStatusShortInfoProto {
861    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
862
863    optional int32 calling_uid = 1;
864    // Job IDs can technically be negative.
865    optional int32 job_id = 2;
866    optional string battery_name = 3;
867}
868
869// Dump from a com.android.server.job.controllers.JobStatus object.
870message JobStatusDumpProto {
871    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
872
873    // The UID that scheduled the job.
874    optional int32 calling_uid = 1;
875    optional string tag = 2;
876
877    // The UID for which the job is being run.
878    optional int32 source_uid = 3;
879    optional int32 source_user_id = 4;
880    // The package for which the job is being run.
881    optional string source_package_name = 5;
882
883    // Custom dump of android.app.job.JobInfo object.
884    message JobInfo {
885        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
886
887        optional .android.content.ComponentNameProto service = 1;
888
889        optional bool is_periodic = 2;
890        // Only valid if is_periodic is true.
891        optional int64 period_interval_ms = 3;
892        // Only valid if is_periodic is true.
893        optional int64 period_flex_ms = 4;
894
895        optional bool is_persisted = 5;
896        optional sint32 priority = 6;
897        optional int32 flags = 7;
898
899        optional bool requires_charging = 8;
900        optional bool requires_battery_not_low = 9;
901        optional bool requires_device_idle = 10;
902
903        message TriggerContentUri {
904            optional int32 flags = 1 [
905                (.android.privacy).dest = DEST_AUTOMATIC
906            ];
907            optional string uri = 2 [ (.android.privacy).dest = DEST_EXPLICIT ];
908        }
909        repeated TriggerContentUri trigger_content_uris = 11;
910        optional int64 trigger_content_update_delay_ms = 12;
911        optional int64 trigger_content_max_delay_ms = 13;
912
913        optional .android.os.PersistableBundleProto extras = 14;
914        optional .android.os.BundleProto transient_extras = 15;
915        // ClipData of information that is returned to the application at
916        // execution time, but not persisted by the system. This is provided by
917        // the app and the main purpose of providing a ClipData is to allow
918        // granting of URI permissions for data associated with the clip.  The
919        // exact kind of permission grant to perform is specified in the flags
920        // field.
921        optional .android.content.ClipDataProto clip_data = 16;
922
923        optional GrantedUriPermissionsDumpProto granted_uri_permissions = 17;
924
925        optional .android.net.NetworkRequestProto required_network = 18;
926
927        reserved 19; // total_network_bytes
928
929        // The estimated download bytes of the job. Will have a value of
930        // {@link JobInfo.NETWORK_BYTES_UNKNOWN} if any part of the job download is unknown.
931        optional int64 total_network_download_bytes = 25;
932
933        // The estimated upload bytes of the job. Will have a value of
934        // {@link JobInfo.NETWORK_BYTES_UNKNOWN} if any part of the job upload is unknown.
935        optional int64 total_network_upload_bytes = 26;
936
937        optional int64 min_latency_ms = 20;
938        optional int64 max_execution_delay_ms = 21;
939
940        message Backoff {
941            option (.android.msg_privacy).dest = DEST_AUTOMATIC;
942
943            enum Policy {
944                BACKOFF_POLICY_LINEAR = 0;
945                BACKOFF_POLICY_EXPONENTIAL = 1;
946            }
947            optional Policy policy = 1;
948            optional int64 initial_backoff_ms = 2;
949        }
950        optional Backoff backoff_policy = 22;
951
952        optional bool has_early_constraint = 23;
953        optional bool has_late_constraint = 24;
954
955        // Next tag: 27
956    }
957    optional JobInfo job_info = 6;
958
959    repeated ConstraintEnum required_constraints = 7;
960    // Dynamic constraints are additional constraints imposed by the system that MUST be met before
961    // the app can run if the app does not have quota.
962    repeated ConstraintEnum dynamic_constraints = 31;
963    repeated ConstraintEnum satisfied_constraints = 8;
964    repeated ConstraintEnum unsatisfied_constraints = 9;
965    optional bool is_doze_whitelisted = 10;
966    optional bool is_uid_active = 26;
967
968    message ImplicitConstraints {
969        // The device isn't Dozing or this job will be in the foreground. This
970        // implicit constraint must be satisfied for the job to run.
971        optional bool is_not_dozing = 1;
972        // The job is not restricted from running in the background (due to
973        // Battery Saver). This implicit constraint must be satisfied for the
974        // job to run.
975        optional bool is_not_restricted_in_bg = 2;
976        // True if dynamic constraints have been satisfied.
977        optional bool is_dynamic_satisfied = 3;
978    }
979    optional ImplicitConstraints implicit_constraints = 25;
980
981    enum TrackingController {
982        TRACKING_BATTERY = 0;
983        TRACKING_CONNECTIVITY = 1;
984        TRACKING_CONTENT = 2;
985        TRACKING_IDLE = 3;
986        TRACKING_STORAGE = 4;
987        TRACKING_TIME = 5;
988        TRACKING_QUOTA = 6;
989    }
990    // Controllers that are currently tracking the job.
991    repeated TrackingController tracking_controllers = 11;
992
993    repeated string changed_authorities = 12 [
994        (.android.privacy).dest = DEST_EXPLICIT
995    ];
996    repeated string changed_uris = 13 [
997        (.android.privacy).dest = DEST_EXPLICIT
998    ];
999
1000    optional .android.net.NetworkProto network = 14;
1001
1002    // Only the desired data from an android.app.job.JobWorkItem object.
1003    message JobWorkItem {
1004        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
1005
1006        optional int32 work_id = 1;
1007        optional int32 delivery_count = 2;
1008        optional .android.content.IntentProto intent = 3;
1009        optional GrantedUriPermissionsDumpProto uri_grants = 4;
1010    }
1011    repeated JobWorkItem pending_work = 15;
1012    repeated JobWorkItem executing_work = 16;
1013
1014    enum Bucket {
1015        ACTIVE = 0;
1016        WORKING_SET = 1;
1017        FREQUENT = 2;
1018        RARE = 3;
1019        NEVER = 4;
1020        RESTRICTED = 5;
1021    }
1022    optional Bucket standby_bucket = 17;
1023    optional bool is_exempted_from_app_standby = 27;
1024
1025    optional int64 enqueue_duration_ms = 18;
1026    // Can be negative if the earliest runtime deadline has passed.
1027    optional sint64 time_until_earliest_runtime_ms = 19;
1028    // Can be negative if the latest runtime deadline has passed.
1029    optional sint64 time_until_latest_runtime_ms = 20;
1030    // The original latest runtime value, in the elapsed realtime timebase. Valid only for periodic
1031    // jobs.
1032    optional uint64 original_latest_runtime_elapsed = 30;
1033
1034    optional int32 num_failures = 21;
1035
1036    // Last time a job finished successfully for a periodic job, in currentTimeMillis time.
1037    optional int64 last_successful_run_time = 22;
1038    // Last time a job finished unsuccessfully, in currentTimeMillis time.
1039    optional int64 last_failed_run_time = 23;
1040
1041    optional int64 internal_flags = 24;
1042
1043    // Amount of time since this job was first deferred due to standby bucketing policy. Will be
1044    // 0 if this job was never deferred.
1045    optional int64 time_since_first_deferral_ms = 28;
1046
1047    // Amount of time since JobScheduler first tried to force batch this job. Will be 0 if there
1048    // was no attempt.
1049    optional int64 time_since_first_force_batch_attempt_ms = 29;
1050
1051    // Next tag: 32
1052}
1053
1054// Dump from com.android.server.job.JobConcurrencyManager.
1055// Next tag: 7
1056message JobConcurrencyManagerProto {
1057    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
1058
1059    // Whether the device is interactive (== screen on) now or not.
1060    optional bool current_interactive_state = 1;
1061    // Similar to current_interactive_state, screen on or not, but it takes into account the off timeout.
1062    optional bool effective_interactive_state = 2;
1063    // How many milliseconds have passed since the last screen on. (i.e. 1000 == 1 sec ago)
1064    optional int64 time_since_last_screen_on_ms = 3;
1065    // How many milliseconds have passed since the last screen off. (i.e. 1000 == 1 sec ago)
1066    optional int64 time_since_last_screen_off_ms = 4;
1067    // Current max number of jobs.
1068    optional JobCountTrackerProto job_count_tracker = 5;
1069    // Current memory trim level.
1070    optional int32 memory_trim_level = 6;
1071    // Performance stats.
1072    optional StatLoggerProto stats = 7;
1073}
1074
1075// Dump from com.android.server.job.JobConcurrencyManager.JobCountTracker.
1076// Next tag: 8
1077message JobCountTrackerProto {
1078    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
1079
1080    // Number of total jos that can run simultaneously.
1081    optional int32 config_num_max_total_jobs = 1;
1082    // Number of background jos that can run simultaneously.
1083    optional int32 config_num_max_bg_jobs = 2;
1084    // Out of total jobs, this many background jobs should be guaranteed to be executed, even if
1085    // there are the config_num_max_total_jobs count of foreground jobs pending.
1086    optional int32 config_num_min_bg_jobs = 3;
1087
1088    // Number of running foreground jobs.
1089    optional int32 num_running_fg_jobs = 4;
1090    // Number of running background jobs.
1091    optional int32 num_running_bg_jobs = 5;
1092
1093    // Number of pending foreground jobs.
1094    optional int32 num_pending_fg_jobs = 6;
1095    // Number of pending background jobs.
1096    optional int32 num_pending_bg_jobs = 7;
1097
1098    optional int32 num_actual_max_fg_jobs = 8;
1099    optional int32 num_actual_max_bg_jobs = 9;
1100
1101    optional int32 num_reserved_for_bg = 10;
1102
1103    optional int32 num_starting_fg_jobs = 11;
1104    optional int32 num_starting_bg_jobs = 12;
1105}
1106
1107message JobStorePersistStatsProto {
1108    message Stats {
1109        optional int32 num_total_jobs = 1;
1110        optional int32 num_system_server_jobs = 2;
1111        optional int32 num_system_sync_manager_jobs = 3;
1112    }
1113
1114    optional Stats first_load = 1;
1115    optional Stats last_save = 2;
1116}
1117