1/*
2 * Copyright (C) 2018 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
19// C++ namespace: bluetooth::metrics::BluetoothMetricsProto
20package bluetooth.metrics.BluetoothMetricsProto;
21
22option java_package = "com.android.bluetooth";
23option java_outer_classname = "BluetoothMetricsProto";
24
25message BluetoothLog {
26  // Session information that gets logged for every BT connection.
27  repeated BluetoothSession session = 1;
28
29  // Session information that gets logged for every Pair event.
30  repeated PairEvent pair_event = 2;
31
32  // Information for Wake locks.
33  repeated WakeEvent wake_event = 3;
34
35  // Scan event information.
36  repeated ScanEvent scan_event = 4;
37
38  // Number of bonded devices.
39  optional int32 num_bonded_devices = 5;
40
41  // Number of BluetoothSession including discarded ones beyond capacity
42  optional int64 num_bluetooth_session = 6;
43
44  // Number of PairEvent including discarded ones beyond capacity
45  optional int64 num_pair_event = 7;
46
47  // Number of WakeEvent including discarded ones beyond capacity
48  optional int64 num_wake_event = 8;
49
50  // Number of ScanEvent including discarded ones beyond capacity
51  optional int64 num_scan_event = 9;
52
53  // Statistics about Bluetooth profile connections
54  repeated ProfileConnectionStats profile_connection_stats = 10;
55
56  // Statistics about Headset profile connections
57  repeated HeadsetProfileConnectionStats headset_profile_connection_stats = 11;
58}
59
60// The information about the device.
61message DeviceInfo {
62  // Device type.
63  enum DeviceType {
64    // Type is unknown.
65    DEVICE_TYPE_UNKNOWN = 0;
66
67    DEVICE_TYPE_BREDR = 1;
68
69    DEVICE_TYPE_LE = 2;
70
71    DEVICE_TYPE_DUMO = 3;
72  }
73
74  // Device class
75  // https://cs.corp.google.com/#android/system/bt/stack/include/btm_api.h&q=major_computer.
76  optional int32 device_class = 1;
77
78  // Device type.
79  optional DeviceType device_type = 2;
80}
81
82// Information that gets logged for every Bluetooth connection.
83message BluetoothSession {
84  // Type of technology used in the connection.
85  enum ConnectionTechnologyType {
86    CONNECTION_TECHNOLOGY_TYPE_UNKNOWN = 0;
87
88    CONNECTION_TECHNOLOGY_TYPE_LE = 1;
89
90    CONNECTION_TECHNOLOGY_TYPE_BREDR = 2;
91  }
92
93  enum DisconnectReasonType {
94    UNKNOWN = 0;
95
96    // A metrics dump takes a snapshot of current Bluetooth session and thus
97    // is not a real disconnect, but a discontinuation in metrics logging.
98    // This enum indicates this situation.
99    METRICS_DUMP = 1;
100
101    NEXT_START_WITHOUT_END_PREVIOUS = 2;
102  }
103
104  // Duration of the session.
105  optional int64 session_duration_sec = 2;
106
107  // Technology type.
108  optional ConnectionTechnologyType connection_technology_type = 3;
109
110  // Reason for disconnecting.
111  optional string disconnect_reason = 4 [deprecated = true];
112
113  // The information about the device which it is connected to.
114  optional DeviceInfo device_connected_to = 5;
115
116  // The information about the RFComm session.
117  optional RFCommSession rfcomm_session = 6;
118
119  // The information about the A2DP audio session.
120  optional A2DPSession a2dp_session = 7;
121
122  // Numeric reason for disconnecting as defined in metrics.h
123  optional DisconnectReasonType disconnect_reason_type = 8;
124}
125
126message RFCommSession {
127  // bytes transmitted.
128  optional int32 rx_bytes = 1;
129
130  // bytes transmitted.
131  optional int32 tx_bytes = 2;
132}
133
134enum A2dpSourceCodec {
135  A2DP_SOURCE_CODEC_UNKNOWN = 0;
136  A2DP_SOURCE_CODEC_SBC = 1;
137  A2DP_SOURCE_CODEC_AAC = 2;
138  A2DP_SOURCE_CODEC_APTX = 3;
139  A2DP_SOURCE_CODEC_APTX_HD = 4;
140  A2DP_SOURCE_CODEC_LDAC = 5;
141}
142
143// Session information that gets logged for A2DP session.
144message A2DPSession {
145  // Media timer in milliseconds.
146  optional int32 media_timer_min_millis = 1;
147
148  // Media timer in milliseconds.
149  optional int32 media_timer_max_millis = 2;
150
151  // Media timer in milliseconds.
152  optional int32 media_timer_avg_millis = 3;
153
154  // Buffer overruns count.
155  optional int32 buffer_overruns_max_count = 4;
156
157  // Buffer overruns total.
158  optional int32 buffer_overruns_total = 5;
159
160  // Buffer underruns average.
161  optional float buffer_underruns_average = 6;
162
163  // Buffer underruns count.
164  optional int32 buffer_underruns_count = 7;
165
166  // Total audio time in this A2DP session
167  optional int64 audio_duration_millis = 8;
168
169  // Audio codec used in this A2DP session in A2DP source role
170  optional A2dpSourceCodec source_codec = 9;
171
172  // Whether A2DP offload is enabled in this A2DP session
173  optional bool is_a2dp_offload = 10;
174}
175
176message PairEvent {
177  // The reason for disconnecting
178  // See: system/bt/stack/include/hcidefs.h, HCI_ERR_CONN_FAILED_ESTABLISHMENT
179  optional int32 disconnect_reason = 1;
180
181  // Pair event time
182  optional int64 event_time_millis = 2;  // [(datapol.semantic_type) = ST_TIMESTAMP];
183
184  // The information about the device which it is paired to.
185  optional DeviceInfo device_paired_with = 3;
186}
187
188message WakeEvent {
189  // Information about the wake event type.
190  enum WakeEventType {
191    UNKNOWN = 0;
192    // WakeLock was acquired.
193    ACQUIRED = 1;
194    // WakeLock was released.
195    RELEASED = 2;
196  }
197
198  // Information about the wake event type.
199  optional WakeEventType wake_event_type = 1;
200
201  // Initiator of the scan. Only the first three names will be stored.
202  // e.g. com.company.app
203  optional string requestor = 2;
204
205  // Name of the wakelock (e.g. bluedroid_timer).
206  optional string name = 3;
207
208  // Time of the event.
209  optional int64 event_time_millis = 4;  // [(datapol.semantic_type) = ST_TIMESTAMP];
210}
211
212message ScanEvent {
213  // Scan type.
214  enum ScanTechnologyType {
215    SCAN_TYPE_UNKNOWN = 0;
216
217    SCAN_TECH_TYPE_LE = 1;
218
219    SCAN_TECH_TYPE_BREDR = 2;
220
221    SCAN_TECH_TYPE_BOTH = 3;
222  }
223
224  // Scan event type.
225  enum ScanEventType {
226    // Scan started.
227    SCAN_EVENT_START = 0;
228    // Scan stopped.
229    SCAN_EVENT_STOP = 1;
230  }
231
232  // Scan event type.
233  optional ScanEventType scan_event_type = 1;
234
235  // Initiator of the scan. Only the first three names will be stored.
236  // e.g. com.company.app
237  optional string initiator = 2;
238
239  // Technology used for scanning.
240  optional ScanTechnologyType scan_technology_type = 3;
241
242  // Number of results returned.
243  optional int32 number_results = 4;
244
245  // Time of the event.
246  optional int64 event_time_millis = 5;  // [(datapol.semantic_type) = ST_TIMESTAMP];
247}
248
249// Profile IDs defined in BluetoothProfile API class
250// Values must match API class values
251enum ProfileId {
252  PROFILE_UNKNOWN = 0;
253  HEADSET = 1;
254  A2DP = 2;
255  HEALTH = 3;
256  HID_HOST = 4;
257  PAN = 5;
258  PBAP = 6;
259  GATT = 7;
260  GATT_SERVER = 8;
261  MAP = 9;
262  SAP = 10;
263  A2DP_SINK = 11;
264  AVRCP_CONTROLLER = 12;
265  AVRCP = 13;
266  HEADSET_CLIENT = 16;
267  PBAP_CLIENT = 17;
268  MAP_CLIENT = 18;
269  HID_DEVICE = 19;
270  OPP = 20;
271  HEARING_AID = 21;
272}
273
274// Statistics about Bluetooth profile connections
275message ProfileConnectionStats {
276  // Profile id defined in BluetoothProfile.java
277  optional ProfileId profile_id = 1;
278
279  // Number of times that this profile is connected since last metrics dump
280  optional int32 num_times_connected = 2;
281}
282
283enum HeadsetProfileType {
284  HEADSET_PROFILE_UNKNOWN = 0;
285  HSP = 1;
286  HFP = 2;
287}
288
289// Statistics about headset profile connections
290message HeadsetProfileConnectionStats {
291  // Type of headset profile connected
292  optional HeadsetProfileType headset_profile_type = 1;
293
294  // Number of times this type of headset profile is connected
295  optional int32 num_times_connected = 2;
296}