summaryrefslogtreecommitdiff
path: root/system/common/metrics.cc
diff options
context:
space:
mode:
author Jack He <siyuanh@google.com> 2019-01-31 15:17:08 -0800
committer Jack He <siyuanh@google.com> 2019-01-31 15:38:23 -0800
commitb75275d4abd74c67167aaae03cc67e28dc3eeb66 (patch)
tree3cefc37501218dcdd8be7959af3001791b8213c7 /system/common/metrics.cc
parentc49c9b1f3efbc192d38003d61a532cc03b555bbb (diff)
Metrics: Log SMP pairing commands
* Log SMP pairing commands and pairing failure reasons Bug: 112969790 Test: make, testdrive with statsd Change-Id: I51ae2af981a687954f7de3cee3caacce43d782b6
Diffstat (limited to 'system/common/metrics.cc')
-rw-r--r--system/common/metrics.cc22
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