[BluetoothMetrics] Adding new atom for BluetoothLeSessionConnected

Bug: 268252025
Change-Id: I949888fa8c001fdbc0e5896e43e35f0fedaed2ab
(cherry picked from commit c762883ba51f65d79cbe0b0155b56a2731b906b6)
Merged-In: I949888fa8c001fdbc0e5896e43e35f0fedaed2ab
Merged-In: Ie0727b18ff916dfe5e569f8b8365a99680cf4a55
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 5334c27..7e8b99c 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -747,6 +747,8 @@
     extensions 615; // BluetoothL2capCocServerConnection bluetooth_l2cap_coc_server_connection
     extensions 631; // FullScreenIntentLaunched full_screen_intent_launched
     extensions 632; // BalAllowed bal_allowed
+    extensions 656; // BluetoothLeSessionConnected bluetooth_le_session_connected
+    extensions 9999; // Atom9999 atom_9999
 
     // Pulled events will start at field 10000.
     // Next: 10175
diff --git a/stats/atoms/bluetooth/bluetooth_extension_atoms.proto b/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
index 45d2a0b..4c9325a 100644
--- a/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
+++ b/stats/atoms/bluetooth/bluetooth_extension_atoms.proto
@@ -21,6 +21,8 @@
 import "frameworks/proto_logging/stats/atom_field_options.proto";
 import "frameworks/proto_logging/stats/atoms.proto";
 import "frameworks/proto_logging/stats/enums/bluetooth/enums.proto";
+import "frameworks/proto_logging/stats/enums/bluetooth/hci/enums.proto";
+import "frameworks/proto_logging/stats/enums/bluetooth/le/enums.proto";
 
 option java_package = "com.android.os.bluetooth";
 option java_multiple_files = true;
@@ -32,6 +34,8 @@
         = 614 [(module) = "bluetooth"];
     optional BluetoothL2capCocServerConnection bluetooth_l2cap_coc_server_connection
         = 615 [(module) = "bluetooth"];
+    optional BluetoothLeSessionConnected bluetooth_le_session_connected
+        = 656 [(module) = "bluetooth"];
 }
 
 /**
@@ -114,3 +118,46 @@
  // Timeout for connection acceptance. -1 if not timeout.
  optional int64 timeout_millis = 6;
 }
+
+/**
+ * Logs when Bluetooth LE Connection Session is made
+ *
+ * Logged from: system/bt
+ */
+message BluetoothLeSessionConnected {
+  // Contains the state of the LE Connection Session
+  // Default: LE_ACL_ABSENT
+  optional android.bluetooth.le.LeAclConnectionState acl_state = 1;
+  // Origin type of the connection whether it was from the ORIGIN_JAVA
+  // or the ORIGIN_NATIVE layer
+  // Default: ORIGIN_NATIVE
+  optional android.bluetooth.le.LeConnectionOriginType connection_origin = 2;
+  // Contains the connection type whether it was CONNECTION_TYPE_GATT
+  // ,CONNECTION_TYPE_LE_ACL
+  // Default: CONNECTION_TYPE_LE_ACL
+  optional android.bluetooth.le.LeConnectionType connection_type = 3;
+  // Connection State which contain the last state associated with the
+  // event
+  // Default: STATE_UNSPECIFIED
+  optional android.bluetooth.le.LeConnectionState state = 4;
+  // Contains the latency of the transaction from the beginning till
+  // the end:
+  // Default: 0
+  optional int64 latency_nanos = 5;
+  // Contains the metric id associated with the remote device
+  // Default: 0
+  optional int32 metric_id = 6;
+  // Contains the UID which is associated with the app
+  // Default: 0
+  optional int32 app_uid = 7 [(is_uid) = true];
+  // Contains the latency of the ACL Connection, which if made will be
+  // greater than 0
+  // Default: 0
+  optional int64 acl_latency_nanos = 8;
+  // Contains the status of the ACL Transactions, which if made will be
+  // something other than STATUS_UNKNOWN Default: STATUS_UNKNOWN
+  optional android.bluetooth.hci.StatusEnum acl_connection_state = 9;
+  // Identifies whether the LE-ACL Connection failed due to cancellation
+  // Default: false
+  optional bool is_cancelled = 10;
+}
diff --git a/stats/enums/bluetooth/Android.bp b/stats/enums/bluetooth/Android.bp
index 5f7d6d9..b824249 100644
--- a/stats/enums/bluetooth/Android.bp
+++ b/stats/enums/bluetooth/Android.bp
@@ -30,6 +30,7 @@
         "enums.proto",
         "hci/enums.proto",
         "hfp/enums.proto",
