Create Job Policy Protos
Bug: 323029432
Test: m
Change-Id: I99fdb68b252442c92e99aae1558d76f520bde4d1
diff --git a/shared/device-side/libraries/proto/job_policy.proto b/shared/device-side/libraries/proto/job_policy.proto
new file mode 100644
index 0000000..2df6980
--- /dev/null
+++ b/shared/device-side/libraries/proto/job_policy.proto
@@ -0,0 +1,132 @@
+// Copyright 2024 Google LLC
+//
+// 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 = "proto3";
+
+package com.android.adservices.shared.proto;
+option java_multiple_files = true;
+option java_package = "com.android.adservices.shared.proto";
+
+// The Policy used to schedule a background job in PolicyJobScheduler. The sequence of the fields
+// follows the sequence in JobInfo.
+message JobPolicy {
+ // Unique identifier of a job.
+ optional int32 job_id = 1; // ** REQUIRED field **
+
+ // Indicate the priority for this job. Use this to inform the system about which jobs it should
+ // try to run before other jobs.
+ optional Priority priority = 2;
+
+ enum Priority {
+ // Unknown priority value.
+ PRIORITY_UNKNOWN = 0;
+
+ // Job has minimal value to the user. The user has absolutely no expectation or knowledge of
+ // this task and it has no bearing on the user's perception of the app whatsoever.
+ PRIORITY_MIN = 1;
+
+ // Low priority. The task provides some benefit to users, but is not critical and is more of a
+ // nice-to-have.
+ PRIORITY_LOW = 2;
+
+ // Default value for all regular jobs.
+ PRIORITY_DEFAULT = 3;
+
+ // This task should be ordered ahead of most other tasks. It may be eferred a little, but if it
+ // doesn't run at some point, the user may think something is wrong.
+ PRIORITY_HIGH = 4;
+
+ // This task should be run ahead of all other tasks. Only Expedited Jobs can have this priority.
+ PRIORITY_MAX = 5;
+ }
+
+ // Set basic description of the kind of network your job requires.
+ optional NetworkType network_type = 3;
+
+ enum NetworkType {
+ // Unknown network type.
+ NETWORK_TYPE_UNKNOWN = 0;
+
+ // Default type.
+ NETWORK_TYPE_NONE = 1;
+
+ // This job requires network connectivity.
+ NETWORK_TYPE_ANY = 2;
+
+ // This job requires network connectivity that is unmetered.
+ NETWORK_TYPE_UNMETERED = 3;
+
+ // This job requires network connectivity that is not roaming.
+ NETWORK_TYPE_NOT_ROAMING = 4;
+
+ // This job requires network connectivity that is a cellular network.
+ NETWORK_TYPE_CELLULAR = 5;
+ }
+
+ // Set the battery constraint for your job.
+ optional BatteryType battery_type = 4;
+
+ enum BatteryType {
+ // Unknown battery type.
+ BATTERY_TYPE_UNKNOWN = 0;
+
+ // The job doesn't have any battery condition.
+ BATTERY_TYPE_REQUIRE_NONE = 1;
+
+ // The job requires the battery to be charged.
+ BATTERY_TYPE_REQUIRE_CHARGING = 2;
+
+ // The job requires the battery to be not low.
+ BATTERY_TYPE_REQUIRE_NOT_LOW = 3;
+ }
+
+ // Set if your job requires the device in idle.
+ optional bool require_device_idle = 5;
+
+ // Specify that to run this job, the device's available storage must not be low.
+ optional bool require_storage_not_low = 6;
+
+ // The URI string to be parsed to build a URI.
+ optional string trigger_content_uri_string = 7;
+
+ // The flag used in JobInfo to build a TriggerContentUri.
+ optional int32 trigger_content_flag = 8;
+
+ // The maximum delay in millisecond to use before scheduling the job when triggering on content
+ // URI changes.
+ optional int64 trigger_content_max_delay_ms = 9;
+
+ // The delay from when a change is detected until the job is scheduled when triggering on content
+ // URI changes, in millisecond.
+ optional int64 trigger_content_update_delay_ms = 10;
+
+ // The interval of a periodic job in millisecond.
+ optional int64 periodic_interval_ms = 11;
+
+ // The flex interval of a periodic job in millisecond.
+ optional int64 flex_internal_ms = 12;
+
+ // Specify that this job should be delayed by the provided amount of time, in millisecond.
+ optional int64 minimum_latency_ms = 13;
+
+ // Set deadline which is the maximum scheduling latency in millisecond.
+ optional int64 override_deadline_ms = 14;
+
+ // Setting this to true indicates that this job is important and needs to run as soon as possible
+ // with stronger guarantees than regular jobs.
+ optional bool is_expedited = 15;
+
+ // Set whether or not to persist this job across device reboots.
+ optional bool is_persisted = 16;
+}
\ No newline at end of file
diff --git a/shared/device-side/libraries/proto/module_job_policy.proto b/shared/device-side/libraries/proto/module_job_policy.proto
new file mode 100644
index 0000000..96b053e
--- /dev/null
+++ b/shared/device-side/libraries/proto/module_job_policy.proto
@@ -0,0 +1,27 @@
+// Copyright 2024 Google LLC
+//
+// 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 = "proto3";
+
+package com.android.adservices.shared.proto;
+option java_multiple_files = true;
+option java_package = "com.android.adservices.shared.proto";
+
+import "job_policy.proto";
+
+// The proto used by a module for all job policies.
+message ModuleJobPolicy {
+ // The mapping between jobId and the corresponding JobPolicy for a job.
+ map<int32, JobPolicy> job_policy = 1; // ** REQUIRED field **
+}
\ No newline at end of file