1 /* 2 * Copyright 2021 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 #pragma once 18 19 #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> 20 #include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> 21 22 #include "main/shim/metric_id_api.h" 23 #include "types/raw_address.h" 24 25 void log_a2dp_audio_underrun_event(const RawAddress& address, 26 uint64_t encoding_interval_millis, 27 int num_missing_pcm_bytes); 28 29 void log_a2dp_audio_overrun_event(const RawAddress& address, 30 uint64_t encoding_interval_millis, 31 int num_dropped_buffers, 32 int num_dropped_encoded_frames, 33 int num_dropped_encoded_bytes); 34 35 void log_a2dp_playback_event(const RawAddress& address, int playback_state, 36 int audio_coding_mode); 37 38 void log_read_rssi_result(const RawAddress& address, uint16_t handle, 39 uint32_t cmd_status, int8_t rssi); 40 41 void log_read_failed_contact_counter_result(const RawAddress& address, 42 uint16_t handle, 43 uint32_t cmd_status, 44 int32_t failed_contact_counter); 45 46 void log_read_tx_power_level_result(const RawAddress& address, uint16_t handle, 47 uint32_t cmd_status, 48 int32_t transmit_power_level); 49 50 void log_socket_connection_state( 51 const RawAddress& address, int port, int type, 52 android::bluetooth::SocketConnectionstateEnum connection_state, 53 int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, 54 android::bluetooth::SocketRoleEnum socket_role); 55 56 bool init_metric_id_allocator( 57 const std::unordered_map<RawAddress, int>& paired_device_map, 58 bluetooth::shim::CallbackLegacy save_id_callback, 59 bluetooth::shim::CallbackLegacy forget_device_callback); 60 61 bool close_metric_id_allocator(); 62 63 int allocate_metric_id_from_metric_id_allocator(const RawAddress&); 64 65 int save_metric_id_from_metric_id_allocator(const RawAddress&); 66 67 void forget_device_from_metric_id_allocator(const RawAddress&); 68 69 bool is_valid_id_from_metric_id_allocator(const int id);