File: jobscheduler.proto

package info (click to toggle)
android-platform-frameworks-base 1%3A10.0.0%2Br36-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 321,788 kB
  • sloc: java: 962,234; cpp: 274,314; xml: 242,770; python: 5,060; sh: 1,432; ansic: 494; makefile: 47; sed: 19
file content (975 lines) | stat: -rw-r--r-- 39,181 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package com.android.server.job;

option java_multiple_files = true;

import "frameworks/base/core/proto/android/app/job/enums.proto";
import "frameworks/base/core/proto/android/content/clipdata.proto";
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/content/intent.proto";
import "frameworks/base/core/proto/android/net/network.proto";
import "frameworks/base/core/proto/android/net/networkrequest.proto";
import "frameworks/base/core/proto/android/os/bundle.proto";
import "frameworks/base/core/proto/android/os/persistablebundle.proto";
import "frameworks/base/core/proto/android/server/forceappstandbytracker.proto";
import "frameworks/base/core/proto/android/server/job/enums.proto";
import "frameworks/base/core/proto/android/privacy.proto";

// Next tag: 21
message JobSchedulerServiceDumpProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    optional ConstantsProto settings = 1;

    optional int32 current_heartbeat = 14;
    repeated int32 next_heartbeat = 15;
    optional int64 last_heartbeat_time_millis = 16;
    optional int64 next_heartbeat_time_millis = 17;
    optional bool in_parole = 18;
    optional bool in_thermal = 19;

    repeated int32 started_users = 2;

    message RegisteredJob {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional JobStatusShortInfoProto info = 1;
        optional JobStatusDumpProto dump = 2;

        // A job is ready to be executed if:
        // is_job_ready && is_user_started && !is_job_pending &&
        // !is_job_currently_active && !is_uid_backing_up &&
        // is_component_present.
        optional bool is_job_ready = 3;
        optional bool is_user_started = 4;
        optional bool is_job_pending = 5;
        optional bool is_job_currently_active = 6;
        optional bool is_uid_backing_up = 7;
        optional bool is_component_present = 8;

        optional int64 last_run_heartbeat = 9;
    }
    repeated RegisteredJob registered_jobs = 3;

    repeated StateControllerProto controllers = 4;

    // Which uids are currently in the foreground.
    message PriorityOverride {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional int32 uid = 1;
        // Use sint32 instead of an enum since priorities can technically be
        // negative.
        optional sint32 override_value = 2;
    }
    repeated PriorityOverride priority_overrides = 5;

    // UIDs that are currently performing backups, so their jobs won't be
    // allowed to run.
    repeated int32 backing_up_uids = 6;

    optional JobPackageHistoryProto history = 7;
    optional JobPackageTrackerDumpProto package_tracker = 8;

    message PendingJob {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional JobStatusShortInfoProto info = 1;
        optional JobStatusDumpProto dump = 2;
        optional sint32 evaluated_priority = 3;
        // How long this job has been pending.
        optional int64 enqueued_duration_ms = 4;
    }
    repeated PendingJob pending_jobs = 9;

    // From a service that has currently active or pending jobs.
    message ActiveJob {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        message InactiveJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional int64 time_since_stopped_ms = 1;
            // This is not always provided.
            optional string stopped_reason = 2;
        }
        message RunningJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            // How long this job has been running for.
            optional int64 running_duration_ms = 2;
            optional int64 time_until_timeout_ms = 3;

            optional JobStatusDumpProto dump = 4;

            optional sint32 evaluated_priority = 5;

            optional int64 time_since_made_active_ms = 6;
            // How long this job has been pending.
            optional int64 pending_duration_ms = 7;
        }
        oneof job {
            InactiveJob inactive = 1;
            RunningJob running = 2;
        }
    }
    repeated ActiveJob active_jobs = 10;

    // True when JobScheduler is allowed to run third party apps.
    optional bool is_ready_to_rock = 11;
    // What was last reported to DeviceIdleController about whether the device
    // is active.
    optional bool reported_active = 12;
    // The current limit on the number of concurrent JobServiceContext entries
    // we want to keep actively running a job.
    optional int32 max_active_jobs = 13;

    // Dump from JobConcurrencyManager.
    optional JobConcurrencyManagerProto concurrency_manager = 20;
}

