1/* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18 19package android.os.statsd.bluetooth; 20 21import "frameworks/proto_logging/stats/attribution_node.proto"; 22import "frameworks/proto_logging/stats/atom_field_options.proto"; 23import "frameworks/proto_logging/stats/atoms.proto"; 24import "frameworks/proto_logging/stats/enums/bluetooth/enums.proto"; 25import "frameworks/proto_logging/stats/enums/bluetooth/hci/enums.proto"; 26import "frameworks/proto_logging/stats/enums/bluetooth/le/enums.proto"; 27import "frameworks/proto_logging/stats/enums/bluetooth/rfcomm/enums.proto"; 28 29option java_package = "com.android.os.bluetooth"; 30option java_multiple_files = true; 31 32extend Atom { 33 optional BluetoothHashedDeviceNameReported bluetooth_hashed_device_name_reported 34 = 613 [(module) = "bluetooth"]; 35 optional BluetoothL2capCocClientConnection bluetooth_l2cap_coc_client_connection 36 = 614 [(module) = "bluetooth"]; 37 optional BluetoothL2capCocServerConnection bluetooth_l2cap_coc_server_connection 38 = 615 [(module) = "bluetooth"]; 39 optional BluetoothLeSessionConnected bluetooth_le_session_connected 40 = 656 [(module) = "bluetooth"]; 41 optional RestrictedBluetoothDeviceNameReported 42 restricted_bluetooth_device_name_reported = 666 [ 43 (module) = "bt_restricted", 44 (restriction_category) = RESTRICTION_DIAGNOSTIC 45 ]; 46 optional BluetoothProfileConnectionAttempted bluetooth_profile_connection_attempted 47 = 696 [(module) = "bluetooth"]; 48 optional BluetoothContentProfileErrorReported bluetooth_content_profile_error_reported 49 = 781 [(module) = "bluetooth"]; 50 optional BluetoothRfcommConnectionAttempted bluetooth_rfcomm_connection_attempted 51 = 782 [(module) = "bluetooth"]; 52 optional RemoteDeviceInformationWithMetricId remote_device_information_with_metric_id = 862 [(module) = "bluetooth"]; 53 optional LeAppScanStateChanged le_app_scan_state_changed 54 = 870 [(module) = "bluetooth"]; 55 optional LeRadioScanStopped le_radio_scan_stopped 56 = 871 [(module) = "bluetooth"]; 57 optional LeScanResultReceived le_scan_result_received 58 = 872 [(module) = "bluetooth"]; 59 optional LeScanAbused le_scan_abused 60 = 873 [(module) = "bluetooth"]; 61 optional LeAdvStateChanged le_adv_state_changed 62 = 874 [(module) = "bluetooth"]; 63 optional LeAdvErrorReported le_adv_error_reported 64 = 875 [(module) = "bluetooth"]; 65} 66 67/** 68* Logs hashed Bluetooth device names 69* 70* Logged from: 71* packages/modules/Bluetooth 72*/ 73message BluetoothHashedDeviceNameReported { 74 75 // An identifier that can be used to match events for this device. 76 // The incremental identifier is locally generated and guaranteed not derived 77 // from any globally unique hardware id. 78 // For paired devices, it stays consistent between Bluetooth toggling for the 79 // same remote device. 80 // For unpaired devices, it stays consistent within the same Bluetooth adapter 81 // session for the same remote device. 82 // Default: 0 if the device's metric id is unknown. 83 optional int32 metric_id = 1; 84 85 // SHA256 hashed Bluetooth device name. 86 optional string device_name_hash = 2; 87} 88 89/** 90* Logs when L2CAP CoC on a Bluetooth device connects and disconnects. 91*/ 92message BluetoothL2capCocClientConnection { 93 94 // An identifier that can be used to match events for this device. 95 // The incremental identifier is locally generated and guaranteed not derived 96 // from any globally unique hardware id. 97 // For paired devices, it stays consistent between Bluetooth toggling for the 98 // same remote device. 99 // For unpaired devices, it stays consistent within the same Bluetooth adapter 100 // session for the same remote device. 101 // Default: 0 if the device's metric id is unknown. 102 optional int32 metric_id = 1; 103 104 // Port used for the connection session 105 optional int32 port = 2; 106 107 // Flag to show if the connection is secured or not 108 optional bool is_secured = 3; 109 110 // Result of L2CAP CoC connection 111 optional android.bluetooth.L2capCocConnectionResult result = 4; 112 113 // Latency between connection start and end 114 optional int64 connection_latency_millis = 5; 115 116 // Uid of the app who calls l2cap coc connection API 117 optional int32 uid = 6 [(is_uid) = true]; 118 119 // Latency of BluetoothSocket constructor 120 optional int64 socket_creation_latency_millis = 7; 121 122 // Latency of BluetoothSocket.connect 123 optional int64 socket_connection_latency_millis = 8; 124} 125 126/** 127* Logs when L2CAP CoC on a Bluetooth device connects and disconnects. 128*/ 129message BluetoothL2capCocServerConnection { 130 131 // An identifier that can be used to match events for this device. 132 // The incremental identifier is locally generated and guaranteed not derived 133 // from any globally unique hardware id. 134 // For paired devices, it stays consistent between Bluetooth toggling for the 135 // same remote device. 136 // For unpaired devices, it stays consistent within the same Bluetooth adapter 137 // session for the same remote device. 138 // Default: 0 if the device's metric id is unknown. 139 optional int32 metric_id = 1; 140 141 // Port used for the connection session 142 optional int32 port = 2; 143 144 // Flag to show if the connection is secured or not 145 optional bool is_secured = 3; 146 147 // Result of L2CAP CoC connection 148 optional android.bluetooth.L2capCocConnectionResult result = 4; 149 150 // Latency between connection start and end 151 optional int64 latency_since_listening_millis = 5; 152 153 // Timeout for connection acceptance. -1 if not timeout. 154 optional int64 timeout_millis = 6; 155 156 // Uid of the app who calls l2cap coc connection API 157 optional int32 uid = 7 [(is_uid) = true]; 158 159 // Latency of BluetoothServerSocket constructor 160 optional int64 socket_creation_latency_millis = 8; 161 162 // Latency of BluetoothServerSocket.accept 163 optional int64 socket_acceptance_latency_millis = 9; 164} 165 166/** 167 * Logs when Bluetooth LE Connection Session is made 168 * 169 * Logged from: system/bt 170 */ 171message BluetoothLeSessionConnected { 172 // Contains the state of the LE Connection Session 173 // Default: LE_ACL_ABSENT 174 optional android.bluetooth.le.LeAclConnectionState acl_state = 1; 175 // Origin type of the connection whether it was from the ORIGIN_JAVA 176 // or the ORIGIN_NATIVE layer 177 // Default: ORIGIN_NATIVE 178 optional android.bluetooth.le.LeConnectionOriginType connection_origin = 2; 179 // Contains the connection type whether it was CONNECTION_TYPE_GATT 180 // ,CONNECTION_TYPE_LE_ACL 181 // Default: CONNECTION_TYPE_LE_ACL 182 optional android.bluetooth.le.LeConnectionType connection_type = 3; 183 // Connection State which contain the last state associated with the 184 // event 185 // Default: STATE_UNSPECIFIED 186 optional android.bluetooth.le.LeConnectionState state = 4; 187 // Contains the latency of the transaction from the beginning till 188 // the end: 189 // Default: 0 190 optional int64 latency_nanos = 5; 191 // Contains the metric id associated with the remote device 192 // Default: 0 193 optional int32 metric_id = 6; 194 // Contains the UID which is associated with the app 195 // Default: 0 196 optional int32 app_uid = 7 [(is_uid) = true]; 197 // Contains the latency of the ACL Connection, which if made will be 198 // greater than 0 199 // Default: 0 200 optional int64 acl_latency_nanos = 8; 201 // Contains the status of the ACL Transactions, which if made will be 202 // something other than STATUS_UNKNOWN Default: STATUS_UNKNOWN 203 optional android.bluetooth.hci.StatusEnum acl_connection_state = 9; 204 // Identifies whether the LE-ACL Connection failed due to cancellation 205 // Default: false 206 optional bool is_cancelled = 10; 207} 208 209/** 210 * Logs the user created Bluetooth device's name. 211 * It is pushed at Bluetooth pairing and connection. 212 * 213 * Logged from: 214 * packages/modules/Bluetooth 215 */ 216message RestrictedBluetoothDeviceNameReported { 217 // Name of the Bluetooth device. It is created by the user. 218 optional string device_name = 1 219 [(field_restriction_option).peripheral_device_info = true]; 220} 221 222/** 223 * Logs profile connection known completions. 224 * 225 * Logged from: 226 * packages/modules/Bluetooth 227 */ 228message BluetoothProfileConnectionAttempted { 229 // The profile that is connected. Eg. GATT, A2DP, HEADSET. 230 // From android.bluetooth.BluetoothAdapter.java 231 // Default: 0 when not used 232 optional int32 bt_profile = 1; 233 234 // Result of Profile connection 235 optional android.bluetooth.ProfileConnectionResult result = 2; 236 237 // Previous connection state 238 optional android.bluetooth.ConnectionStateEnum previous_state = 3; 239 240 // Terminating connection state 241 optional android.bluetooth.ConnectionStateEnum current_state = 4; 242 243 // Reason for the connection result 244 optional android.bluetooth.ProfileConnectionReason reason = 5; 245 246 // Remote Device Information 247 optional BluetoothRemoteDeviceInformation remote_device_information = 6 [(log_mode) = MODE_BYTES]; 248} 249 250/** 251 * Logs content profiles' caught exceptions or logs (ERROR, WARN) 252 * 253 * Logged from: 254 * packages/modules/Bluetooth 255 */ 256message BluetoothContentProfileErrorReported { 257 enum ErrorType { 258 UNKNOWN = 0; 259 EXCEPTION = 1; 260 LOG_ERROR = 2; 261 LOG_WARN = 3; 262 } 263 264 // The content profile where the error happened. (E.g. PBAP, MAP, OPP) 265 // From android.bluetooth.BluetoothProfile.java 266 // Default: 0 when not used 267 optional int32 bt_profile = 1; 268 269 // The file name where the error is reported from 270 optional android.bluetooth.ContentProfileFileName file_name = 2; 271 272 // The type of error (exception, Log.e, Log.w) 273 optional ErrorType type = 3; 274 275 // Integer tag associated with the error 276 optional int32 tag = 4; 277} 278 279message BluetoothRemoteDeviceInformation { 280 // SHA256 hashed Bluetooth device name. 281 optional string allowlisted_device_name_hash = 1; 282 283 // Class of Device 284 optional int32 class_of_device = 2; 285 286 // The first three bytes of MAC address 287 optional int32 oui = 3; 288} 289 290/** 291* Logs RFCOMM connection attempts 292* 293* Logged from: 294* packages/modules/Bluetooth 295*/ 296message BluetoothRfcommConnectionAttempted { 297 // Locally generated id for event matching 298 optional int32 metric_id = 1; 299 300 // Latency of the connection 301 optional int64 latency_nanos = 2; 302 303 // Whether or not the connection is secured 304 optional android.bluetooth.rfcomm.SocketConnectionSecurity security = 3; 305 306 // Result of Rfcomm connection 307 optional android.bluetooth.rfcomm.RfcommConnectionResult status = 4; 308 309 // is_serial_port is true if the service class UUID is 0x1101 310 optional bool is_serial_port = 5; 311 312 // Uid of the app that calls RFCOMM connection API 313 optional int32 uid = 6 [(is_uid) = true]; // [(datapol.semantic_type) = ST_SOFTWARE_ID] 314 315 // Remote Device Information 316 optional BluetoothRemoteDeviceInformation remote_device_information = 7 [(log_mode) = MODE_BYTES]; 317} 318 319/** 320* Logs remote device information with metric ID 321* 322* Logged from: 323* packages/modules/Bluetooth 324*/ 325message RemoteDeviceInformationWithMetricId { 326 // Locally generated id for event matching 327 optional int32 metric_id = 1; 328 329 // Remote Device Information 330 optional BluetoothRemoteDeviceInformation remote_device_information = 2 [(log_mode) = MODE_BYTES]; 331 332} 333 334/** 335 * Logs LE app scan information when the scan starts and stops. 336 * 337 * Logged from: 338 * packages/modules/Bluetooth 339*/ 340message LeAppScanStateChanged { 341 repeated AttributionNode attribution_node = 1; 342 // True for scan start, false for scan stop. 343 optional bool enabled = 2; 344 // Does the scan have a filter. 345 optional bool is_filtered = 3; 346 // Whether the scan has callback function or pending intent. 347 optional bool is_callback_scan = 4; 348 optional android.bluetooth.le.LeScanCallbackType scan_callback_type = 5; 349 optional android.bluetooth.le.LeScanType le_scan_type = 6; 350 // For app scan modes, it is logged before being modified based on screen state. 351 optional android.bluetooth.le.LeScanMode le_scan_mode = 7; 352 // Time of delay for reporting the scan result in milliseconds. 353 optional int64 report_delay_ms = 8; 354 // Duration from scan start to stop in milliseconds. Use 0 for scan start. 355 optional int64 app_scan_duration_ms = 9; 356 // Number of scans on going when the scan started or stopped. 357 optional int32 num_ongoing_scan = 10; 358 // Screen state when the scan started or stopped. True for STATE_ON, false 359 // for any other state as defined in android.view.Display. 360 optional bool is_screen_on = 11; 361 // Whether the app is dead when the scan started or stopped. 362 optional bool is_app_dead = 12; 363} 364 365/** 366 * Logs the LE scan information when the radio scan is stopped or screen state 367 * changes which reconfigures the scan parameters. 368 * 369 * Logged from: 370 * packages/modules/Bluetooth 371 */ 372message LeRadioScanStopped { 373 // Attribution of the app with most aggressive scanning parameters, which 374 // will be used by the LE radio for the scanning. 375 repeated AttributionNode attribution_node_most_aggressive_app = 1; 376 optional android.bluetooth.le.LeScanType le_scan_type_most_aggressive_app = 2; 377 optional android.bluetooth.le.LeScanMode le_scan_mode_most_aggressive_app = 3; 378 // Radio scan interval in milliseconds. 379 optional int64 le_scan_radio_settings_interval_ms = 4; 380 // Radio Scan window in milliseconds. 381 optional int64 le_scan_radio_settings_window_ms = 5; 382 // True for STATE_ON, false for any other state as defined in 383 // android.view.Display. 384 optional bool is_screen_on = 6; 385 // Delta time of radio scan start and stop in milliseconds. 386 optional int64 scan_duration_ms = 7; 387} 388 389/** 390 * Logs the LE scan results information when regular and batched scan results 391 * are received. 392 * 393 * Logged from: 394 * packages/modules/Bluetooth 395 */ 396message LeScanResultReceived { 397 repeated AttributionNode attribution_node = 1; 398 // Number of ble scan results returned. 1 for regular scan, and use numRecords for batched scan 399 optional int32 num_results = 2; 400 optional android.bluetooth.le.LeScanType le_scan_type = 3; 401 // True for STATE_ON, false for any other state as defined in 402 // android.view.Display. 403 optional bool is_screen_on = 4; 404} 405 406 407/** 408 * Logs LE scan abuse count and details for scan request errors. 409 * 410 * Logged from: 411 * packages/modules/Bluetooth 412 */ 413message LeScanAbused{ 414 repeated AttributionNode attribution_node = 1; 415 optional android.bluetooth.le.LeScanType le_scan_type = 2; 416 // LE scan abuse reason. 417 optional android.bluetooth.le.LeScanAbuseReason le_scan_abuse_reason = 3; 418 // Logs the system configuration as details of the abuse reason. 419 // getScanTimeoutMillis() in AdapterService.java for REASON_SCAN_TIMEOUT. 420 // getNumOfOffloadedScanFilterSupported() in in AdapterService.java for 421 // REASON_HW_FILTER_NOT_AVAILABLE. 422 // getTotalNumOfTrackableAdvertisements() in AdapterService.java for 423 // REASON_TRACKING_HW_FILTER_NOT_AVAILABLE. 424 optional int64 le_scan_abuse_reason_details = 4; 425} 426 427/** 428 * Logs LE advertisement information when LE adv starts and stops. 429 * 430 * Logged from: 431 * packages/modules/Bluetooth 432 */ 433message LeAdvStateChanged { 434 repeated AttributionNode attribution_node = 1; 435 // LE advertisement state, true for adv start, false for adv stop. 436 optional bool enabled = 2; 437 // LE adv interval configuration. 438 optional android.bluetooth.le.LeAdvInterval adv_interval = 3; 439 // LE adv tx power configuration. 440 optional android.bluetooth.le.LeAdvTxPower adv_tx_power = 4; 441 // Whether the adv is connectable. 442 optional bool is_connectable = 5; 443 // Whether the adv is periodic. 444 optional bool is_periodic = 6; 445 // Whether the adv has scan response. 446 optional bool has_scan_response = 7; 447 // Whether the adv is extended adv. 448 optional bool is_extended_adv = 8; 449 // Number of total active advertisements when the current advertisement 450 // starts or stops. 451 optional int32 num_adv_instances_in_use = 9; 452 // Adv duration when adv stops (adv stop timestamp - adv start timestamp), 453 // in milliseconds. Use 0 for adv start. 454 optional int64 adv_duration_ms = 10; 455} 456 457/** 458 * Logs errors when LE advertising set starts. 459 * 460 * Logged from: 461 * packages/modules/Bluetooth 462 */ 463message LeAdvErrorReported { 464 repeated AttributionNode attribution_node = 1; 465 // Operation code for the adv error. 466 optional android.bluetooth.le.LeAdvOpCode le_adv_op_code = 2; 467 // The status code of internal state. 468 optional android.bluetooth.le.LeAdvStatusCode status_code = 3; 469} 470