Home | History | Annotate | Download | only in metrics
      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 
     17 syntax = "proto2";
     18 
     19 option optimize_for = LITE_RUNTIME;
     20 
     21 // C++ namespace: bluetooth::metrics::BluetoothMetricsProto
     22 package bluetooth.metrics.BluetoothMetricsProto;
     23 
     24 option java_package = "com.android.bluetooth";
     25 option java_outer_classname = "BluetoothMetricsProto";
     26 
     27 message 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.
     63 message 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.
     85 message 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 
    128 message RFCommSession {
    129   // bytes transmitted.
    130   optional int32 rx_bytes = 1;
    131 
    132   // bytes transmitted.
    133   optional int32 tx_bytes = 2;
    134 }
    135 
    136 // Session information that gets logged for A2DP session.
    137 message A2DPSession {
    138   // Media timer in milliseconds.
    139   optional int32 media_timer_min_millis = 1;
    140 
    141   // Media timer in milliseconds.
    142   optional int32 media_timer_max_millis = 2;
    143 
    144   // Media timer in milliseconds.
    145   optional int32 media_timer_avg_millis = 3;
    146 
    147   // Buffer overruns count.
    148   optional int32 buffer_overruns_max_count = 4;
    149 
    150   // Buffer overruns total.
    151   optional int32 buffer_overruns_total = 5;
    152 
    153   // Buffer underruns average.
    154   optional float buffer_underruns_average = 6;
    155 
    156   // Buffer underruns count.
    157   optional int32 buffer_underruns_count = 7;
    158 
    159   // Total audio time in this A2DP session
    160   optional int64 audio_duration_millis = 8;
    161 }
    162 
    163 message PairEvent {
    164   // The reason for disconnecting
    165   // See: system/bt/stack/include/hcidefs.h, HCI_ERR_CONN_FAILED_ESTABLISHMENT
    166   optional int32 disconnect_reason = 1;
    167 
    168   // Pair event time
    169   optional int64 event_time_millis =
    170       2;  // [(datapol.semantic_type) = ST_TIMESTAMP];
    171 
    172   // The information about the device which it is paired to.
    173   optional DeviceInfo device_paired_with = 3;
    174 }
    175 
    176 message WakeEvent {
    177   // Information about the wake event type.
    178   enum WakeEventType {
    179     UNKNOWN = 0;
    180     // WakeLock was acquired.
    181     ACQUIRED = 1;
    182     // WakeLock was released.
    183     RELEASED = 2;
    184   }
    185 
    186   // Information about the wake event type.
    187   optional WakeEventType wake_event_type = 1;
    188 
    189   // Initiator of the scan. Only the first three names will be stored.
    190   // e.g. com.company.app
    191   optional string requestor = 2;
    192 
    193   // Name of the wakelock (e.g. bluedroid_timer).
    194   optional string name = 3;
    195 
    196   // Time of the event.
    197   optional int64 event_time_millis =
    198       4;  // [(datapol.semantic_type) = ST_TIMESTAMP];
    199 }
    200 
    201 message ScanEvent {
    202   // Scan type.
    203   enum ScanTechnologyType {
    204     SCAN_TYPE_UNKNOWN = 0;
    205 
    206     SCAN_TECH_TYPE_LE = 1;
    207 
    208     SCAN_TECH_TYPE_BREDR = 2;
    209 
    210     SCAN_TECH_TYPE_BOTH = 3;
    211   }
    212 
    213   // Scan event type.
    214   enum ScanEventType {
    215     // Scan started.
    216     SCAN_EVENT_START = 0;
    217     // Scan stopped.
    218     SCAN_EVENT_STOP = 1;
    219   }
    220 
    221   // Scan event type.
    222   optional ScanEventType scan_event_type = 1;
    223 
    224   // Initiator of the scan. Only the first three names will be stored.
    225   // e.g. com.company.app
    226   optional string initiator = 2;
    227 
    228   // Technology used for scanning.
    229   optional ScanTechnologyType scan_technology_type = 3;
    230 
    231   // Number of results returned.
    232   optional int32 number_results = 4;
    233 
    234   // Time of the event.
    235   optional int64 event_time_millis =
    236       5;  // [(datapol.semantic_type) = ST_TIMESTAMP];
    237 }
    238 
    239 // Profile IDs defined in BluetoothProfile API class
    240 // Values must match API class values
    241 enum ProfileId {
    242   PROFILE_UNKNOWN = 0;
    243   HEADSET = 1;
    244   A2DP = 2;
    245   HEALTH = 3;
    246   HID_HOST = 4;
    247   PAN = 5;
    248   PBAP = 6;
    249   GATT = 7;
    250   GATT_SERVER = 8;
    251   MAP = 9;
    252   SAP = 10;
    253   A2DP_SINK = 11;
    254   AVRCP_CONTROLLER = 12;
    255   AVRCP = 13;
    256   HEADSET_CLIENT = 16;
    257   PBAP_CLIENT = 17;
    258   MAP_CLIENT = 18;
    259   HID_DEVICE = 19;
    260   OPP = 20;
    261   HEARING_AID = 21;
    262 }
    263 
    264 // Statistics about Bluetooth profile connections
    265 message ProfileConnectionStats {
    266   // Profile id defined in BluetoothProfile.java
    267   optional ProfileId profile_id = 1;
    268 
    269   // Number of times that this profile is connected since last metrics dump
    270   optional int32 num_times_connected = 2;
    271 }
    272 
    273 enum HeadsetProfileType {
    274   HEADSET_PROFILE_UNKNOWN = 0;
    275   HSP = 1;
    276   HFP = 2;
    277 }
    278 
    279 // Statistics about headset profile connections
    280 message HeadsetProfileConnectionStats {
    281   // Type of headset profile connected
    282   optional HeadsetProfileType headset_profile_type = 1;
    283 
    284   // Number of times this type of headset profile is connected
    285   optional int32 num_times_connected = 2;
    286 }