diff options
author | 2019-02-06 20:24:24 -0800 | |
---|---|---|
committer | 2019-02-08 15:51:20 -0800 | |
commit | 7a98b40aca20bde252d941feba368ff096f20737 (patch) | |
tree | 0d8462741c15189a9e7821c6b5fc8420202dbe2f /system/common/metrics.cc | |
parent | 68fd6c2f719aba215206c10b435516a05b57e2ca (diff) |
Metrics: Log L2CAP and RFCOMM socket connection state changes to statsd
* Log L2CAP LE Coc, L2CAP BREDR, and RFCOMM socket connection state
changes, including port number, socket type, connection states,
number of bytes sent and received, server port number, uid of socket
owner
* Address is empty if this is a server port
Bug: 112969790
Test: make, test drive with statsd
Change-Id: Ic0ee93a6d9e4fa4109ddb89dea5e92907c49f2fc
Diffstat (limited to 'system/common/metrics.cc')
-rw-r--r-- | system/common/metrics.cc | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/system/common/metrics.cc b/system/common/metrics.cc index 377476fc97..f74234b3b9 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -572,9 +572,9 @@ void BluetoothMetricsLogger::Reset() { void LogLinkLayerConnectionEvent(const RawAddress* address, uint32_t connection_handle, android::bluetooth::DirectionEnum direction, - uint32_t link_type, uint32_t hci_cmd, - uint32_t hci_event, uint32_t hci_ble_event, - uint32_t cmd_status, uint32_t reason_code) { + uint16_t link_type, uint32_t hci_cmd, + uint16_t hci_event, uint16_t hci_ble_event, + uint16_t cmd_status, uint16_t reason_code) { std::string obfuscated_id; if (address != nullptr) { obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(*address); @@ -588,12 +588,12 @@ void LogLinkLayerConnectionEvent(const RawAddress* address, connection_handle, direction, link_type, hci_cmd, hci_event, hci_ble_event, cmd_status, reason_code); if (ret < 0) { - LOG(WARNING) << __func__ << ": failed to log status 0x" - << loghex(cmd_status) << ", reason 0x" << loghex(reason_code) - << " from cmd 0x" << loghex(hci_cmd) << ", event 0x" - << loghex(hci_event) << ", ble_event 0x" - << loghex(hci_ble_event) << " for " << address << ", handle " - << connection_handle << ", error " << ret; + LOG(WARNING) << __func__ << ": failed to log status " << loghex(cmd_status) + << ", reason " << loghex(reason_code) << " from cmd " + << loghex(hci_cmd) << ", event " << loghex(hci_event) + << ", ble_event " << loghex(hci_ble_event) << " for " + << address << ", handle " << connection_handle << ", type " + << loghex(link_type) << ", error " << ret; } } @@ -801,6 +801,32 @@ void LogSdpAttribute(const RawAddress& address, uint16_t protocol_uuid, } } +void LogSocketConnectionState( + const RawAddress& address, int port, int type, + android::bluetooth::SocketConnectionstateEnum connection_state, + int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, + android::bluetooth::SocketRoleEnum socket_role) { + 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_SOCKET_CONNECTION_STATE_CHANGED, + obfuscated_id_field, port, type, connection_state, tx_bytes, rx_bytes, + uid, server_port, socket_role); + if (ret < 0) { + LOG(WARNING) << __func__ << ": failed for " << address << ", port " << port + << ", type " << type << ", state " << connection_state + << ", tx_bytes " << tx_bytes << ", rx_bytes " << rx_bytes + << ", uid " << uid << ", server_port " << server_port + << ", socket_role " << socket_role << ", error " << ret; + } +} + } // namespace common } // namespace bluetooth |