diff options
Diffstat (limited to 'system/common/metrics.cc')
-rw-r--r-- | system/common/metrics.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/system/common/metrics.cc b/system/common/metrics.cc index 9cbef5e49f..1f6653861b 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -735,6 +735,28 @@ void LogReadTxPowerLevelResult(const RawAddress& address, uint16_t handle, } } +void LogSmpPairingEvent(const RawAddress& address, uint8_t smp_cmd, + android::bluetooth::DirectionEnum direction, + uint8_t smp_fail_reason) { + 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 obfuscated_id_field( + address.IsEmpty() ? nullptr : obfuscated_id.c_str(), + address.IsEmpty() ? 0 : obfuscated_id.size()); + int ret = android::util::stats_write( + android::util::BLUETOOTH_SMP_PAIRING_EVENT_REPORTED, obfuscated_id_field, + smp_cmd, direction, smp_fail_reason); + if (ret < 0) { + LOG(WARNING) << __func__ << ": failed for " << address << ", smp_cmd " + << loghex(smp_cmd) << ", direction " << direction + << ", smp_fail_reason " << loghex(smp_fail_reason) + << ", error " << ret; + } +} + } // namespace common } // namespace bluetooth |