Loading system/gd/hci/acl_manager/classic_impl.h +11 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "hci/acl_manager/event_checkers.h" #include "hci/acl_manager/round_robin_scheduler.h" #include "hci/controller.h" #include "os/metrics.h" #include "security/security_manager_listener.h" #include "security/security_module.h" Loading Loading @@ -209,6 +210,14 @@ struct classic_impl : public security::ISecurityManagerListener { } return kIllegalConnectionHandle; } Address get_address(uint16_t handle) const { std::unique_lock<std::mutex> lock(acl_connections_guard_); auto connection = acl_connections_.find(handle); if (connection == acl_connections_.end()) { return Address::kEmpty; } return connection->second.address_with_type_.GetAddress(); } bool is_classic_link_already_connected(const Address& address) const { std::unique_lock<std::mutex> lock(acl_connections_guard_); for (const auto& connection : acl_connections_) { Loading Loading @@ -411,6 +420,8 @@ struct classic_impl : public security::ISecurityManagerListener { static constexpr bool kRemoveConnectionAfterwards = true; void on_classic_disconnect(uint16_t handle, ErrorCode reason) { bool event_also_routes_to_other_receivers = connections.crash_on_unknown_handle_; bluetooth::os::LogMetricBluetoothDisconnectionReasonReported( static_cast<uint32_t>(reason), connections.get_address(handle), handle); connections.crash_on_unknown_handle_ = false; connections.execute( handle, Loading system/gd/os/android/metrics.cc +18 −0 Original line number Diff line number Diff line Loading @@ -445,6 +445,24 @@ void LogMetricBluetoothLocalVersions( } } void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) { int metric_id = 0; if (!address.IsEmpty()) { metric_id = MetricIdManager::GetInstance().AllocateId(address); } int ret = stats_write(BLUETOOTH_DISCONNECTION_REASON_REPORTED, reason, metric_id, connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothDisconnectionReasonReported, " "reason %d, metric_id %d, connection_handle %d, error %d", reason, metric_id, connection_handle, ret); } } void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) { int ret = stats_write(BLUETOOTH_CODE_PATH_COUNTER, key, count); if (ret < 0) { Loading system/gd/os/host/metrics.cc +3 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_reversion) {} void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) {} void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) {} } // namespace os } // namespace bluetooth system/gd/os/linux/metrics.cc +3 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_revision) {} void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) {} void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) {} } // namespace os Loading system/gd/os/metrics.h +3 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_revision); void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const hci::Address& address, uint32_t connection_handle); void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count); } // namespace os Loading Loading
system/gd/hci/acl_manager/classic_impl.h +11 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "hci/acl_manager/event_checkers.h" #include "hci/acl_manager/round_robin_scheduler.h" #include "hci/controller.h" #include "os/metrics.h" #include "security/security_manager_listener.h" #include "security/security_module.h" Loading Loading @@ -209,6 +210,14 @@ struct classic_impl : public security::ISecurityManagerListener { } return kIllegalConnectionHandle; } Address get_address(uint16_t handle) const { std::unique_lock<std::mutex> lock(acl_connections_guard_); auto connection = acl_connections_.find(handle); if (connection == acl_connections_.end()) { return Address::kEmpty; } return connection->second.address_with_type_.GetAddress(); } bool is_classic_link_already_connected(const Address& address) const { std::unique_lock<std::mutex> lock(acl_connections_guard_); for (const auto& connection : acl_connections_) { Loading Loading @@ -411,6 +420,8 @@ struct classic_impl : public security::ISecurityManagerListener { static constexpr bool kRemoveConnectionAfterwards = true; void on_classic_disconnect(uint16_t handle, ErrorCode reason) { bool event_also_routes_to_other_receivers = connections.crash_on_unknown_handle_; bluetooth::os::LogMetricBluetoothDisconnectionReasonReported( static_cast<uint32_t>(reason), connections.get_address(handle), handle); connections.crash_on_unknown_handle_ = false; connections.execute( handle, Loading
system/gd/os/android/metrics.cc +18 −0 Original line number Diff line number Diff line Loading @@ -445,6 +445,24 @@ void LogMetricBluetoothLocalVersions( } } void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) { int metric_id = 0; if (!address.IsEmpty()) { metric_id = MetricIdManager::GetInstance().AllocateId(address); } int ret = stats_write(BLUETOOTH_DISCONNECTION_REASON_REPORTED, reason, metric_id, connection_handle); if (ret < 0) { LOG_WARN( "Failed for LogMetricBluetoothDisconnectionReasonReported, " "reason %d, metric_id %d, connection_handle %d, error %d", reason, metric_id, connection_handle, ret); } } void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) { int ret = stats_write(BLUETOOTH_CODE_PATH_COUNTER, key, count); if (ret < 0) { Loading
system/gd/os/host/metrics.cc +3 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_reversion) {} void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) {} void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) {} } // namespace os } // namespace bluetooth
system/gd/os/linux/metrics.cc +3 −0 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_revision) {} void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const Address& address, uint32_t connection_handle) {} void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count) {} } // namespace os Loading
system/gd/os/metrics.h +3 −0 Original line number Diff line number Diff line Loading @@ -272,6 +272,9 @@ void LogMetricBluetoothLocalVersions( uint8_t hci_version, uint32_t hci_revision); void LogMetricBluetoothDisconnectionReasonReported( uint32_t reason, const hci::Address& address, uint32_t connection_handle); void LogMetricBluetoothCodePathCounterMetrics(int32_t key, int64_t count); } // namespace os Loading