diff options
-rw-r--r-- | system/common/metrics.cc | 341 | ||||
-rw-r--r-- | system/common/metrics.h | 208 | ||||
-rw-r--r-- | system/common/metrics_linux.cc | 68 |
3 files changed, 4 insertions, 613 deletions
diff --git a/system/common/metrics.cc b/system/common/metrics.cc index a3b3eea450..c6c0977115 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -18,87 +18,19 @@ #include "common/metrics.h" -#include <base/base64.h> #include <bluetooth/log.h> #include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> -#include <include/hardware/bt_av.h> #include <statslog_bt.h> -#include <unistd.h> -#include <algorithm> -#include <cerrno> #include <cstdint> -#include <cstring> -#include <memory> -#include <mutex> // NOLINT -#include <utility> +#include <vector> -#include "common/address_obfuscator.h" -#include "common/leaky_bonded_queue.h" -#include "common/time_util.h" -#include "hci/address.h" #include "main/shim/metric_id_api.h" -#include "osi/include/osi.h" #include "types/raw_address.h" -namespace std { -template <> -struct formatter<android::bluetooth::DirectionEnum> - : enum_formatter<android::bluetooth::DirectionEnum> {}; -template <> -struct formatter<android::bluetooth::SocketConnectionstateEnum> - : enum_formatter<android::bluetooth::SocketConnectionstateEnum> {}; -template <> -struct formatter<android::bluetooth::SocketRoleEnum> - : enum_formatter<android::bluetooth::SocketRoleEnum> {}; -template <> -struct formatter<android::bluetooth::AddressTypeEnum> - : enum_formatter<android::bluetooth::AddressTypeEnum> {}; -template <> -struct formatter<android::bluetooth::DeviceInfoSrcEnum> - : enum_formatter<android::bluetooth::DeviceInfoSrcEnum> {}; -template <> -struct formatter<android::bluetooth::SocketErrorEnum> - : enum_formatter<android::bluetooth::SocketErrorEnum> {}; -} // namespace std - namespace bluetooth { namespace common { -using bluetooth::hci::Address; - -void LogLinkLayerConnectionEvent(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, uint16_t link_type, - uint32_t hci_cmd, uint16_t hci_event, uint16_t hci_ble_event, - uint16_t cmd_status, uint16_t reason_code) { - std::string obfuscated_id; - int metric_id = 0; - if (address != nullptr) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(*address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(*address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address != nullptr ? obfuscated_id.c_str() : nullptr, - address != nullptr ? obfuscated_id.size() : 0); - int ret = stats_write(BLUETOOTH_LINK_LAYER_CONNECTION_EVENT, bytes_field, connection_handle, - direction, link_type, hci_cmd, hci_event, hci_ble_event, cmd_status, - reason_code, metric_id); - if (ret < 0) { - log::warn( - "failed to log status 0x{:x}, reason 0x{:x} from cmd 0x{:x}, event " - "0x{:x}, ble_event 0x{:x} for {}, handle {}, type 0x{:x}, error {}", - cmd_status, reason_code, hci_cmd, hci_event, hci_ble_event, *address, connection_handle, - link_type, ret); - } -} - -void LogHciTimeoutEvent(uint32_t hci_cmd) { - int ret = stats_write(BLUETOOTH_HCI_TIMEOUT_REPORTED, static_cast<int64_t>(hci_cmd)); - if (ret < 0) { - log::warn("failed for opcode 0x{:x}, error {}", hci_cmd, ret); - } -} - void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, uint16_t manufacturer_name, uint16_t subversion) { int ret = stats_write(BLUETOOTH_REMOTE_VERSION_INFO_REPORTED, handle, status, version, @@ -111,276 +43,6 @@ void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, } } -void LogA2dpAudioUnderrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, - int num_missing_pcm_bytes) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int64_t encoding_interval_nanos = encoding_interval_millis * 1000000; - int ret = stats_write(BLUETOOTH_A2DP_AUDIO_UNDERRUN_REPORTED, bytes_field, - encoding_interval_nanos, num_missing_pcm_bytes, metric_id); - if (ret < 0) { - log::warn( - "failed for {}, encoding_interval_nanos {}, num_missing_pcm_bytes {}, " - "error {}", - address, encoding_interval_nanos, num_missing_pcm_bytes, ret); - } -} - -void LogA2dpAudioOverrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, - int num_dropped_buffers, int num_dropped_encoded_frames, - int num_dropped_encoded_bytes) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int64_t encoding_interval_nanos = encoding_interval_millis * 1000000; - int ret = stats_write(BLUETOOTH_A2DP_AUDIO_OVERRUN_REPORTED, bytes_field, encoding_interval_nanos, - num_dropped_buffers, num_dropped_encoded_frames, num_dropped_encoded_bytes, - metric_id); - if (ret < 0) { - log::warn( - "failed to log for {}, encoding_interval_nanos {}, num_dropped_buffers " - "{}, num_dropped_encoded_frames {}, num_dropped_encoded_bytes {}, " - "error {}", - address, encoding_interval_nanos, num_dropped_buffers, num_dropped_encoded_frames, - num_dropped_encoded_bytes, ret); - } -} - -void LogA2dpPlaybackEvent(const RawAddress& address, int playback_state, int audio_coding_mode) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED, bytes_field, playback_state, - audio_coding_mode, metric_id); - if (ret < 0) { - log::warn( - "failed to log for {}, playback_state {}, audio_coding_mode {}, error " - "{}", - address, playback_state, audio_coding_mode, ret); - } -} - -void LogReadRssiResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, - int8_t rssi) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_DEVICE_RSSI_REPORTED, bytes_field, handle, cmd_status, rssi, - metric_id); - if (ret < 0) { - log::warn("failed for {}, handle {}, status 0x{:x}, rssi {} dBm, error {}", address, handle, - cmd_status, rssi, ret); - } -} - -void LogReadFailedContactCounterResult(const RawAddress& address, uint16_t handle, - uint32_t cmd_status, int32_t failed_contact_counter) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_DEVICE_FAILED_CONTACT_COUNTER_REPORTED, bytes_field, handle, - cmd_status, failed_contact_counter, metric_id); - if (ret < 0) { - log::warn( - "failed for {}, handle {}, status 0x{:x}, failed_contact_counter {} " - "packets, error {}", - address, handle, cmd_status, failed_contact_counter, ret); - } -} - -void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, - int32_t transmit_power_level) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField bytes_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_DEVICE_TX_POWER_LEVEL_REPORTED, bytes_field, handle, cmd_status, - transmit_power_level, metric_id); - if (ret < 0) { - log::warn( - "failed for {}, handle {}, status 0x{:x}, transmit_power_level {} " - "packets, error {}", - address, handle, cmd_status, transmit_power_level, ret); - } -} - -void LogSmpPairingEvent(const RawAddress& address, uint8_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint8_t smp_fail_reason) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_SMP_PAIRING_EVENT_REPORTED, obfuscated_id_field, smp_cmd, - direction, smp_fail_reason, metric_id); - if (ret < 0) { - log::warn( - "failed for {}, smp_cmd 0x{:x}, direction {}, smp_fail_reason 0x{:x}, " - "error {}", - address, smp_cmd, direction, smp_fail_reason, ret); - } -} - -void LogClassicPairingEvent(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_CLASSIC_PAIRING_EVENT_REPORTED, obfuscated_id_field, handle, - hci_cmd, hci_event, cmd_status, reason_code, event_value, metric_id); - if (ret < 0) { - log::warn( - "failed for {}, handle {}, hci_cmd 0x{:x}, hci_event 0x{:x}, " - "cmd_status 0x{:x}, reason 0x{:x}, event_value {}, error {}", - address, handle, hci_cmd, hci_event, cmd_status, reason_code, event_value, ret); - } -} - -void LogSdpAttribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - BytesField attribute_field(attribute_value, attribute_size); - int ret = stats_write(BLUETOOTH_SDP_ATTRIBUTE_REPORTED, obfuscated_id_field, protocol_uuid, - attribute_id, attribute_field, metric_id); - if (ret < 0) { - log::warn("failed for {}, protocol_uuid 0x{:x}, attribute_id 0x{:x}, error {}", address, - protocol_uuid, attribute_id, ret); - } -} - -void LogSocketConnectionState(const RawAddress& address, int port, int type, - android::bluetooth::SocketConnectionstateEnum connection_state, - int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, - android::bluetooth::SocketRoleEnum socket_role, - uint64_t connection_duration_ms, - android::bluetooth::SocketErrorEnum error_code, - bool is_hardware_offload) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_SOCKET_CONNECTION_STATE_CHANGED, obfuscated_id_field, port, type, - connection_state, tx_bytes, rx_bytes, uid, server_port, socket_role, - metric_id, static_cast<int64_t>(connection_duration_ms), error_code, - is_hardware_offload); - if (ret < 0) { - log::warn( - "failed for {}, port {}, type {}, state {}, tx_bytes {}, rx_bytes {}, " - "uid {}, server_port {}, socket_role {}, error {}, connection_duration_ms {}, " - "socket_error_code {}, " - "is_hardware_offload {}", - address, port, type, connection_state, tx_bytes, rx_bytes, uid, server_port, - socket_role, ret, connection_duration_ms, error_code, is_hardware_offload); - } -} - -void LogManufacturerInfo(const RawAddress& address, - android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version) { - std::string obfuscated_id; - int metric_id = 0; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - metric_id = bluetooth::shim::AllocateIdFromMetricIdAllocator(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_DEVICE_INFO_REPORTED, obfuscated_id_field, source_type, - source_name.c_str(), manufacturer.c_str(), model.c_str(), - hardware_version.c_str(), software_version.c_str(), metric_id, address_type, - address.address[5], address.address[4], address.address[3]); - if (ret < 0) { - log::warn( - "failed for {}, source_type {}, source_name {}, manufacturer {}, model " - "{}, hardware_version {}, software_version {} MAC address type {} MAC " - "address prefix {} {} {}, error {}", - address, source_type, source_name, manufacturer, model, hardware_version, - software_version, address_type, address.address[5], address.address[4], - address.address[3], ret); - } -} - -void LogBluetoothHalCrashReason(const RawAddress& address, uint32_t error_code, - uint32_t vendor_error_code) { - std::string obfuscated_id; - if (!address.IsEmpty()) { - obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); - } - // nullptr and size 0 represent missing value for obfuscated_id - BytesField obfuscated_id_field(address.IsEmpty() ? nullptr : obfuscated_id.c_str(), - address.IsEmpty() ? 0 : obfuscated_id.size()); - int ret = stats_write(BLUETOOTH_HAL_CRASH_REASON_REPORTED, 0, obfuscated_id_field, error_code, - vendor_error_code); - if (ret < 0) { - log::warn("failed for {}, error_code 0x{:x}, vendor_error_code 0x{:x}, error {}", address, - error_code, vendor_error_code, ret); - } -} - void LogLeAudioConnectionSessionReported( int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos, const std::vector<int64_t>& device_connecting_offset_nanos, @@ -429,5 +91,4 @@ void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) { } } // namespace common - } // namespace bluetooth diff --git a/system/common/metrics.h b/system/common/metrics.h index 4ccb47f64c..4d5a234ce5 100644 --- a/system/common/metrics.h +++ b/system/common/metrics.h @@ -18,22 +18,12 @@ #pragma once -#include <bta/include/bta_api.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> -#include <stdint.h> - -#include <memory> -#include <string> +#include <cstdint> #include <vector> -#include "hci/address.h" -#include "os/metrics.h" #include "types/raw_address.h" namespace bluetooth { - namespace common { /** @@ -42,34 +32,6 @@ namespace common { static const uint32_t kUnknownConnectionHandle = 0xFFFF; /** - * Log link layer connection event - * - * @param address Stack wide consistent Bluetooth address of this event, - * nullptr if unknown - * @param connection_handle connection handle of this event, - * {@link kUnknownConnectionHandle} if unknown - * @param direction direction of this connection - * @param link_type type of the link - * @param hci_cmd HCI command opecode associated with this event, if any - * @param hci_event HCI event code associated with this event, if any - * @param hci_ble_event HCI BLE event code associated with this event, if any - * @param cmd_status Command status associated with this event, if any - * @param reason_code Reason code associated with this event, if any - */ -void LogLinkLayerConnectionEvent(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, uint16_t link_type, - uint32_t hci_cmd, uint16_t hci_event, uint16_t hci_ble_event, - uint16_t cmd_status, uint16_t reason_code); - -/** - * Logs when Bluetooth controller failed to reply with command status within - * a timeout period after receiving an HCI command from the host - * - * @param hci_cmd opcode of HCI command that caused this timeout - */ -void LogHciTimeoutEvent(uint32_t hci_cmd); - -/** * Logs when we receive Bluetooth Read Remote Version Information Complete * Event from the remote device, as documented by the Bluetooth Core HCI * specification @@ -86,173 +48,6 @@ void LogHciTimeoutEvent(uint32_t hci_cmd); void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, uint16_t manufacturer_name, uint16_t subversion); -/** - * Log A2DP audio buffer underrun event - * - * @param address A2DP device associated with this event - * @param encoding_interval_millis encoding interval in milliseconds - * @param num_missing_pcm_bytes number of PCM bytes that cannot be read from - * the source - */ -void LogA2dpAudioUnderrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, - int num_missing_pcm_bytes); - -/** - * Log A2DP audio buffer overrun event - * - * @param address A2DP device associated with this event - * @param encoding_interval_millis encoding interval in milliseconds - * @param num_dropped_buffers number of encoded buffers dropped from Tx queue - * @param num_dropped_encoded_frames number of encoded frames dropped from Tx - * queue - * @param num_dropped_encoded_bytes number of encoded bytes dropped from Tx - * queue - */ -void LogA2dpAudioOverrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, - int num_dropped_buffers, int num_dropped_encoded_frames, - int num_dropped_encoded_bytes); - -/** - * Log A2DP playback state changed event - * - * @param address A2DP device associated with this event - * @param playback_state audio playback state - * @param audio_coding_mode audio codec encoding mode - */ -void LogA2dpPlaybackEvent(const RawAddress& address, int playback_state, int audio_coding_mode); - -/** - * Log read RSSI result - * - * @param address device associated with this event - * @param handle connection handle of this event, - * {@link kUnknownConnectionHandle} if unknown - * @param cmd_status command status from read RSSI command - * @param rssi rssi value in dBm - */ -void LogReadRssiResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, - int8_t rssi); - -/** - * Log failed contact counter report - * - * @param address device associated with this event - * @param handle connection handle of this event, - * {@link kUnknownConnectionHandle} if unknown - * @param cmd_status command status from read failed contact counter command - * @param failed_contact_counter Number of consecutive failed contacts for a - * connection corresponding to the Handle - */ -void LogReadFailedContactCounterResult(const RawAddress& address, uint16_t handle, - uint32_t cmd_status, int32_t failed_contact_counter); - -/** - * Log transmit power level for a particular device after read - * - * @param address device associated with this event - * @param handle connection handle of this event, - * {@link kUnknownConnectionHandle} if unknown - * @param cmd_status command status from read failed contact counter command - * @param transmit_power_level transmit power level for connection to this - * device - */ -void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, - int32_t transmit_power_level); - -/** - * Logs when there is an event related to Bluetooth Security Manager Protocol - * - * @param address address of associated device - * @param smp_cmd SMP command code associated with this event - * @param direction direction of this SMP command - * @param smp_fail_reason SMP pairing failure reason code from SMP spec - */ -void LogSmpPairingEvent(const RawAddress& address, uint8_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint8_t smp_fail_reason); - -/** - * Logs there is an event related Bluetooth classic pairing - * - * @param address address of associated device - * @param handle connection handle of this event, - * {@link kUnknownConnectionHandle} if unknown - * @param hci_cmd HCI command associated with this event - * @param hci_event HCI event associated with this event - * @param cmd_status Command status associated with this event - * @param reason_code Reason code associated with this event - * @param event_value A status value related to this specific event - */ -void LogClassicPairingEvent(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value); - -/** - * Logs when certain Bluetooth SDP attributes are discovered - * - * @param address address of associated device - * @param protocol_uuid 16 bit protocol UUID from Bluetooth Assigned Numbers - * @param attribute_id 16 bit attribute ID from Bluetooth Assigned Numbers - * @param attribute_size size of this attribute - * @param attribute_value pointer to the attribute data, must be larger than - * attribute_size - */ -void LogSdpAttribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value); - -/** - * Logs when there is a change in Bluetooth socket connection state - * - * @param address address of associated device, empty if this is a server port - * @param port port of this socket connection - * @param type type of socket - * @param connection_state socket connection state - * @param tx_bytes number of bytes transmitted - * @param rx_bytes number of bytes received - * @param server_port server port of this socket, if any. When both - * |server_port| and |port| fields are populated, |port| must be spawned - * by |server_port| - * @param socket_role role of this socket, server or connection - * @param uid socket owner's uid - * @param connection_duration_ms duration of socket connection in milliseconds - * @param error_code error code of socket failures - * @param is_hardware_offload whether this is a offload socket - */ -void LogSocketConnectionState(const RawAddress& address, int port, int type, - android::bluetooth::SocketConnectionstateEnum connection_state, - int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, - android::bluetooth::SocketRoleEnum socket_role, - uint64_t connection_duration_ms, - android::bluetooth::SocketErrorEnum error_code, - bool is_hardware_offload); - -/** - * Logs when a Bluetooth device's manufacturer information is learnt - * - * @param address address of associated device - * @param source_type where is this device info obtained from - * @param source_name name of the data source, internal or external - * @param manufacturer name of the manufacturer of this device - * @param model model of this device - * @param hardware_version hardware version of this device - * @param software_version software version of this device - */ -void LogManufacturerInfo(const RawAddress& address, - android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version); - -/** - * Logs when received Bluetooth HAL crash reason report. - * - * @param address current connected address. - * @param error_code the crash reason from bluetooth hal - * @param vendor_error_code the vendor crash reason from bluetooth Firmware - */ -void LogBluetoothHalCrashReason(const RawAddress& address, uint32_t error_code, - uint32_t vendor_error_code); - void LogLeAudioConnectionSessionReported( int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos, const std::vector<int64_t>& device_connecting_offset_nanos, @@ -268,5 +63,4 @@ void LogLeAudioConnectionSessionReported( void LogLeAudioBroadcastSessionReported(int64_t duration_nanos); } // namespace common - } // namespace bluetooth diff --git a/system/common/metrics_linux.cc b/system/common/metrics_linux.cc index 3283619415..e886c05bf3 100644 --- a/system/common/metrics_linux.cc +++ b/system/common/metrics_linux.cc @@ -16,81 +16,18 @@ * ******************************************************************************/ -#include <bluetooth/log.h> +#include <cstdint> +#include <vector> #include "common/metrics.h" #include "types/raw_address.h" namespace bluetooth { - namespace common { -void LogClassicPairingEvent(const RawAddress& /* address */, uint16_t /* handle */, - uint32_t /* hci_cmd */, uint16_t /* hci_event */, - uint16_t /* cmd_status */, uint16_t /* reason_code */, - int64_t /* event_value */) {} - -void LogSocketConnectionState(const RawAddress& /* address */, int /* port */, int /* type */, - android::bluetooth::SocketConnectionstateEnum /* connection_state */, - int64_t /* tx_bytes */, int64_t /* rx_bytes */, int /* uid */, - int /* server_port */, - android::bluetooth::SocketRoleEnum /* socket_role */, - uint64_t /* connection_duration_ms */, - android::bluetooth::SocketErrorEnum /* error_code */, - bool /* is_hardware_offload */) {} - -void LogHciTimeoutEvent(uint32_t /* hci_cmd */) {} - -void LogA2dpAudioUnderrunEvent(const RawAddress& /* address */, - uint64_t /* encoding_interval_millis */, - int /* num_missing_pcm_bytes */) {} - -void LogA2dpAudioOverrunEvent(const RawAddress& /* address */, - uint64_t /* encoding_interval_millis */, - int /* num_dropped_buffers */, int /* num_dropped_encoded_frames */, - int /* num_dropped_encoded_bytes */) {} - -void LogA2dpPlaybackEvent(const RawAddress& /* address */, int /* playback_state */, - int /* audio_coding_mode */) {} - -void LogBluetoothHalCrashReason(const RawAddress& /* address */, uint32_t /* error_code */, - uint32_t /* vendor_error_code */) {} - -void LogReadRssiResult(const RawAddress& /* address */, uint16_t /* handle */, - uint32_t /* cmd_status */, int8_t /* rssi */) {} - -void LogReadFailedContactCounterResult(const RawAddress& /* address */, uint16_t /* handle */, - uint32_t /* cmd_status */, - int32_t /* failed_contact_counter */) {} - -void LogReadTxPowerLevelResult(const RawAddress& /* address */, uint16_t /* handle */, - uint32_t /* cmd_status */, int32_t /* transmit_power_level */) {} - void LogRemoteVersionInfo(uint16_t /* handle */, uint8_t /* status */, uint8_t /* version */, uint16_t /* manufacturer_name */, uint16_t /* subversion */) {} -void LogLinkLayerConnectionEvent(const RawAddress* /* address */, uint32_t /* connection_handle */, - android::bluetooth::DirectionEnum /* direction */, - uint16_t /* link_type */, uint32_t /* hci_cmd */, - uint16_t /* hci_event */, uint16_t /* hci_ble_event */, - uint16_t /* cmd_status */, uint16_t /* reason_code */) {} - -void LogManufacturerInfo(const RawAddress& /* address */, - android::bluetooth::AddressTypeEnum /* address_type */, - android::bluetooth::DeviceInfoSrcEnum /* source_type */, - const std::string& /* source_name */, - const std::string& /* manufacturer */, const std::string& /* model */, - const std::string& /* hardware_version */, - const std::string& /* software_version */) {} - -void LogSdpAttribute(const RawAddress& /* address */, uint16_t /* protocol_uuid */, - uint16_t /* attribute_id */, size_t /* attribute_size */, - const char* /* attribute_value */) {} - -void LogSmpPairingEvent(const RawAddress& /* address */, uint8_t /* smp_cmd */, - android::bluetooth::DirectionEnum /* direction */, - uint8_t /* smp_fail_reason */) {} - void LogLeAudioConnectionSessionReported( int32_t /* group_size */, int32_t /* group_metric_id */, int64_t /* connection_duration_nanos */, @@ -107,5 +44,4 @@ void LogLeAudioConnectionSessionReported( void LogLeAudioBroadcastSessionReported(int64_t /* duration_nanos */) {} } // namespace common - } // namespace bluetooth |