// A com.android.server.job.JobSchedulerService.Constants object.
// Next tag: 29
message ConstantsProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    // Minimum # of idle jobs that must be ready in order to force the JMS to
    // schedule things early.
    optional int32 min_idle_count = 1;
    // Minimum # of charging jobs that must be ready in order to force the JMS
    // to schedule things early.
    optional int32 min_charging_count = 2;
    // Minimum # of "battery not low" jobs that must be ready in order to force
    // the JMS to schedule things early.
    optional int32 min_battery_not_low_count = 3;
    // Minimum # of "storage not low" jobs that must be ready in order to force
    // the JMS to schedule things early.
    optional int32 min_storage_not_low_count = 4;
    // Minimum # of connectivity jobs that must be ready in order to force the
    // JMS to schedule things early. 1 == Run connectivity jobs as soon as
    // ready.
    optional int32 min_connectivity_count = 5;
    // Minimum # of content trigger jobs that must be ready in order to force
    // the JMS to schedule things early.
    optional int32 min_content_count = 6;
    // Minimum # of jobs (with no particular constraints) for which the JMS will
    // be happy running some work early. This (and thus the other min counts)
    // is now set to 1, to prevent any batching at this level. Since we now do
    // batching through doze, that is a much better mechanism.
    optional int32 min_ready_jobs_count = 7;
    // This is the job execution factor that is considered to be heavy use of
    // the system.
    optional double heavy_use_factor = 8;
    // This is the job execution factor that is considered to be moderate use of
    // the system.
    optional double moderate_use_factor = 9;
    // The number of MAX_JOB_CONTEXTS_COUNT we reserve for the foreground app.
    optional int32 fg_job_count = 10;
    // The maximum number of background jobs we allow when the system is in a
    // normal memory state.
    optional int32 bg_normal_job_count = 11;
    // The maximum number of background jobs we allow when the system is in a
    // moderate memory state.
    optional int32 bg_moderate_job_count = 12;
    // The maximum number of background jobs we allow when the system is in a
    // low memory state.
    optional int32 bg_low_job_count = 13;
    // The maximum number of background jobs we allow when the system is in a
    // critical memory state.
    optional int32 bg_critical_job_count = 14;
    // The maximum number of times we allow a job to have itself rescheduled
    // before giving up on it, for standard jobs.
    optional int32 max_standard_reschedule_count = 15;
    // The maximum number of times we allow a job to have itself rescheduled
    // before giving up on it, for jobs that are executing work.
    optional int32 max_work_reschedule_count = 16;
    // The minimum backoff time to allow for linear backoff.
    optional int64 min_linear_backoff_time_ms = 17;
    // The minimum backoff time to allow for exponential backoff.
    optional int64 min_exp_backoff_time_ms = 18;
    // How often we recalculate runnability based on apps' standby bucket
    // assignment. This should be prime relative to common time interval lengths
    // such as a quarter-hour or day, so that the heartbeat drifts relative to
    // wall-clock milestones.
    optional int64 standby_heartbeat_time_ms = 19;
    // Mapping: standby bucket -> number of heartbeats between each sweep of
    // that bucket's jobs.
    // Bucket assignments as recorded in the JobStatus objects are normalized to
    // be indices into this array, rather than the raw constants used by
    // AppIdleHistory.
    repeated int32 standby_beats = 20;
    // The fraction of a job's running window that must pass before we
    // consider running it when the network is congested.
    optional double conn_congestion_delay_frac = 21;
    // The fraction of a prefetch job's running window that must pass before
    // we consider matching it against a metered network.
    optional double conn_prefetch_relax_frac = 22;
    // Whether to use heartbeats or rolling window for quota management. True
    // will use heartbeats, false will use a rolling window.
    optional bool use_heartbeats = 23;

    message TimeController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        // Whether or not TimeController should skip setting wakeup alarms for jobs that aren't
        // ready now.
        optional bool skip_not_ready_jobs = 1;
    }
    optional TimeController time_controller = 25;

    message QuotaController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        // How much time each app will have to run jobs within their standby bucket window.
        optional int64 allowed_time_per_period_ms = 1;
        // How much time the package should have before transitioning from out-of-quota to in-quota.
        // This should not affect processing if the package is already in-quota.
        optional int64 in_quota_buffer_ms = 2;
        // The quota window size of the particular standby bucket. Apps in this standby bucket are
        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
        // WINDOW_SIZE_MS.
        optional int64 active_window_size_ms = 3;
        // The quota window size of the particular standby bucket. Apps in this standby bucket are
        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
        // WINDOW_SIZE_MS.
        optional int64 working_window_size_ms = 4;
        // The quota window size of the particular standby bucket. Apps in this standby bucket are
        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
        // WINDOW_SIZE_MS.
        optional int64 frequent_window_size_ms = 5;
        // The quota window size of the particular standby bucket. Apps in this standby bucket are
        // expected to run only {@link QUOTA_CONTROLLER_ALLOWED_TIME_PER_PERIOD_MS} within the past
        // WINDOW_SIZE_MS.
        optional int64 rare_window_size_ms = 6;
        // The maximum amount of time an app can have its jobs running within a 24 hour window.
        optional int64 max_execution_time_ms = 7;
        // The maximum number of jobs an app can run within this particular standby bucket's
        // window size.
        optional int32 max_job_count_active = 8;
        // The maximum number of jobs an app can run within this particular standby bucket's
        // window size.
        optional int32 max_job_count_working = 9;
        // The maximum number of jobs an app can run within this particular standby bucket's
        // window size.
        optional int32 max_job_count_frequent = 10;
        // The maximum number of jobs an app can run within this particular standby bucket's
        // window size.
        optional int32 max_job_count_rare = 11;
        // The period of time used to rate limit recently run jobs.
        optional int32 rate_limiting_window_ms = 19;
        // The maximum number of jobs that should be allowed to run in the past
        // rate_limiting_window_ms.
        optional int32 max_job_count_per_rate_limiting_window = 12;
        // The maximum number of timing sessions an app can run within this particular standby
        // bucket's window size.
        optional int32 max_session_count_active = 13;
        // The maximum number of timing sessions an app can run within this particular standby
        // bucket's window size.
        optional int32 max_session_count_working = 14;
        // The maximum number of timing sessions an app can run within this particular standby
        // bucket's window size.
        optional int32 max_session_count_frequent = 15;
        // The maximum number of timing sessions an app can run within this particular standby
        // bucket's window size.
        optional int32 max_session_count_rare = 16;
        // The maximum number of timing sessions that should be allowed to run in the past
        // rate_limiting_window_ms.
        optional int32 max_session_count_per_rate_limiting_window = 17;
        // Treat two distinct {@link TimingSession}s as the same if they start and end within this
        // amount of time of each other.
        optional int64 timing_session_coalescing_duration_ms = 18;
    }
    optional QuotaController quota_controller = 24;

    // Max number of jobs, when screen is ON.
    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_on = 26;

    // Max number of jobs, when screen is OFF.
    optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_off = 27;

    // In this time after screen turns on, we increase job concurrency.
    optional int32 screen_off_job_concurrency_increase_delay_ms = 28;
}

