diff options
author | 2021-03-24 20:15:43 +0800 | |
---|---|---|
committer | 2021-03-31 14:34:06 +0800 | |
commit | e9f5c354556a5f3d04c73c918b4559290421fa94 (patch) | |
tree | 0a4e85fe5d6d769113a62c67db35f42f933bec34 /system/common/metrics.cc | |
parent | b6f7ab5cf9833509754c7b46e2929160e1831551 (diff) |
A2DP: Log BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED
Enable BLUETOOTH_A2DP_PLAYBACK_STATE_CHANGED Result metrics logged in stack
Tag: #feature
Bug: 183473902
Test: atest BluetoothInstrumentationTests
Change-Id: I9e9b7d1d0e6fd094978ccaad9c16a0e2306e7882
Diffstat (limited to 'system/common/metrics.cc')
-rw-r--r-- | system/common/metrics.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/system/common/metrics.cc b/system/common/metrics.cc index 10eedc8e13..184961293a 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -678,6 +678,29 @@ void LogA2dpAudioOverrunEvent(const RawAddress& address, } } +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 = MetricIdAllocator::GetInstance().AllocateId(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_A2DP_PLAYBACK_STATE_CHANGED, bytes_field, + playback_state, audio_coding_mode, metric_id); + if (ret < 0) { + LOG(WARNING) << __func__ << ": failed to log for " << address + << ", playback_state " << playback_state + << ", audio_coding_mode " << audio_coding_mode << ", error " + << ret; + } +} + void LogReadRssiResult(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int8_t rssi) { std::string obfuscated_id; |