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