// Next tag: 4
message MaxJobCountsProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    // Total number of jobs to run simultaneously.
    optional int32 total_jobs = 1;

    // Max number of BG (== owned by non-TOP apps) jobs to run simultaneously.
    optional int32 max_bg = 2;

    // We try to run at least this many BG (== owned by non-TOP apps) jobs, when there are any
    // pending, rather than always running the TOTAL number of FG jobs.
    optional int32 min_bg = 3;
}

// Next tag: 5
message MaxJobCountsPerMemoryTrimLevelProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    optional MaxJobCountsProto normal = 1;
    optional MaxJobCountsProto moderate = 2;
    optional MaxJobCountsProto low = 3;
    optional MaxJobCountsProto critical = 4;
}

message StateControllerProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    message BackgroundJobsController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional com.android.server.ForceAppStandbyTrackerProto force_app_standby_tracker = 1;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
            optional string source_package_name = 3;
            optional bool is_in_foreground = 4;
            optional bool is_whitelisted = 5;
            optional bool can_run_any_in_background = 6;
            // If the constraints are satisfied, then the controller will mark
            // the job as RUNNABLE, otherwise, it will be WAITING.
            optional bool are_constraints_satisfied = 7;
        }
        repeated TrackedJob tracked_jobs = 2;
    }
    message BatteryController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional bool is_on_stable_power = 1;
        optional bool is_battery_not_low = 2;

        // Whether or not the controller is monitoring battery changes.
        optional bool is_monitoring = 3;
        // Only valid if is_monitoring is true.
        optional int32 last_broadcast_sequence_number = 4;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
        }
        repeated TrackedJob tracked_jobs = 5;
    }
    message ConnectivityController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional bool is_connected = 1;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
            optional .android.net.NetworkRequestProto required_network = 3;
        }
        repeated TrackedJob tracked_jobs = 2;
    }
    message ContentObserverController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
        }
        repeated TrackedJob tracked_jobs = 1;

        message Observer {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional int32 user_id = 1;

            message TriggerContentData {
                option (.android.msg_privacy).dest = DEST_AUTOMATIC;

                optional string uri = 1 [
                    (.android.privacy).dest = DEST_EXPLICIT
                ];
                optional int32 flags = 2;

                // A
                // com.android.server.job.controllers.ContentObserverController.JobInstance
                // object.
                message JobInstance {
                    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

                    optional JobStatusShortInfoProto info = 1;
                    optional int32 source_uid = 2;

                    optional int64 trigger_content_update_delay_ms = 3;
                    optional int64 trigger_content_max_delay_ms = 4;

                    repeated string changed_authorities = 5 [
                        (.android.privacy).dest = DEST_EXPLICIT
                    ];
                    repeated string changed_uris = 6 [
                        (.android.privacy).dest = DEST_EXPLICIT
                    ];
                }
                repeated JobInstance jobs = 3;
            }
            repeated TriggerContentData triggers = 2;
        }
        repeated Observer observers = 2;
    }
    message DeviceIdleJobsController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        // True when in device idle mode.
        optional bool is_device_idle_mode = 1;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
            optional string source_package_name = 3;
            // If the constraints are satisfied, then the controller will mark
            // the job as RUNNABLE, otherwise, it will be WAITING.
            optional bool are_constraints_satisfied = 4;
            optional bool is_doze_whitelisted = 5;
            // A job that is exempted from Doze when the app is temp whitelisted
            // or in the foreground.
            optional bool is_allowed_in_doze = 6;
        }
        repeated TrackedJob tracked_jobs = 2;
    }
    message IdleController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional bool is_idle = 1;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
        }
        repeated TrackedJob tracked_jobs = 2;
    }
    message QuotaController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional bool is_charging = 1;
        optional bool is_in_parole = 2;
        optional int64 elapsed_realtime = 6;

        // List of UIDs currently in the foreground.
        repeated int32 foreground_uids = 3;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
            optional JobStatusDumpProto.Bucket effective_standby_bucket = 3;
            // If the job started while the app was in the TOP state.
            optional bool is_top_started_job = 4;
            optional bool has_quota = 5;
            // The amount of time that this job has remaining in its quota. This
            // can be negative if the job is out of quota.
            optional int64 remaining_quota_ms = 6;
        }
        repeated TrackedJob tracked_jobs = 4;

        message AlarmListener {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            // Whether the listener is waiting for an alarm or not.
            optional bool is_waiting = 1;
            // The time at which the alarm should go off, in the elapsed realtime timebase. Only
            // valid if is_waiting is true.
            optional int64 trigger_time_elapsed = 2;
        }

        message ExecutionStats {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusDumpProto.Bucket standby_bucket = 1;

            // The time after which this record should be considered invalid (out of date), in the
            // elapsed realtime timebase.
            optional int64 expiration_time_elapsed = 2;
            optional int64 window_size_ms = 3;

            optional int32 job_count_limit = 14;
            optional int32 session_count_limit = 15;

            // The total amount of time the app ran in its respective bucket window size.
            optional int64 execution_time_in_window_ms = 4;
            optional int32 bg_job_count_in_window = 5;

            // The total amount of time the app ran in the last
            // {@link QuotaController#MAX_PERIOD_MS}.
            optional int64 execution_time_in_max_period_ms = 6;
            optional int32 bg_job_count_in_max_period = 7;

            // The number of {@link TimingSession}s within the bucket window size. This will include
            // sessions that started before the window as long as they end within the window.
            optional int32 session_count_in_window = 11;

            // The time after which the app will be under the bucket quota. This is only valid if
            // execution_time_in_window_ms >=
            //   ConstantsProto.QuotaController.allowed_time_per_period_ms
            // or
            // execution_time_in_max_period_ms >=
            //   ConstantsProto.QuotaController.max_execution_time_ms
            // or
            // bg_job_count_in_window >= job_count_limit
            // or
            // session_count_in_window >= session_count_limit.
            optional int64 in_quota_time_elapsed = 8;

            // The time after which job_count_in_rate_limiting_window should be considered invalid,
            // in the elapsed realtime timebase.
            optional int64 job_count_expiration_time_elapsed = 9;

            // The number of jobs that ran in at least the last
            // ConstantsProto.QuotaController.rate_limiting_window_ms.
            // It may contain a few stale entries since cleanup won't happen exactly every
            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be
            // considered valid before elapsed realtime has reached
            // job_count_expiration_time_elapsed.
            optional int32 job_count_in_rate_limiting_window = 10;

            // The time after which {@link #timingSessionCountInAllowedTime} should be considered
            // invalid, in the elapsed realtime timebase.
            optional int64 session_count_expiration_time_elapsed = 12;

            // The number of {@link TimingSession}s that ran in at least the last
            // ConstantsProto.QuotaController.rate_limiting_window_ms. It may contain a few stale
            // entries since cleanup won't happen exactly every
            // ConstantsProto.QuotaController.rate_limiting_window_ms. This should only be considered
            // valid before elapsed realtime has reached session_count_expiration_time_elapsed.
            optional int32 session_count_in_rate_limiting_window = 13;
        }

        message Package {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional int32 user_id = 1;
            optional string name = 2;
        }

        message TimingSession {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional int64 start_time_elapsed = 1;
            optional int64 end_time_elapsed = 2;
            // The number of background jobs that ran during this session.
            optional int32 bg_job_count = 3;
        }

        message Timer {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional Package pkg = 1;
            // True if the Timer is actively tracking jobs.
            optional bool is_active = 2;
            // The time this timer last became active. Only valid if is_active is true.
            optional int64 start_time_elapsed = 3;
            // How many background jobs are currently running. Valid only if the device is_active
            // is true.
            optional int32 bg_job_count = 4;
            // All of the jobs that the Timer is currently tracking.
            repeated JobStatusShortInfoProto running_jobs = 5;
        }

        message PackageStats {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional Package pkg = 1;

            optional Timer timer = 2;

            repeated TimingSession saved_sessions = 3;

            repeated ExecutionStats execution_stats = 4;

            optional AlarmListener in_quota_alarm_listener = 5;
        }
        repeated PackageStats package_stats = 5;
    }
    message StorageController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional bool is_storage_not_low = 1;
        optional int32 last_broadcast_sequence_number = 2;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;
        }
        repeated TrackedJob tracked_jobs = 3;
    }
    message TimeController {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional int64 now_elapsed_realtime = 1;
        optional int64 time_until_next_delay_alarm_ms = 2;
        optional int64 time_until_next_deadline_alarm_ms = 3;

        message TrackedJob {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional JobStatusShortInfoProto info = 1;
            optional int32 source_uid = 2;

            optional bool has_timing_delay_constraint = 3;
            // Only valid if has_timing_delay_constraint is true. Can be
            // negative if the delay is in the past.
            optional int64 delay_time_remaining_ms = 4;

            optional bool has_deadline_constraint = 5;
            // Only valid if has_timing_delay_constraint is true. Can be
            // negative in certain situations.
            optional int64 time_remaining_until_deadline_ms = 6;
        }
        repeated TrackedJob tracked_jobs = 4;
    }
    oneof controller {
        BackgroundJobsController background = 1;
        BatteryController battery = 2;
        ConnectivityController connectivity = 3;
        ContentObserverController content_observer = 4;
        DeviceIdleJobsController device_idle = 5;
        IdleController idle = 6;
        QuotaController quota = 9;
        StorageController storage = 7;
        TimeController time = 8;
        // Next tag: 10
    }
}

