Merge "Update HealthConnectUsageStats atom to add monthly active users." into udc-mainline-prod
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 69ff007..221c45e 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -1051,6 +1051,7 @@
     extensions 722; // WifiIsUnusableReported wifi_is_unusable_reported
     extensions 723; // WifiApCapabilitiesReported wifi_ap_capabilities_reported
     extensions 735; // SandboxActivityEventOccurred sandbox_activity_event_occurred
+    extensions 752; // StatsSocketLossReported stats_socket_loss_reported
     extensions 756; // AdServicesMeasurementClickVerification ad_services_measurement_click_verification
     extensions 9999; // Atom9999 atom_9999
     // StatsdStats tracks platform atoms with ids up to 900.
diff --git a/stats/atoms/statsd/statsd_extension_atoms.proto b/stats/atoms/statsd/statsd_extension_atoms.proto
index 64d8558..8e2327c 100644
--- a/stats/atoms/statsd/statsd_extension_atoms.proto
+++ b/stats/atoms/statsd/statsd_extension_atoms.proto
@@ -28,7 +28,9 @@
     optional TestExtensionAtomReported test_extension_atom_reported =
             660 [(module) = "cts", (module) = "statsdtest"];
     optional TestRestrictedAtomReported test_restricted_atom_reported = 672
-    [(module) = "cts", (android.os.statsd.restriction_category) = RESTRICTION_DIAGNOSTIC];
+    [(module) = "cts", (restriction_category) = RESTRICTION_DIAGNOSTIC];
+    optional StatsSocketLossReported stats_socket_loss_reported =
+            752 [(module) = "statsdsocket", (module) = "statsd"];
 }
 
 message TestExtensionAtomNestedMessage {
@@ -67,3 +69,62 @@
     optional string string_field = 4;
     optional bool boolean_field = 5;
 }
+
+/**
+ * Represents the atom loss info from libstatssocket
+ */
+message StatsSocketLossReported {
+
+    /**
+     * initial set of errors defined based on write() API potential codes
+     * and what is observed via statsdstats LogLosStats.last_error
+     */
+    enum SocketLossError {
+        SOCKET_LOSS_ERROR_UNKNOWN = 0;
+
+        // errno based error codes are negated to not overlap with internal codes
+        // Values are aligned with what is reported by StatsdStatsReport::LogLossStats
+        SOCKET_LOSS_ERROR_ON_WRITE_EDQUOT = -122;
+        SOCKET_LOSS_ERROR_ON_WRITE_EDESTADDRREQ = -89;
+        SOCKET_LOSS_ERROR_ON_WRITE_EPIPE = -32;
+        SOCKET_LOSS_ERROR_ON_WRITE_ENOSPC = -28;
+        SOCKET_LOSS_ERROR_ON_WRITE_EFBIG = -27;
+        SOCKET_LOSS_ERROR_ON_WRITE_EINVAL = -22;
+        SOCKET_LOSS_ERROR_ON_WRITE_ENODEV = -19;
+        SOCKET_LOSS_ERROR_ON_WRITE_EFAULT = -14;
+        SOCKET_LOSS_ERROR_ON_WRITE_EAGAIN = -11; // same as EWOULDBLOCK
+        SOCKET_LOSS_ERROR_ON_WRITE_EBADF = -9;
+        SOCKET_LOSS_ERROR_ON_WRITE_EIO = -5;
+        SOCKET_LOSS_ERROR_ON_WRITE_EINTR = -4;
+        SOCKET_LOSS_ERROR_ON_WRITE_EPERM = -1;
+
+        // internal error codes are positive
+        SOCKET_LOSS_ERROR_QUEUE_OVERFLOW = 1;
+    }
+
+    optional int32 uid = 1 [(is_uid) = true];
+
+    /* denotes timestamp when first socket loss event detected */
+    optional int64 first_timestamp_nanos = 2;
+
+    /* denotes timestamp when last socket loss event detected */
+    optional int64 last_timestamp_nanos = 3;
+
+    /* represents number of times loss info container hits guarrail */
+    optional int32 overflow_count = 4;
+
+    /**
+     * below tuples represent number of times atom loss detected for the pair [error, tag],
+     * where for each pair such as [errors[i], tags[i]] there is a matching counts[i] element
+     *
+     * For ex:
+     * errors [EBUSY,ERROR1,EBUSY,ERROR2]
+     * tags   [    5,     6,    6,     5]
+     * counts [    2,     1,    1,     1]
+     */
+    repeated SocketLossError errors = 5;
+
+    repeated int32 tags = 6;
+
+    repeated int32 counts = 7;
+}
diff --git a/stats/enums/adservices/measurement/enums.proto b/stats/enums/adservices/measurement/enums.proto
index f0fb2e0..7cf12e7 100644
--- a/stats/enums/adservices/measurement/enums.proto
+++ b/stats/enums/adservices/measurement/enums.proto
@@ -79,6 +79,7 @@
   SERIALIZATION_ERROR_REPORT_UPLOAD_FAILURE_TYPE = 6;
   ENCRYPTION_ERROR_REPORT_UPLOAD_FAILURE_TYPE = 7;
   UNSUCCESSFUL_HTTP_RESPONSE_CODE_FAILURE_TYPE = 8;
+  REPORT_NOT_FOUND_FAILURE_TYPE = 9;
 }
 
 /**