Add atom for general JobScheduler constraints.

Make it possible to log constraints that apply to all jobs instead of
for each individual job. This allow us to analyze behavior when
JobScheduler believes the device is in various states.

Also add missing constraints to the enum list.

Bug: 129954980
Bug: 242611030
Test: `statsd_testdrive 514`
Change-Id: If277846ade64f9db0484410785ec37fc7b7734df
Merged-In: If277846ade64f9db0484410785ec37fc7b7734df
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 05ffa65..fe04f49 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -719,6 +719,8 @@
         MediametricsHeadTrackerDeviceEnabledReported mediametrics_headtrackerdeviceenabled_reported = 510;
         MediametricsHeadTrackerDeviceSupportedReported mediametrics_headtrackerdevicesupported_reported = 511;
         HearingAidInfoReported hearing_aid_info_reported = 513 [(module) = "framework"];
+        DeviceWideJobConstraintChanged device_wide_job_constraint_changed =
+            514 [(module) = "framework"];
         // StatsdStats tracks platform atoms with ids upto 750.
         // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
     }
@@ -10182,7 +10184,8 @@
 }
 
 /**
- * Logs that a constraint for a scheduled job has changed.
+ * Logs that a job-specific constraint for a scheduled job has changed.
+ * DeviceWideJobConstraintChanged will cover constraints that are normally the same for all jobs.
  *
  * Logged from:
  *     frameworks/base/services/core/java/com/android/server/job/controllers/JobStatus.java
@@ -10204,6 +10207,29 @@
 }
 
 /**
+ * Logs that a device-state-level JobScheduler constraint has changed. This doesn't take individual
+ * job or app characteristics into account. Individual jobs may have a different satisfaction value
+ * based on special policies. Individual job constraints (eg. connectivity or prefetch) are not
+ * logged in this atom.
+ *
+ * Logged from:
+ *     frameworks/base/services/core/java/com/android/server/job/controllers/<*>.java
+ */
+message DeviceWideJobConstraintChanged {
+    optional com.android.server.job.ConstraintEnum constraint = 1;
+
+    enum State {
+        UNKNOWN = 0;
+        UNSATISFIED = 1;
+        SATISFIED = 2;
+    }
+    optional State state = 2 [
+        (state_field_option).exclusive_state = true,
+        (state_field_option).nested = false
+    ];
+}
+
+/**
  * Logs PowerManagerService screen timeout resets (extensions) that happen when an attention check
  * returns true.
  *
diff --git a/stats/enums/server/job/enums.proto b/stats/enums/server/job/enums.proto
index 2ef08a5..68d88a3 100644
--- a/stats/enums/server/job/enums.proto
+++ b/stats/enums/server/job/enums.proto
@@ -41,4 +41,6 @@
     CONSTRAINT_WITHIN_QUOTA = 10;
     CONSTRAINT_BACKGROUND_NOT_RESTRICTED = 11;
     CONSTRAINT_WITHIN_EXPEDITED_JOB_QUOTA = 12;
+    CONSTRAINT_TARE_WEALTH = 13;
+    CONSTRAINT_PREFETCH = 14;
 }