1 /****************************************************************************** 2 * 3 * Copyright (C) 2016 Google, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 #pragma once 20 21 #include <stdint.h> 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 // Typedefs to hide protobuf definition to the rest of stack 27 28 typedef enum { 29 DEVICE_TYPE_UNKNOWN, 30 DEVICE_TYPE_BREDR, 31 DEVICE_TYPE_LE, 32 DEVICE_TYPE_DUMO, 33 } device_type_t; 34 35 typedef enum { 36 WAKE_EVENT_UNKNOWN, 37 WAKE_EVENT_ACQUIRED, 38 WAKE_EVENT_RELEASED, 39 } wake_event_type_t; 40 41 typedef enum { 42 SCAN_TYPE_UNKNOWN, 43 SCAN_TECH_TYPE_LE, 44 SCAN_TECH_TYPE_BREDR, 45 SCAN_TECH_TYPE_BOTH, 46 } scan_tech_t; 47 48 typedef enum { 49 CONNECTION_TECHNOLOGY_TYPE_UNKNOWN, 50 CONNECTION_TECHNOLOGY_TYPE_LE, 51 CONNECTION_TECHNOLOGY_TYPE_BREDR, 52 } connection_tech_t; 53 54 typedef enum { 55 DISCONNECT_REASON_UNKNOWN, 56 DISCONNECT_REASON_METRICS_DUMP, 57 DISCONNECT_REASON_NEXT_START_WITHOUT_END_PREVIOUS, 58 } disconnect_reason_t; 59 60 typedef struct { 61 int64_t audio_duration_ms; 62 int32_t media_timer_min_ms; 63 int32_t media_timer_max_ms; 64 int32_t media_timer_avg_ms; 65 int64_t total_scheduling_count; 66 int32_t buffer_overruns_max_count; 67 int32_t buffer_overruns_total; 68 float buffer_underruns_average; 69 int32_t buffer_underruns_count; 70 } A2dpSessionMetrics_t; 71 72 void metrics_log_pair_event(uint32_t disconnect_reason, uint64_t timestamp_ms, 73 uint32_t device_class, device_type_t device_type); 74 75 void metrics_log_wake_event(wake_event_type_t type, const char* requestor, 76 const char* name, uint64_t timestamp_ms); 77 78 void metrics_log_scan_event(bool start, const char* initator, scan_tech_t type, 79 uint32_t results, uint64_t timestamp_ms); 80 81 void metrics_log_bluetooth_session_start(connection_tech_t connection_tech_type, 82 uint64_t timestamp_ms); 83 84 void metrics_log_bluetooth_session_end(disconnect_reason_t disconnect_reason, 85 uint64_t timestamp_ms); 86 87 void metrics_log_bluetooth_session_device_info(uint32_t device_class, 88 device_type_t device_type); 89 90 void metrics_log_a2dp_session(A2dpSessionMetrics_t* metrics); 91 92 void metrics_write_base64(int fd, bool clear); 93 94 #ifdef __cplusplus 95 } 96 #endif 97