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