Loading system/common/metrics.cc +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <base/base64.h> #include <base/logging.h> #include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> #include <include/hardware/bt_av.h> #include <statslog_bt.h> #include <unistd.h> Loading @@ -35,6 +36,9 @@ #include "address_obfuscator.h" #include "bluetooth/metrics/bluetooth.pb.h" #include "gd/metrics/metrics_state.h" #include "gd/hci/address.h" #include "gd/os/metrics.h" #include "leaky_bonded_queue.h" #include "metric_id_allocator.h" #include "osi/include/osi.h" Loading Loading @@ -68,6 +72,7 @@ using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanEventType; using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanTechnologyType; using bluetooth::metrics::BluetoothMetricsProto::WakeEvent; using bluetooth::metrics::BluetoothMetricsProto::WakeEvent_WakeEventType; using bluetooth::hci::Address; static float combine_averages(float avg_a, int64_t ct_a, float avg_b, int64_t ct_b) { Loading Loading @@ -969,6 +974,19 @@ void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) { } } void LogLeBluetoothConnectionMetricEventReported( const Address& address, android::bluetooth::le::LeConnectionOriginType origin_type, android::bluetooth::le::LeConnectionType connection_type, android::bluetooth::le::LeConnectionState transaction_state, std::vector<std::pair<os::ArgumentType, int>> argument_list) { // Log the events for the State Management metrics::MetricsCollector::GetLEConnectionMetricsCollector() ->AddStateChangedEvent(address, origin_type, connection_type, transaction_state, argument_list); } } // namespace common } // namespace bluetooth system/common/metrics.h +11 −0 Original line number Diff line number Diff line Loading @@ -21,13 +21,16 @@ #include <bta/include/bta_api.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "gd/os/metrics.h" #include "types/raw_address.h" #include "hci/address.h" namespace bluetooth { Loading Loading @@ -520,6 +523,14 @@ void LogLeAudioConnectionSessionReported( void LogLeAudioBroadcastSessionReported(int64_t duration_nanos); void LogLeBluetoothConnectionMetricEventReported( const RawAddress& raw_address, android::bluetooth::le::LeConnectionOriginType origin_type, android::bluetooth::le::LeConnectionType connection_type, android::bluetooth::le::LeConnectionState transaction_state, std::vector<std::pair<os::ArgumentType, int>> argument_list); } // namespace common } // namespace bluetooth system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -426,6 +426,7 @@ cc_test { "libbt_callbacks_cxx", "libbt_shim_bridge", "libbt_shim_ffi", "libbt-platform-protos-lite" ], shared_libs: [ "libcrypto", Loading system/gd/hci/acl_manager/le_impl.h +44 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include "hci/le_address_manager.h" #include "os/alarm.h" #include "os/handler.h" #include "os/metrics.h" #include "os/system_properties.h" #include "packet/packet_view.h" Loading Loading @@ -342,6 +343,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { AddressWithType remote_address(address, peer_address_type); AddressWithType local_address = le_address_manager_->GetInitiatorAddress(); const bool in_filter_accept_list = is_device_in_connect_list(remote_address); auto argument_list = std::vector<std::pair<bluetooth::os::ArgumentType, int>>(); argument_list.push_back( std::make_pair(os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(status))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address, android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_END, argument_list); if (role == hci::Role::CENTRAL) { connectability_state_ = ConnectabilityState::DISARMED; Loading Loading @@ -485,6 +496,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } AddressWithType remote_address(address, remote_address_type); const bool in_filter_accept_list = is_device_in_connect_list(remote_address); auto argument_list = std::vector<std::pair<bluetooth::os::ArgumentType, int>>(); argument_list.push_back( std::make_pair(os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(status))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address, android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_END, argument_list); if (role == hci::Role::CENTRAL) { connectability_state_ = ConnectabilityState::DISARMED; Loading Loading @@ -982,6 +1003,15 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } void disarm_connectability() { auto argument_list = std::vector<std::pair<os::ArgumentType, int>>(); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( Address::kEmpty, os::LeConnectionOriginType::ORIGIN_UNSPECIFIED, os::LeConnectionType::CONNECTION_TYPE_LE_ACL, os::LeConnectionState::STATE_LE_ACL_CANCEL, argument_list); switch (connectability_state_) { case ConnectabilityState::ARMED: LOG_INFO("Disarming LE connection state machine with create connection cancel"); Loading Loading @@ -1078,6 +1108,17 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (create_connection_timeout_alarms_.find(address_with_type) != create_connection_timeout_alarms_.end()) { create_connection_timeout_alarms_.at(address_with_type).Cancel(); create_connection_timeout_alarms_.erase(address_with_type); auto argument_list = std::vector<std::pair<os::ArgumentType, int>>(); argument_list.push_back(std::make_pair( os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(android::bluetooth::hci::StatusEnum::STATUS_CONNECTION_TOUT))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address_with_type.GetAddress(), android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_TIMEOUT, argument_list); if (background_connections_.find(address_with_type) != background_connections_.end()) { direct_connections_.erase(address_with_type); disarm_connectability(); Loading system/gd/metrics/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ filegroup { name: "BluetoothMetricsSources", srcs: [ "counter_metrics.cc", "metrics_state.cc", "utils.cc" ], } Loading @@ -18,5 +20,6 @@ filegroup { name: "BluetoothMetricsTestSources", srcs: [ "counter_metrics_unittest.cc", "metrics_state_unittest.cc" ], } Loading
system/common/metrics.cc +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <base/base64.h> #include <base/logging.h> #include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> #include <include/hardware/bt_av.h> #include <statslog_bt.h> #include <unistd.h> Loading @@ -35,6 +36,9 @@ #include "address_obfuscator.h" #include "bluetooth/metrics/bluetooth.pb.h" #include "gd/metrics/metrics_state.h" #include "gd/hci/address.h" #include "gd/os/metrics.h" #include "leaky_bonded_queue.h" #include "metric_id_allocator.h" #include "osi/include/osi.h" Loading Loading @@ -68,6 +72,7 @@ using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanEventType; using bluetooth::metrics::BluetoothMetricsProto::ScanEvent_ScanTechnologyType; using bluetooth::metrics::BluetoothMetricsProto::WakeEvent; using bluetooth::metrics::BluetoothMetricsProto::WakeEvent_WakeEventType; using bluetooth::hci::Address; static float combine_averages(float avg_a, int64_t ct_a, float avg_b, int64_t ct_b) { Loading Loading @@ -969,6 +974,19 @@ void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) { } } void LogLeBluetoothConnectionMetricEventReported( const Address& address, android::bluetooth::le::LeConnectionOriginType origin_type, android::bluetooth::le::LeConnectionType connection_type, android::bluetooth::le::LeConnectionState transaction_state, std::vector<std::pair<os::ArgumentType, int>> argument_list) { // Log the events for the State Management metrics::MetricsCollector::GetLEConnectionMetricsCollector() ->AddStateChangedEvent(address, origin_type, connection_type, transaction_state, argument_list); } } // namespace common } // namespace bluetooth
system/common/metrics.h +11 −0 Original line number Diff line number Diff line Loading @@ -21,13 +21,16 @@ #include <bta/include/bta_api.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h> #include <stdint.h> #include <memory> #include <string> #include <vector> #include "gd/os/metrics.h" #include "types/raw_address.h" #include "hci/address.h" namespace bluetooth { Loading Loading @@ -520,6 +523,14 @@ void LogLeAudioConnectionSessionReported( void LogLeAudioBroadcastSessionReported(int64_t duration_nanos); void LogLeBluetoothConnectionMetricEventReported( const RawAddress& raw_address, android::bluetooth::le::LeConnectionOriginType origin_type, android::bluetooth::le::LeConnectionType connection_type, android::bluetooth::le::LeConnectionState transaction_state, std::vector<std::pair<os::ArgumentType, int>> argument_list); } // namespace common } // namespace bluetooth
system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -426,6 +426,7 @@ cc_test { "libbt_callbacks_cxx", "libbt_shim_bridge", "libbt_shim_ffi", "libbt-platform-protos-lite" ], shared_libs: [ "libcrypto", Loading
system/gd/hci/acl_manager/le_impl.h +44 −3 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ #include "hci/le_address_manager.h" #include "os/alarm.h" #include "os/handler.h" #include "os/metrics.h" #include "os/system_properties.h" #include "packet/packet_view.h" Loading Loading @@ -342,6 +343,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { AddressWithType remote_address(address, peer_address_type); AddressWithType local_address = le_address_manager_->GetInitiatorAddress(); const bool in_filter_accept_list = is_device_in_connect_list(remote_address); auto argument_list = std::vector<std::pair<bluetooth::os::ArgumentType, int>>(); argument_list.push_back( std::make_pair(os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(status))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address, android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_END, argument_list); if (role == hci::Role::CENTRAL) { connectability_state_ = ConnectabilityState::DISARMED; Loading Loading @@ -485,6 +496,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } AddressWithType remote_address(address, remote_address_type); const bool in_filter_accept_list = is_device_in_connect_list(remote_address); auto argument_list = std::vector<std::pair<bluetooth::os::ArgumentType, int>>(); argument_list.push_back( std::make_pair(os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(status))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address, android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_END, argument_list); if (role == hci::Role::CENTRAL) { connectability_state_ = ConnectabilityState::DISARMED; Loading Loading @@ -982,6 +1003,15 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { } void disarm_connectability() { auto argument_list = std::vector<std::pair<os::ArgumentType, int>>(); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( Address::kEmpty, os::LeConnectionOriginType::ORIGIN_UNSPECIFIED, os::LeConnectionType::CONNECTION_TYPE_LE_ACL, os::LeConnectionState::STATE_LE_ACL_CANCEL, argument_list); switch (connectability_state_) { case ConnectabilityState::ARMED: LOG_INFO("Disarming LE connection state machine with create connection cancel"); Loading Loading @@ -1078,6 +1108,17 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback { if (create_connection_timeout_alarms_.find(address_with_type) != create_connection_timeout_alarms_.end()) { create_connection_timeout_alarms_.at(address_with_type).Cancel(); create_connection_timeout_alarms_.erase(address_with_type); auto argument_list = std::vector<std::pair<os::ArgumentType, int>>(); argument_list.push_back(std::make_pair( os::ArgumentType::ACL_STATUS_CODE, static_cast<int>(android::bluetooth::hci::StatusEnum::STATUS_CONNECTION_TOUT))); bluetooth::os::LogMetricBluetoothLEConnectionMetricEvent( address_with_type.GetAddress(), android::bluetooth::le::LeConnectionOriginType::ORIGIN_NATIVE, android::bluetooth::le::LeConnectionType::CONNECTION_TYPE_LE_ACL, android::bluetooth::le::LeConnectionState::STATE_LE_ACL_TIMEOUT, argument_list); if (background_connections_.find(address_with_type) != background_connections_.end()) { direct_connections_.erase(address_with_type); disarm_connectability(); Loading
system/gd/metrics/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -11,6 +11,8 @@ filegroup { name: "BluetoothMetricsSources", srcs: [ "counter_metrics.cc", "metrics_state.cc", "utils.cc" ], } Loading @@ -18,5 +20,6 @@ filegroup { name: "BluetoothMetricsTestSources", srcs: [ "counter_metrics_unittest.cc", "metrics_state_unittest.cc" ], }