// A com.android.server.job.JobPackageTracker.DataSet object.
message DataSetProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    optional int64 start_clock_time_ms = 1;
    // How much time has elapsed since the DataSet was instantiated.
    optional int64 elapsed_time_ms = 2;
    optional int64 period_ms = 3;

    // Represents a com.android.server.job.JobPackageTracker.PackageEntry
    // object, but with some extra data.
    message PackageEntryProto {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional int32 uid = 1;
        optional string package_name = 2;

        message State {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional int64 duration_ms = 1;
            optional int32 count = 2;
        }
        optional State pending_state = 3;
        optional State active_state = 4;
        optional State active_top_state = 5;

        // True if the PackageEntry is currently pending or has been pending in
        // the past.
        optional bool pending = 6;
        // True if the PackageEntry is currently active or has been active in
        // the past.
        optional bool active = 7;
        // True if the PackageEntry is currently active top or has been active
        // top in the past.
        optional bool active_top = 8;

        message StopReasonCount {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            optional .android.app.job.StopReasonEnum reason = 1;
            optional int32 count = 2;
        }
        repeated StopReasonCount stop_reasons = 9;
    }
    repeated PackageEntryProto package_entries = 4;

    optional int32 max_concurrency = 5;
    optional int32 max_foreground_concurrency = 6;
}

