1// Copyright 2024 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package com.android.adservices.shared.proto;
18option java_multiple_files = true;
19option java_package = "com.android.adservices.shared.proto";
20
21// The Policy used to schedule a background job in Scheduling Policy Engine (SPE).
22//
23// The SPE supports singular field: Integer, Long, Boolean, String, Enum, and current it doesn't
24// support repeated or composited field. Please file a request if it needs to be supported.
25message JobPolicy {
26  // Unique identifier of a job.
27  optional int32 job_id = 1; // ** REQUIRED field **
28
29  // Set basic description of the kind of network the job requires.
30  optional NetworkType network_type = 2;
31
32  enum NetworkType {
33    // Unknown network type.
34    NETWORK_TYPE_UNKNOWN = 0;
35
36    // Default type.
37    NETWORK_TYPE_NONE = 1;
38
39    // This job requires any network connectivity.
40    NETWORK_TYPE_ANY = 2;
41
42    // This job requires network connectivity that is unmetered.
43    NETWORK_TYPE_UNMETERED = 3;
44
45    // This job requires network connectivity that is not roaming.
46    NETWORK_TYPE_NOT_ROAMING = 4;
47
48    // This job requires network connectivity that is a cellular network (metered).
49    NETWORK_TYPE_CELLULAR = 5;
50  }
51
52  // Set the battery constraint for the job.
53  optional BatteryType battery_type = 3;
54
55  enum BatteryType {
56    // Unknown battery type.
57    BATTERY_TYPE_UNKNOWN = 0;
58
59    // The job doesn't have any battery condition.
60    BATTERY_TYPE_REQUIRE_NONE = 1;
61
62    // The job requires the battery to be charged.
63    BATTERY_TYPE_REQUIRE_CHARGING = 2;
64
65    // The job requires the battery to be not low.
66    BATTERY_TYPE_REQUIRE_NOT_LOW = 3;
67  }
68
69  // Set if the job requires the device in idle.
70  optional bool require_device_idle = 4;
71
72  // Specify that to run this job, the device's available storage must not be low.
73  optional bool require_storage_not_low = 5;
74
75  // Set whether or not to persist this job across device reboots.
76  optional bool is_persisted = 6;
77
78  // The job type for the job to schedule. It should be one of the supported types in SPE.
79  oneof job_params {
80    PeriodicJobParams periodic_job_params = 7;
81    OneOffJobParams one_off_job_params = 8;
82    TriggerContentJobParams trigger_content_job_params = 9;
83  }
84
85  // Information about a periodic job. The job will be executed periodically.
86  message PeriodicJobParams {
87    // The interval of a periodic job in millisecond.
88    optional int64 periodic_interval_ms = 1;
89
90    // The flex interval of a periodic job in millisecond.
91    optional int64 flex_internal_ms = 2;
92  }
93
94  // Information about a one-off job. That says, the job will be only executed once.
95  message OneOffJobParams {
96    // Specify that this job should be delayed by the provided amount of time, in millisecond.
97    optional int64 minimum_latency_ms = 1;
98
99    // Set deadline which is the maximum scheduling latency in millisecond. The job will be ran by
100    // this deadline even if other requirements aren't satisfied.
101    optional int64 override_deadline_ms = 2;
102  }
103
104  // Information about a content URI modification that a job would like to trigger on.
105  message TriggerContentJobParams {
106    // The URI string to be parsed to build a URI.
107    optional string trigger_content_uri_string = 1;
108
109    // The maximum delay in millisecond to use before scheduling the job when triggering on content
110    // URI changes.
111    optional int64 trigger_content_max_delay_ms = 2;
112
113    // The delay from when a change is detected until the job is scheduled when triggering on content
114    // URI changes, in millisecond.
115    optional int64 trigger_content_update_delay_ms = 3;
116  }
117}