summaryrefslogtreecommitdiff
path: root/system/common/metrics.cc
diff options
context:
space:
mode:
author Jack He <siyuanh@google.com> 2019-01-31 17:44:46 -0800
committer Jack He <siyuanh@google.com> 2019-01-31 18:55:54 -0800
commit0d888e5216875967de29d52d1e2bb792fcc9e12b (patch)
treec3c02fe20a3f6659ac895e60ff2c5918a0118033 /system/common/metrics.cc
parentf63120d8a40f1abbb7b56a65b5edf49e94876cb2 (diff)
Metrics: Add classic pairing metrics
* Log HCI commands and events related to classic pairing * Move all metrics logging for sending HCI command into a single function * Move all metrics logging for HCI command status into a single function * Move all metrics logging for HCI Command complete into a single function * Move all metrics logging for HCI events into a single function * Make sure we log all instances of HCI command sending methods, including those with desinated callbacks Bug: 112969790 Test: make, testdrive with statsd Change-Id: I4b1ca4ee814096d84bcd93c8d7206b0a771a3210
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 1f6653861b..8355e03eb8 100644
--- a/system/common/metrics.cc
+++ b/system/common/metrics.cc
@@ -757,6 +757,28 @@ void LogSmpPairingEvent(const RawAddress& address, uint8_t smp_cmd,
}
}
+void LogClassicPairingEvent(const RawAddress& address, uint16_t handle,
+ uint32_t hci_cmd, uint16_t hci_event,
+ uint16_t cmd_status, uint16_t reason_code) {
+ 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_CLASSIC_PAIRING_EVENT_REPORTED,
+ obfuscated_id_field, handle, hci_cmd, hci_event, cmd_status, reason_code);
+ if (ret < 0) {
+ LOG(WARNING) << __func__ << ": failed for " << address << ", handle "
+ << handle << ", hci_cmd " << loghex(hci_cmd) << ", hci_event "
+ << loghex(hci_event) << ", cmd_status " << loghex(cmd_status)
+ << ", reason " << loghex(reason_code) << ", error " << ret;
+ }
+}
+
} // namespace common
} // namespace bluetooth