// Dump from com.android.server.job.GrantedUriPermissions.
message GrantedUriPermissionsDumpProto {
    option (.android.msg_privacy).dest = DEST_EXPLICIT;

    optional int32 flags = 1 [ (.android.privacy).dest = DEST_AUTOMATIC ];
    optional int32 source_user_id = 2 [
        (.android.privacy).dest = DEST_AUTOMATIC
    ];
    optional string tag = 3;
    optional string permission_owner = 4;
    repeated string uris = 5;
}

message JobPackageTrackerDumpProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    repeated DataSetProto historical_stats = 1;
    optional DataSetProto current_stats = 2;
}

message JobPackageHistoryProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    enum Event {
        UNKNOWN = 0;
        START_JOB = 1;
        STOP_JOB = 2;
        START_PERIODIC_JOB = 3;
        STOP_PERIODIC_JOB = 4;
    }
    message HistoryEvent {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional Event event = 1;
        optional int64 time_since_event_ms = 2;
        optional int32 uid = 3;
        // Job IDs can technically be negative.
        optional int32 job_id = 4;
        optional string tag = 5;
        // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events.
        optional .android.app.job.StopReasonEnum stop_reason = 6;
    }
    repeated HistoryEvent history_event = 1;
}

message JobStatusShortInfoProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    optional int32 calling_uid = 1;
    // Job IDs can technically be negative.
    optional int32 job_id = 2;
    optional string battery_name = 3;
}