+        "le/enums.proto",
         "smp/enums.proto",
     ],
     apex_available: [
@@ -45,6 +46,7 @@
       "enums.proto",
       "hci/enums.proto",
       "hfp/enums.proto",
+      "le/enums.proto",
       "smp/enums.proto",
   ],
 }
diff --git a/stats/enums/bluetooth/BUILD.gn b/stats/enums/bluetooth/BUILD.gn
index e1f398e..0572bfc 100644
--- a/stats/enums/bluetooth/BUILD.gn
+++ b/stats/enums/bluetooth/BUILD.gn
@@ -23,6 +23,7 @@
     "a2dp/enums.proto",
     "enums.proto",
     "hci/enums.proto",
+    "le/enums.proto",
     "hfp/enums.proto",
     "smp/enums.proto",
   ]
diff --git a/stats/enums/bluetooth/le/enums.proto b/stats/enums/bluetooth/le/enums.proto
new file mode 100644
index 0000000..1a4b128
--- /dev/null
+++ b/stats/enums/bluetooth/le/enums.proto
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2018 The Android Open Source Project
+ *
+ * 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 = "proto2";
+package android.bluetooth.le;
+
+option java_outer_classname = "BluetoothLEProtoEnums";
+option java_multiple_files = true;
+
+
+// LE ACL Connection State. This as per - go/bluetooth-le-connection-metrics
+enum LeAclConnectionState {
+  LE_ACL_UNSPECIFIED = 0;
+  LE_ACL_SUCCESS = 1;
+  LE_ACL_FAILED = 2;
+  LE_ACL_ALREADY_PRESENT = 3;
+}
+
+// Connection Origin type.
+enum LeConnectionOriginType {
+  ORIGIN_UNSPECIFIED = 0;
+  ORIGIN_NATIVE = 1;
+  ORIGIN_JAVA = 2;
+}
+
+// LE Connection Type
+enum LeConnectionType {
+  CONNECTION_TYPE_UNSPECIFIED = 0;
+  CONNECTION_TYPE_LE_ACL = 1;
+  CONNECTION_TYPE_GATT = 2;
+  CONNECTION_TYPE_L2CAP_FIXED_CHNL_SMP = 3;
+  CONNECTION_TYPE_L2CAP_FIXED_CHNL_ATT = 4;
+  CONNECTION_TYPE_L2CAP_FIXED_CHNL_LE_SIGNALLING = 5;
+}
+
+// LE Connection State
+enum LeConnectionState {
+  STATE_UNSPECIFIED = 0;
+  STATE_LE_ACL_START = 1;
+  STATE_LE_ACL_END = 2;
+  STATE_LE_ACL_CANCEL = 3;
+  STATE_LE_ACL_TIMEOUT = 4;
+  STATE_GATT_APP_USE_LINK_FLAG = 5;
+  STATE_GATT_CREATE_DIRECT_CONN = 6;
+  STATE_GATT_HOLD_LINK_EMPTY = 7;
+  STATE_GATT_CONNECT_NATIVE = 8;
+  STATE_GATT_APP_CREATE_LE_ACL = 9;
+  STATE_GATT_CONN_STATE_CHANGE_CLIENT = 10;
+  STATE_GATT_CONN_STATE_CHANGE_SERVER = 11;
+  STATE_L2CAP_FIXED_CHNL_START_CREATE_CONN = 12;
+  STATE_L2CAP_FIXED_CHNL_START_LE_ACL = 13;
+  STATE_L2CAP_FIXED_CHNL_LE_ACL_FINISH = 14;
+}
+