Loading system/btif/src/btif_a2dp_source.cc +26 −1 Original line number Diff line number Diff line Loading @@ -837,6 +837,9 @@ static uint32_t btif_a2dp_source_read_callback(uint8_t* p_buf, uint32_t len) { btif_a2dp_source_cb.stats.media_read_total_underflow_count++; btif_a2dp_source_cb.stats.media_read_last_underflow_us = bluetooth::common::time_get_os_boottime_us(); bluetooth::common::LogA2dpAudioUnderrunEvent( btif_av_source_active_peer(), btif_a2dp_source_cb.encoder_interval_ms, len - bytes_read); } return bytes_read; Loading Loading @@ -882,10 +885,23 @@ static bool btif_a2dp_source_enqueue_callback(BT_HDR* p_buf, size_t frames_n, size_t drop_n = fixed_queue_length(btif_a2dp_source_cb.tx_audio_queue); btif_a2dp_source_cb.stats.tx_queue_max_dropped_messages = std::max( drop_n, btif_a2dp_source_cb.stats.tx_queue_max_dropped_messages); int num_dropped_encoded_bytes = 0; int num_dropped_encoded_frames = 0; while (fixed_queue_length(btif_a2dp_source_cb.tx_audio_queue)) { btif_a2dp_source_cb.stats.tx_queue_total_dropped_messages++; osi_free(fixed_queue_try_dequeue(btif_a2dp_source_cb.tx_audio_queue)); void* p_data = fixed_queue_try_dequeue(btif_a2dp_source_cb.tx_audio_queue); if (p_data != nullptr) { auto p_dropped_buf = static_cast<BT_HDR*>(p_data); num_dropped_encoded_bytes += p_dropped_buf->len; num_dropped_encoded_frames += p_dropped_buf->layer_specific; osi_free(p_data); } } bluetooth::common::LogA2dpAudioOverrunEvent( btif_av_source_active_peer(), drop_n, btif_a2dp_source_cb.encoder_interval_ms, num_dropped_encoded_frames, num_dropped_encoded_bytes); // Request additional debug info if we had to flush buffers RawAddress peer_bda = btif_av_source_active_peer(); Loading Loading @@ -1240,6 +1256,9 @@ static void btm_read_rssi_cb(void* data) { result->status); return; } bluetooth::common::LogReadRssiResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->rssi); LOG_WARN(LOG_TAG, "%s: device: %s, rssi: %d", __func__, result->rem_bda.ToString().c_str(), result->rssi); Loading @@ -1259,6 +1278,9 @@ static void btm_read_failed_contact_counter_cb(void* data) { __func__, result->status); return; } bluetooth::common::LogReadFailedContactCounterResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->failed_contact_counter); LOG_WARN(LOG_TAG, "%s: device: %s, Failed Contact Counter: %u", __func__, result->rem_bda.ToString().c_str(), result->failed_contact_counter); Loading Loading @@ -1295,6 +1317,9 @@ static void btm_read_tx_power_cb(void* data) { result->status); return; } bluetooth::common::LogReadTxPowerLevelResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->tx_power); LOG_WARN(LOG_TAG, "%s: device: %s, Tx Power: %d", __func__, result->rem_bda.ToString().c_str(), result->tx_power); Loading system/common/metrics.cc +116 −0 Original line number Diff line number Diff line Loading @@ -619,6 +619,122 @@ void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, << ", subversion " << loghex(subversion) << ", error " << ret; } } void LogA2dpAudioUnderrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, int num_missing_pcm_bytes) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::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 = android::util::stats_write( android::util::BLUETOOTH_A2DP_AUDIO_UNDERRUN_REPORTED, bytes_field, encoding_interval_nanos, num_missing_pcm_bytes); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", encoding_interval_nanos " << encoding_interval_nanos << ", num_missing_pcm_bytes " << num_missing_pcm_bytes << ", error " << 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; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::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 = android::util::stats_write( android::util::BLUETOOTH_A2DP_AUDIO_OVERRUN_REPORTED, bytes_field, encoding_interval_nanos, num_dropped_buffers, num_dropped_encoded_frames, num_dropped_encoded_bytes); if (ret < 0) { LOG(WARNING) << __func__ << ": failed to log for " << address << ", encoding_interval_nanos " << encoding_interval_nanos << ", num_dropped_buffers " << num_dropped_buffers << ", num_dropped_encoded_frames " << num_dropped_encoded_frames << ", num_dropped_encoded_bytes " << num_dropped_encoded_bytes << ", error " << ret; } } void LogReadRssiResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int8_t rssi) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write(android::util::BLUETOOTH_DEVICE_RSSI_REPORTED, bytes_field, handle, cmd_status, rssi); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", rssi " << rssi << " dBm, error " << ret; } } void LogReadFailedContactCounterResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t failed_contact_counter) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write( android::util::BLUETOOTH_DEVICE_FAILED_CONTACT_COUNTER_REPORTED, bytes_field, handle, cmd_status, failed_contact_counter); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", failed_contact_counter " << failed_contact_counter << " packets, error " << ret; } } void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t transmit_power_level) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write( android::util::BLUETOOTH_DEVICE_TX_POWER_LEVEL_REPORTED, bytes_field, handle, cmd_status, transmit_power_level); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", transmit_power_level " << transmit_power_level << " packets, error " << ret; } } } // namespace common } // namespace bluetooth system/common/metrics.h +71 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #pragma once #include <android/bluetooth/hci/enums.pb.h> #include <bta/include/bta_api.h> #include <frameworks/base/core/proto/android/bluetooth/enums.pb.h> #include <stdint.h> Loading Loading @@ -328,6 +329,76 @@ 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 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); } // namespace common } // namespace bluetooth Loading
system/btif/src/btif_a2dp_source.cc +26 −1 Original line number Diff line number Diff line Loading @@ -837,6 +837,9 @@ static uint32_t btif_a2dp_source_read_callback(uint8_t* p_buf, uint32_t len) { btif_a2dp_source_cb.stats.media_read_total_underflow_count++; btif_a2dp_source_cb.stats.media_read_last_underflow_us = bluetooth::common::time_get_os_boottime_us(); bluetooth::common::LogA2dpAudioUnderrunEvent( btif_av_source_active_peer(), btif_a2dp_source_cb.encoder_interval_ms, len - bytes_read); } return bytes_read; Loading Loading @@ -882,10 +885,23 @@ static bool btif_a2dp_source_enqueue_callback(BT_HDR* p_buf, size_t frames_n, size_t drop_n = fixed_queue_length(btif_a2dp_source_cb.tx_audio_queue); btif_a2dp_source_cb.stats.tx_queue_max_dropped_messages = std::max( drop_n, btif_a2dp_source_cb.stats.tx_queue_max_dropped_messages); int num_dropped_encoded_bytes = 0; int num_dropped_encoded_frames = 0; while (fixed_queue_length(btif_a2dp_source_cb.tx_audio_queue)) { btif_a2dp_source_cb.stats.tx_queue_total_dropped_messages++; osi_free(fixed_queue_try_dequeue(btif_a2dp_source_cb.tx_audio_queue)); void* p_data = fixed_queue_try_dequeue(btif_a2dp_source_cb.tx_audio_queue); if (p_data != nullptr) { auto p_dropped_buf = static_cast<BT_HDR*>(p_data); num_dropped_encoded_bytes += p_dropped_buf->len; num_dropped_encoded_frames += p_dropped_buf->layer_specific; osi_free(p_data); } } bluetooth::common::LogA2dpAudioOverrunEvent( btif_av_source_active_peer(), drop_n, btif_a2dp_source_cb.encoder_interval_ms, num_dropped_encoded_frames, num_dropped_encoded_bytes); // Request additional debug info if we had to flush buffers RawAddress peer_bda = btif_av_source_active_peer(); Loading Loading @@ -1240,6 +1256,9 @@ static void btm_read_rssi_cb(void* data) { result->status); return; } bluetooth::common::LogReadRssiResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->rssi); LOG_WARN(LOG_TAG, "%s: device: %s, rssi: %d", __func__, result->rem_bda.ToString().c_str(), result->rssi); Loading @@ -1259,6 +1278,9 @@ static void btm_read_failed_contact_counter_cb(void* data) { __func__, result->status); return; } bluetooth::common::LogReadFailedContactCounterResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->failed_contact_counter); LOG_WARN(LOG_TAG, "%s: device: %s, Failed Contact Counter: %u", __func__, result->rem_bda.ToString().c_str(), result->failed_contact_counter); Loading Loading @@ -1295,6 +1317,9 @@ static void btm_read_tx_power_cb(void* data) { result->status); return; } bluetooth::common::LogReadTxPowerLevelResult( result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status, result->tx_power); LOG_WARN(LOG_TAG, "%s: device: %s, Tx Power: %d", __func__, result->rem_bda.ToString().c_str(), result->tx_power); Loading
system/common/metrics.cc +116 −0 Original line number Diff line number Diff line Loading @@ -619,6 +619,122 @@ void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version, << ", subversion " << loghex(subversion) << ", error " << ret; } } void LogA2dpAudioUnderrunEvent(const RawAddress& address, uint64_t encoding_interval_millis, int num_missing_pcm_bytes) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::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 = android::util::stats_write( android::util::BLUETOOTH_A2DP_AUDIO_UNDERRUN_REPORTED, bytes_field, encoding_interval_nanos, num_missing_pcm_bytes); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", encoding_interval_nanos " << encoding_interval_nanos << ", num_missing_pcm_bytes " << num_missing_pcm_bytes << ", error " << 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; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::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 = android::util::stats_write( android::util::BLUETOOTH_A2DP_AUDIO_OVERRUN_REPORTED, bytes_field, encoding_interval_nanos, num_dropped_buffers, num_dropped_encoded_frames, num_dropped_encoded_bytes); if (ret < 0) { LOG(WARNING) << __func__ << ": failed to log for " << address << ", encoding_interval_nanos " << encoding_interval_nanos << ", num_dropped_buffers " << num_dropped_buffers << ", num_dropped_encoded_frames " << num_dropped_encoded_frames << ", num_dropped_encoded_bytes " << num_dropped_encoded_bytes << ", error " << ret; } } void LogReadRssiResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int8_t rssi) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write(android::util::BLUETOOTH_DEVICE_RSSI_REPORTED, bytes_field, handle, cmd_status, rssi); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", rssi " << rssi << " dBm, error " << ret; } } void LogReadFailedContactCounterResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t failed_contact_counter) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write( android::util::BLUETOOTH_DEVICE_FAILED_CONTACT_COUNTER_REPORTED, bytes_field, handle, cmd_status, failed_contact_counter); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", failed_contact_counter " << failed_contact_counter << " packets, error " << ret; } } void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t transmit_power_level) { std::string obfuscated_id; if (!address.IsEmpty()) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address); } // nullptr and size 0 represent missing value for obfuscated_id android::util::BytesField bytes_field( address.IsEmpty() ? nullptr : obfuscated_id.c_str(), address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = android::util::stats_write( android::util::BLUETOOTH_DEVICE_TX_POWER_LEVEL_REPORTED, bytes_field, handle, cmd_status, transmit_power_level); if (ret < 0) { LOG(WARNING) << __func__ << ": failed for " << address << ", handle " << handle << ", status " << loghex(cmd_status) << ", transmit_power_level " << transmit_power_level << " packets, error " << ret; } } } // namespace common } // namespace bluetooth
system/common/metrics.h +71 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #pragma once #include <android/bluetooth/hci/enums.pb.h> #include <bta/include/bta_api.h> #include <frameworks/base/core/proto/android/bluetooth/enums.pb.h> #include <stdint.h> Loading Loading @@ -328,6 +329,76 @@ 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 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); } // namespace common } // namespace bluetooth