// Dump from a com.android.server.job.controllers.JobStatus object.
message JobStatusDumpProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    // The UID that scheduled the job.
    optional int32 calling_uid = 1;
    optional string tag = 2;

    // The UID for which the job is being run.
    optional int32 source_uid = 3;
    optional int32 source_user_id = 4;
    // The package for which the job is being run.
    optional string source_package_name = 5;

    // Custom dump of android.app.job.JobInfo object.
    message JobInfo {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional .android.content.ComponentNameProto service = 1;

        optional bool is_periodic = 2;
        // Only valid if is_periodic is true.
        optional int64 period_interval_ms = 3;
        // Only valid if is_periodic is true.
        optional int64 period_flex_ms = 4;

        optional bool is_persisted = 5;
        optional sint32 priority = 6;
        optional int32 flags = 7;

        optional bool requires_charging = 8;
        optional bool requires_battery_not_low = 9;
        optional bool requires_device_idle = 10;

        message TriggerContentUri {
            optional int32 flags = 1 [
                (.android.privacy).dest = DEST_AUTOMATIC
            ];
            optional string uri = 2 [ (.android.privacy).dest = DEST_EXPLICIT ];
        }
        repeated TriggerContentUri trigger_content_uris = 11;
        optional int64 trigger_content_update_delay_ms = 12;
        optional int64 trigger_content_max_delay_ms = 13;

        optional .android.os.PersistableBundleProto extras = 14;
        optional .android.os.BundleProto transient_extras = 15;
        // ClipData of information that is returned to the application at
        // execution time, but not persisted by the system. This is provided by
        // the app and the main purpose of providing a ClipData is to allow
        // granting of URI permissions for data associated with the clip.  The
        // exact kind of permission grant to perform is specified in the flags
        // field.
        optional .android.content.ClipDataProto clip_data = 16;

        optional GrantedUriPermissionsDumpProto granted_uri_permissions = 17;

        optional .android.net.NetworkRequestProto required_network = 18;

        optional int64 total_network_bytes = 19;

        optional int64 min_latency_ms = 20;
        optional int64 max_execution_delay_ms = 21;

        message Backoff {
            option (.android.msg_privacy).dest = DEST_AUTOMATIC;

            enum Policy {
                BACKOFF_POLICY_LINEAR = 0;
                BACKOFF_POLICY_EXPONENTIAL = 1;
            }
            optional Policy policy = 1;
            optional int64 initial_backoff_ms = 2;
        }
        optional Backoff backoff_policy = 22;

        optional bool has_early_constraint = 23;
        optional bool has_late_constraint = 24;
    }
    optional JobInfo job_info = 6;

    repeated ConstraintEnum required_constraints = 7;
    repeated ConstraintEnum satisfied_constraints = 8;
    repeated ConstraintEnum unsatisfied_constraints = 9;
    optional bool is_doze_whitelisted = 10;
    optional bool is_uid_active = 26;

    message ImplicitConstraints {
        // The device isn't Dozing or this job will be in the foreground. This
        // implicit constraint must be satisfied for the job to run.
        optional bool is_not_dozing = 1;
        // The job is not restricted from running in the background (due to
        // Battery Saver). This implicit constraint must be satisfied for the
        // job to run.
        optional bool is_not_restricted_in_bg = 2;
    }
    optional ImplicitConstraints implicit_constraints = 25;

    enum TrackingController {
        TRACKING_BATTERY = 0;
        TRACKING_CONNECTIVITY = 1;
        TRACKING_CONTENT = 2;
        TRACKING_IDLE = 3;
        TRACKING_STORAGE = 4;
        TRACKING_TIME = 5;
        TRACKING_QUOTA = 6;
    }
    // Controllers that are currently tracking the job.
    repeated TrackingController tracking_controllers = 11;

    repeated string changed_authorities = 12 [
        (.android.privacy).dest = DEST_EXPLICIT
    ];
    repeated string changed_uris = 13 [
        (.android.privacy).dest = DEST_EXPLICIT
    ];

    optional .android.net.NetworkProto network = 14;

    // Only the desired data from an android.app.job.JobWorkItem object.
    message JobWorkItem {
        option (.android.msg_privacy).dest = DEST_AUTOMATIC;

        optional int32 work_id = 1;
        optional int32 delivery_count = 2;
        optional .android.content.IntentProto intent = 3;
        optional GrantedUriPermissionsDumpProto uri_grants = 4;
    }
    repeated JobWorkItem pending_work = 15;
    repeated JobWorkItem executing_work = 16;

    enum Bucket {
        ACTIVE = 0;
        WORKING_SET = 1;
        FREQUENT = 2;
        RARE = 3;
        NEVER = 4;
    }
    optional Bucket standby_bucket = 17;
    optional bool is_exempted_from_app_standby = 27;

    optional int64 enqueue_duration_ms = 18;
    // Can be negative if the earliest runtime deadline has passed.
    optional sint64 time_until_earliest_runtime_ms = 19;
    // Can be negative if the latest runtime deadline has passed.
    optional sint64 time_until_latest_runtime_ms = 20;

    optional int32 num_failures = 21;

    optional int64 last_successful_run_time = 22;
    optional int64 last_failed_run_time = 23;

    optional int64 internal_flags = 24;

    // Next tag: 28
}

