[Metrics] Add profile connection attempt and completion atoms

Test: atoms definition only

Bug: 285027829

Merged-In: Iae982f445e72f23799af06ddcd8726927c7e5fc6

Change-Id: Ic070bc13831c8578cb6d86159a2688969da36d54
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 59896b4..815a420 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -810,6 +810,7 @@
     extensions 664; // RkpdPoolStats rkpd_pool_stats
     extensions 665; // RkpdClientOperation rkpd_client_operation
     extensions 666;  // RestrictedBluetoothDeviceNameReported restricted_bluetooth_device_name_reported
+    extensions 696; // BluetoothProfileConnectionAttempted bluetooth_profile_connection_attempted
     extensions 9999; // Atom9999 atom_9999
     // StatsdStats tracks platform atoms with ids up to 900.
     // Update StatsdStats::kMaxPushedAtomId when atom ids here approach that value.
diff --git a/stats/atoms/bluetooth/bluetooth_extension_atoms.proto b/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
index 454d645..58560db 100644
--- a/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
+++ b/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
@@ -41,6 +41,8 @@
           (module) = "bt_restricted",
           (restriction_category) = RESTRICTION_DIAGNOSTIC
         ];
+  optional BluetoothProfileConnectionAttempted bluetooth_profile_connection_attempted
+    = 696 [(module) = "bluetooth"];
 }
 
 /**
@@ -197,3 +199,28 @@
   optional string device_name = 1
       [(field_restriction_option).peripheral_device_info = true];
 }
+
+/**
+ * Logs profile connection known completions.
+ *
+ * Logged from:
+ *     packages/modules/Bluetooth
+ */
+message BluetoothProfileConnectionAttempted {
+  // The profile that is connected. Eg. GATT, A2DP, HEADSET.
+  // From android.bluetooth.BluetoothAdapter.java
+  // Default: 0 when not used
+  optional int32 bt_profile = 1;
+
+  // Result of Profile connection
+  optional android.bluetooth.ProfileConnectionResult result = 2;
+
+  // Previous connection state
+  optional android.bluetooth.ConnectionStateEnum previous_state = 3;
+
+  // Terminating connection state
+  optional android.bluetooth.ConnectionStateEnum current_state = 4;
+
+  // Reason for the connection result
+  optional android.bluetooth.ProfileConnectionReason reason = 5;
+}
diff --git a/stats/enums/bluetooth/enums.proto b/stats/enums/bluetooth/enums.proto
index 6c9afab..a081118 100644
--- a/stats/enums/bluetooth/enums.proto
+++ b/stats/enums/bluetooth/enums.proto
@@ -412,3 +412,15 @@
     MAJOR_CLASS_TOY = 0x0800;
     MAJOR_CLASS_HEALTH = 0x0900;
 }
+
+enum ProfileConnectionResult {
+    RESULT_UNKNOWN = 0;
+    RESULT_SUCCESS = 1;
+    RESULT_FAILURE = 2;
+}
+
+enum ProfileConnectionReason {
+    REASON_UNKNOWN = 0;
+    REASON_SUCCESS = 1;
+    REASON_UNEXPECTED_STATE = 2;
+}