// Dump from com.android.server.job.JobConcurrencyManager.
// Next tag: 7
message JobConcurrencyManagerProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    // Whether the device is interactive (== screen on) now or not.
    optional bool current_interactive = 1;
    // Similar to current_interactive, screen on or not, but it takes into account the off timeout.
    optional bool effective_interactive = 2;
    // How many milliseconds have passed since the last screen on. (i.e. 1000 == 1 sec ago)
    optional int64 time_since_last_screen_on_ms = 3;
    // How many milliseconds have passed since the last screen off. (i.e. 1000 == 1 sec ago)
    optional int64 time_since_last_screen_off_ms = 4;
    // Current max number of jobs.
    optional JobCountTrackerProto job_count_tracker = 5;
    // Current memory trim level.
    optional int32 memory_trim_level = 6;
}

// Dump from com.android.server.job.JobConcurrencyManager.JobCountTracker.
// Next tag: 8
message JobCountTrackerProto {
    option (.android.msg_privacy).dest = DEST_AUTOMATIC;

    // Number of total jos that can run simultaneously.
    optional int32 config_num_max_total_jobs = 1;
    // Number of background jos that can run simultaneously.
    optional int32 config_num_max_bg_jobs = 2;
    // Out of total jobs, this many background jobs should be guaranteed to be executed, even if
    // there are the config_num_max_total_jobs count of foreground jobs pending.
    optional int32 config_num_min_bg_jobs = 3;

    // Number of running foreground jobs.
    optional int32 num_running_fg_jobs = 4;
    // Number of running background jobs.
    optional int32 num_running_bg_jobs = 5;

    // Number of pending foreground jobs.
    optional int32 num_pending_fg_jobs = 6;
    // Number of pending background jobs.
    optional int32 num_pending_bg_jobs = 7;
}