diff options
23 files changed, 243 insertions, 784 deletions
diff --git a/system/bta/Android.bp b/system/bta/Android.bp index 52d34d59cc..5a8f721ebd 100644 --- a/system/bta/Android.bp +++ b/system/bta/Android.bp @@ -231,6 +231,7 @@ cc_test { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackA2dp", ":TestMockStackAcl", @@ -243,7 +244,6 @@ cc_test { ":TestMockStackGatt", ":TestMockStackHid", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackPan", ":TestMockStackRfcomm", ":TestMockStackRnr", @@ -339,10 +339,10 @@ cc_test { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", ":TestMockStackL2cap", - ":TestMockStackMetrics", "test/gatt/database_builder_sample_device_test.cc", "test/gatt/database_builder_test.cc", "test/gatt/database_test.cc", diff --git a/system/gd/Android.bp b/system/gd/Android.bp index 26f31f0b8e..f42632df97 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -357,8 +357,8 @@ cc_test { srcs: [ ":BluetoothPacketTestSources", ":TestCommonMockFunctions", + ":TestMockMainShim", ":TestMockMainShimEntry", - ":TestMockStackMetrics", "common/bidi_queue_unittest.cc", "common/blocking_queue_unittest.cc", "common/byte_array_test.cc", @@ -581,11 +581,12 @@ cc_fuzz { defaults: ["gd_fuzz_defaults"], srcs: [ ":TestCommonMockFunctions", - ":TestMockStackMetrics", + ":TestMockMainShim", "hci/fuzz/acl_manager_fuzz_test.cc", ], include_dirs: [ "packages/modules/Bluetooth/system", + "packages/modules/Bluetooth/system/include", ], static_libs: [ "libbt-platform-protos-lite", diff --git a/system/gd/hci/acl_manager/le_impl.h b/system/gd/hci/acl_manager/le_impl.h index a6761e38b7..1a050ca44a 100644 --- a/system/gd/hci/acl_manager/le_impl.h +++ b/system/gd/hci/acl_manager/le_impl.h @@ -39,11 +39,11 @@ #include "hci/hci_packets.h" #include "hci/le_address_manager.h" #include "macros.h" +#include "main/shim/metrics_api.h" #include "os/alarm.h" #include "os/handler.h" #include "os/system_properties.h" #include "stack/include/btm_ble_api_types.h" -#include "stack/include/stack_metrics_logging.h" namespace bluetooth { namespace hci { @@ -426,7 +426,7 @@ public: return; } - log_le_connection_status(address, true /* is_connect */, status); + bluetooth::shim::LogMetricLeConnectionStatus(address, true /* is_connect */, status); const bool in_filter_accept_list = is_device_in_accept_list(remote_address); @@ -586,7 +586,8 @@ public: arm_on_resume_ = true; add_device_to_accept_list(remote_address); } - log_le_connection_status(remote_address.GetAddress(), false /* is_connect */, reason); + bluetooth::shim::LogMetricLeConnectionStatus(remote_address.GetAddress(), + false /* is_connect */, reason); } void on_le_connection_update_complete(LeMetaEventView view) { @@ -724,7 +725,8 @@ public: } void add_device_to_accept_list(AddressWithType address_with_type) { - log_le_device_in_accept_list(address_with_type.GetAddress(), true /* is_add */); + bluetooth::shim::LogMetricLeDeviceInAcceptList(address_with_type.GetAddress(), + true /* is_add */); if (connections.alreadyConnected(address_with_type)) { log::info("Device already connected, return"); return; @@ -747,7 +749,8 @@ public: } void remove_device_from_accept_list(AddressWithType address_with_type) { - log_le_device_in_accept_list(address_with_type.GetAddress(), false /* is_add */); + bluetooth::shim::LogMetricLeDeviceInAcceptList(address_with_type.GetAddress(), + false /* is_add */); if (accept_list.find(address_with_type) == accept_list.end()) { log::warn("Device not in acceptlist and cannot be removed: {}", address_with_type); return; @@ -1132,8 +1135,9 @@ public: remove_device_from_accept_list(address_with_type); } // Temporary mapping the error code to PAGE_TIMEOUT - log_le_connection_completion(address_with_type.GetAddress(), ErrorCode::PAGE_TIMEOUT, - true /* is locally initiated */); + bluetooth::shim::LogMetricLeConnectionCompletion(address_with_type.GetAddress(), + ErrorCode::PAGE_TIMEOUT, + true /* is locally initiated */); le_client_handler_->Post(common::BindOnce( &LeConnectionCallbacks::OnLeConnectFail, common::Unretained(le_client_callbacks_), address_with_type, ErrorCode::CONNECTION_ACCEPT_TIMEOUT)); diff --git a/system/stack/Android.bp b/system/stack/Android.bp index ebab1ff5f4..78af467a76 100644 --- a/system/stack/Android.bp +++ b/system/stack/Android.bp @@ -48,7 +48,6 @@ cc_library_static { "hid", "include", "l2cap", - "metrics", "pan", "sdp", "smp", @@ -183,7 +182,6 @@ cc_library_static { "l2cap/l2c_main.cc", "l2cap/l2c_utils.cc", "l2cap/l2cap_api.cc", - "metrics/stack_metrics_logging.cc", "pan/pan_api.cc", "pan/pan_main.cc", "pan/pan_utils.cc", @@ -374,9 +372,9 @@ cc_fuzz { ":TestFakeOsi", ":TestMockBtif", ":TestMockDevice", + ":TestMockMainShim", ":TestMockStackBtm", ":TestMockStackL2cap", - ":TestMockStackMetrics", "fuzzers/sdp_fuzzer.cc", ], static_libs: [ @@ -414,6 +412,7 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockSrvcDis", ":TestMockStackAcl", @@ -421,7 +420,6 @@ cc_fuzz { ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", "fuzzers/rfcomm_fuzzer.cc", "rfcomm/*.cc", @@ -465,6 +463,7 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockSrvcDis", ":TestMockStackAcl", @@ -473,7 +472,6 @@ cc_fuzz { ":TestMockStackConnMgr", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", "ais/*.cc", "eatt/*.cc", @@ -517,12 +515,12 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", "fuzzers/smp_fuzzer.cc", "smp/*.cc", // add other sources files (p256 related) under smp into this test ], @@ -563,12 +561,12 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", "bnep/*.cc", "fuzzers/bnep_fuzzer.cc", ], @@ -601,12 +599,12 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", "avct/*.cc", "avrc/*.cc", @@ -648,11 +646,11 @@ cc_fuzz { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", - ":TestMockStackMetrics", "fuzzers/l2cap_fuzzer.cc", "l2cap/*.cc", ], @@ -809,10 +807,10 @@ cc_test { ":TestCommonMockFunctions", ":TestMockHci", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", ":TestMockStackL2capInterface", - ":TestMockStackMetrics", ":TestMockStackRfcommMetrics", "rfcomm/port_api.cc", "rfcomm/port_rfc.cc", @@ -903,12 +901,12 @@ cc_test { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", "smp/p_256_curvepara.cc", "smp/p_256_ecc_pp.cc", "smp/p_256_multprecision.cc", @@ -1006,9 +1004,9 @@ cc_test { ":TestCommonMainHandler", ":TestCommonMockFunctions", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", - ":TestMockStackMetrics", "connection_manager/connection_manager.cc", "test/connection_manager_test.cc", ], @@ -1419,10 +1417,10 @@ cc_test { ":TestMockBtif", ":TestMockDevice", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockStackBtm", ":TestMockStackConnMgr", ":TestMockStackL2cap", - ":TestMockStackMetrics", "gatt/gatt_db.cc", "gatt/gatt_sr_hash.cc", "gatt/gatt_utils.cc", @@ -1675,7 +1673,6 @@ cc_test { "btm/hfp_msbc_decoder.cc", "btm/hfp_msbc_encoder.cc", "btm/security_event_parser.cc", - "metrics/stack_metrics_logging.cc", "test/btm/peer_packet_types_test.cc", "test/btm/sco_hci_test.cc", "test/btm/sco_pkt_status_test.cc", @@ -1813,9 +1810,9 @@ cc_test { ], srcs: [ ":TestCommonMockFunctions", + ":TestMockMainShim", ":TestMockStackBtm", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", "hid/hidd_api.cc", "hid/hidd_conn.cc", @@ -1887,12 +1884,12 @@ cc_test { ":TestMockBtif", ":TestMockHci", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSmp", "btu/btu_hcif.cc", "btu/main_thread.cc", @@ -1964,12 +1961,12 @@ cc_test { ":TestMockBtif", ":TestMockHci", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockSrvcDis", ":TestMockStackAcl", ":TestMockStackBtm", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", ":TestMockStackSmp", "ais/ais_ble.cc", @@ -2165,6 +2162,7 @@ cc_test { ":TestMockHci", ":TestMockLegacyHciInterface", ":TestMockMainShim", + ":TestMockMainShim", ":TestMockMainShimEntry", ":TestMockStackBtm", ":TestMockStackBtu", @@ -2172,7 +2170,6 @@ cc_test { ":TestMockStackGatt", ":TestMockStackHcic", ":TestMockStackL2cap", - ":TestMockStackMetrics", ":TestMockStackSdp", ":TestMockStackSmp", "acl/*.cc", @@ -2349,9 +2346,9 @@ cc_test { ":TestFakeOsi", ":TestMockBta", ":TestMockBtif", + ":TestMockMainShim", ":TestMockStackBtm", ":TestMockStackL2cap", - ":TestMockStackMetrics", "test/sdp/stack_sdp_api_test.cc", "test/sdp/stack_sdp_db_test.cc", "test/sdp/stack_sdp_parse_test.cc", diff --git a/system/stack/BUILD.gn b/system/stack/BUILD.gn index d078d1bc14..8aea1cc7ba 100644 --- a/system/stack/BUILD.gn +++ b/system/stack/BUILD.gn @@ -149,7 +149,6 @@ source_set("stack") { "l2cap/l2c_main.cc", "l2cap/l2c_utils.cc", "l2cap/l2cap_api.cc", - "metrics/stack_metrics_logging.cc", "pan/pan_api.cc", "pan/pan_main.cc", "pan/pan_utils.cc", diff --git a/system/stack/btm/btm_sco.cc b/system/stack/btm/btm_sco.cc index c48b321448..82182135eb 100644 --- a/system/stack/btm/btm_sco.cc +++ b/system/stack/btm/btm_sco.cc @@ -44,6 +44,7 @@ #include "internal_include/bt_target.h" #include "main/shim/entry.h" #include "main/shim/helpers.h" +#include "main/shim/metrics_api.h" #include "osi/include/properties.h" #include "osi/include/stack_power_telemetry.h" #include "stack/btm/btm_int_types.h" @@ -60,7 +61,6 @@ #include "stack/include/main_thread.h" #include "stack/include/sco_hci_link_interface.h" #include "stack/include/sdpdefs.h" -#include "stack/include/stack_metrics_logging.h" #include "types/raw_address.h" extern tBTM_CB btm_cb; @@ -1298,7 +1298,8 @@ static void btm_sco_on_disconnected(uint16_t hci_handle, tHCI_REASON reason) { if (fill_plc_stats(&num_decoded_frames, &packet_loss_ratio)) { const int16_t codec_id = sco_codec_type_to_id(codec_type); const std::string codec = sco_codec_type_text(codec_type); - log_hfp_audio_packet_loss_stats(bd_addr, num_decoded_frames, packet_loss_ratio, codec_id); + bluetooth::shim::LogMetricHfpPacketLossStats(bd_addr, num_decoded_frames, packet_loss_ratio, + codec_id); log::debug( "Stopped SCO codec:{}, num_decoded_frames:{}, " "packet_loss_ratio:{:f}", diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc index b00b779eee..3eda3ca519 100644 --- a/system/stack/btm/btm_sec.cc +++ b/system/stack/btm/btm_sec.cc @@ -47,6 +47,7 @@ #include "main/shim/acl_api.h" #include "main/shim/entry.h" #include "main/shim/helpers.h" +#include "main/shim/metrics_api.h" #include "metrics/bluetooth_event.h" #include "osi/include/allocator.h" #include "osi/include/properties.h" @@ -75,7 +76,6 @@ #include "stack/include/main_thread.h" #include "stack/include/rnr_interface.h" #include "stack/include/smp_api.h" -#include "stack/include/stack_metrics_logging.h" #include "types/bt_transport.h" #include "types/raw_address.h" @@ -1923,7 +1923,7 @@ static void btm_sec_bond_cancel_complete(void) { void btm_create_conn_cancel_complete(uint8_t status, const RawAddress bd_addr) { log::verbose("btm_create_conn_cancel_complete(): in State: {} status:{}", tBTM_SEC_CB::btm_pair_state_descr(btm_sec_cb.pairing_state), status); - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( &bd_addr, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, android::bluetooth::hci::CMD_CREATE_CONNECTION_CANCEL, diff --git a/system/stack/btm/security_event_parser.cc b/system/stack/btm/security_event_parser.cc index 84d7005d16..deba84b67f 100644 --- a/system/stack/btm/security_event_parser.cc +++ b/system/stack/btm/security_event_parser.cc @@ -25,10 +25,10 @@ #include "common/metrics.h" #include "hci/hci_packets.h" #include "main/shim/helpers.h" +#include "main/shim/metrics_api.h" #include "stack/include/btm_sec_api_types.h" #include "stack/include/hci_error_code.h" #include "stack/include/sec_hci_link_interface.h" -#include "stack/include/stack_metrics_logging.h" #include "types/raw_address.h" using namespace bluetooth; @@ -46,8 +46,8 @@ static void log_address_and_status(const Address& bda, EventCode event_code, uint16_t reason = android::bluetooth::hci::STATUS_UNKNOWN; uint16_t handle = bluetooth::common::kUnknownConnectionHandle; int64_t value = 0; - log_classic_pairing_event(ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), - status, reason, value); + bluetooth::shim::LogMetricClassicPairingEvent( + ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), status, reason, value); } static void log_address(const Address& bda, EventCode event_code) { uint32_t cmd = android::bluetooth::hci::CMD_UNKNOWN; @@ -55,8 +55,8 @@ static void log_address(const Address& bda, EventCode event_code) { uint16_t reason = android::bluetooth::hci::STATUS_UNKNOWN; uint16_t handle = bluetooth::common::kUnknownConnectionHandle; int64_t value = 0; - log_classic_pairing_event(ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), - status, reason, value); + bluetooth::shim::LogMetricClassicPairingEvent( + ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), status, reason, value); } static void parse_encryption_change(const EventView event) { auto change_opt = EncryptionChangeView::CreateOptional(event); @@ -69,7 +69,7 @@ static void parse_encryption_change(const EventView event) { btm_sec_encryption_change_evt(handle, static_cast<tHCI_STATUS>(status), static_cast<uint8_t>(encr_enable), 0); - log_classic_pairing_event( + bluetooth::shim::LogMetricClassicPairingEvent( ToRawAddress(Address::kEmpty), handle, android::bluetooth::hci::CMD_UNKNOWN, static_cast<uint32_t>(change.GetEventCode()), static_cast<uint16_t>(status), android::bluetooth::hci::STATUS_UNKNOWN, 0); @@ -86,7 +86,7 @@ static void parse_encryption_change_v2(const EventView event) { btm_sec_encryption_change_evt(handle, static_cast<tHCI_STATUS>(status), static_cast<uint8_t>(encr_enable), key_size); - log_classic_pairing_event( + bluetooth::shim::LogMetricClassicPairingEvent( ToRawAddress(Address::kEmpty), handle, android::bluetooth::hci::CMD_UNKNOWN, static_cast<uint32_t>(change.GetEventCode()), static_cast<uint16_t>(status), android::bluetooth::hci::STATUS_UNKNOWN, 0); @@ -96,7 +96,7 @@ static void parse_change_connection_link_key_complete(const EventView event) { log::assert_that(complete_opt.has_value(), "assert failed: complete_opt.has_value()"); auto complete = complete_opt.value(); - log_classic_pairing_event( + bluetooth::shim::LogMetricClassicPairingEvent( ToRawAddress(Address::kEmpty), complete.GetConnectionHandle(), android::bluetooth::hci::CMD_UNKNOWN, static_cast<uint32_t>(complete.GetEventCode()), static_cast<uint16_t>(complete.GetStatus()), android::bluetooth::hci::STATUS_UNKNOWN, 0); diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc index 7a4b6d1256..ee3c9757a5 100644 --- a/system/stack/btu/btu_hcif.cc +++ b/system/stack/btu/btu_hcif.cc @@ -40,6 +40,7 @@ #include "common/metrics.h" #include "internal_include/bt_target.h" #include "main/shim/hci_layer.h" +#include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "stack/include/acl_api.h" #include "stack/include/acl_hci_link_interface.h" @@ -59,7 +60,6 @@ #include "stack/include/sco_hci_link_interface.h" #include "stack/include/sec_hci_link_interface.h" #include "stack/include/smp_api.h" -#include "stack/include/stack_metrics_logging.h" #include "types/hci_role.h" #include "types/raw_address.h" @@ -125,25 +125,29 @@ static void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event) case HCI_KEYPRESS_NOTIFY_EVT: case HCI_REMOTE_OOB_DATA_REQUEST_EVT: STREAM_TO_BDADDR(bda, p_event); - log_classic_pairing_event(bda, handle, cmd, evt_code, status, reason, value); + bluetooth::shim::LogMetricClassicPairingEvent(bda, handle, cmd, evt_code, status, reason, + value); break; case HCI_SIMPLE_PAIRING_COMPLETE_EVT: STREAM_TO_UINT8(status, p_event); STREAM_TO_BDADDR(bda, p_event); - log_classic_pairing_event(bda, handle, cmd, evt_code, status, reason, value); + bluetooth::shim::LogMetricClassicPairingEvent(bda, handle, cmd, evt_code, status, reason, + value); break; case HCI_AUTHENTICATION_COMP_EVT: STREAM_TO_UINT8(status, p_event); STREAM_TO_UINT16(handle, p_event); handle = HCID_GET_HANDLE(handle); - log_classic_pairing_event(bda, handle, cmd, evt_code, status, reason, value); + bluetooth::shim::LogMetricClassicPairingEvent(bda, handle, cmd, evt_code, status, reason, + value); break; case HCI_ENCRYPTION_CHANGE_EVT: { uint8_t encryption_enabled; STREAM_TO_UINT8(status, p_event); STREAM_TO_UINT16(handle, p_event); STREAM_TO_UINT8(encryption_enabled, p_event); - log_classic_pairing_event(bda, handle, cmd, evt_code, status, reason, encryption_enabled); + bluetooth::shim::LogMetricClassicPairingEvent(bda, handle, cmd, evt_code, status, reason, + encryption_enabled); break; } case HCI_ENCRYPTION_CHANGE_EVT_V2: { @@ -153,7 +157,8 @@ static void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event) STREAM_TO_UINT16(handle, p_event); STREAM_TO_UINT8(encryption_enabled, p_event); STREAM_TO_UINT8(key_size, p_event); - log_classic_pairing_event(bda, handle, cmd, evt_code, status, reason, encryption_enabled); + bluetooth::shim::LogMetricClassicPairingEvent(bda, handle, cmd, evt_code, status, reason, + encryption_enabled); break; } case HCI_ESCO_CONNECTION_COMP_EVT: { @@ -163,18 +168,19 @@ static void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event) STREAM_TO_BDADDR(bda, p_event); STREAM_TO_UINT8(link_type, p_event); handle = HCID_GET_HANDLE(handle); - log_link_layer_connection_event(&bda, handle, android::bluetooth::DIRECTION_UNKNOWN, - link_type, cmd, evt_code, - android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason); + bluetooth::shim::LogMetricLinkLayerConnectionEvent( + &bda, handle, android::bluetooth::DIRECTION_UNKNOWN, link_type, cmd, evt_code, + android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason); break; } case HCI_ESCO_CONNECTION_CHANGED_EVT: { STREAM_TO_UINT8(status, p_event); STREAM_TO_UINT16(handle, p_event); handle = HCID_GET_HANDLE(handle); - log_link_layer_connection_event(nullptr, handle, android::bluetooth::DIRECTION_UNKNOWN, - android::bluetooth::LINK_TYPE_UNKNOWN, cmd, evt_code, - android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason); + bluetooth::shim::LogMetricLinkLayerConnectionEvent( + nullptr, handle, android::bluetooth::DIRECTION_UNKNOWN, + android::bluetooth::LINK_TYPE_UNKNOWN, cmd, evt_code, + android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason); break; } // Ignore these events @@ -368,7 +374,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, case HCI_CREATE_CONNECTION: case HCI_CREATE_CONNECTION_CANCEL: STREAM_TO_BDADDR(bd_addr, p_cmd); - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( &bd_addr, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode, hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN); @@ -376,23 +382,24 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, case HCI_DISCONNECT: STREAM_TO_UINT16(handle, p_cmd); STREAM_TO_UINT8(reason, p_cmd); - log_link_layer_connection_event(nullptr, handle, android::bluetooth::DIRECTION_UNKNOWN, - android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, - kUnknownBleEvt, cmd_status, reason); + bluetooth::shim::LogMetricLinkLayerConnectionEvent( + nullptr, handle, android::bluetooth::DIRECTION_UNKNOWN, + android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, kUnknownBleEvt, cmd_status, + reason); break; case HCI_SETUP_ESCO_CONNECTION: case HCI_ENH_SETUP_ESCO_CONNECTION: STREAM_TO_UINT16(handle, p_cmd); - log_link_layer_connection_event(nullptr, handle, android::bluetooth::DIRECTION_OUTGOING, - android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, - kUnknownBleEvt, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN); + bluetooth::shim::LogMetricLinkLayerConnectionEvent( + nullptr, handle, android::bluetooth::DIRECTION_OUTGOING, + android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, kUnknownBleEvt, cmd_status, + android::bluetooth::hci::STATUS_UNKNOWN); break; case HCI_ACCEPT_CONNECTION_REQUEST: case HCI_ACCEPT_ESCO_CONNECTION: case HCI_ENH_ACCEPT_ESCO_CONNECTION: STREAM_TO_BDADDR(bd_addr, p_cmd); - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( &bd_addr, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_INCOMING, android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN); @@ -401,10 +408,10 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, case HCI_REJECT_ESCO_CONNECTION: STREAM_TO_BDADDR(bd_addr, p_cmd); STREAM_TO_UINT8(reason, p_cmd); - log_link_layer_connection_event(&bd_addr, bluetooth::common::kUnknownConnectionHandle, - android::bluetooth::DIRECTION_INCOMING, - android::bluetooth::LINK_TYPE_UNKNOWN, opcode, hci_event, - kUnknownBleEvt, cmd_status, reason); + bluetooth::shim::LogMetricLinkLayerConnectionEvent( + &bd_addr, bluetooth::common::kUnknownConnectionHandle, + android::bluetooth::DIRECTION_INCOMING, android::bluetooth::LINK_TYPE_UNKNOWN, opcode, + hci_event, kUnknownBleEvt, cmd_status, reason); break; // BLE Commands @@ -431,7 +438,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, // Selectively log to avoid log spam due to acceptlist connections: // - When doing non-acceptlist connection // - When there is an error in command status - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( bd_addr_p, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode, hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN); @@ -456,7 +463,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, // Selectively log to avoid log spam due to acceptlist connections: // - When doing non-acceptlist connection // - When there is an error in command status - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( bd_addr_p, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode, hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN); @@ -466,7 +473,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, case HCI_BLE_CREATE_CONN_CANCEL: if (cmd_status != HCI_SUCCESS && !is_cmd_status) { // Only log errors to prevent log spam due to acceptlist connections - log_link_layer_connection_event( + bluetooth::shim::LogMetricLinkLayerConnectionEvent( nullptr, bluetooth::common::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode, hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN); @@ -474,46 +481,48 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, break; case HCI_READ_LOCAL_OOB_DATA: case HCI_READ_LOCAL_OOB_EXTENDED_DATA: - log_classic_pairing_event(RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, - opcode, hci_event, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN, 0); + bluetooth::shim::LogMetricClassicPairingEvent( + RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, + cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, 0); break; case HCI_WRITE_SIMPLE_PAIRING_MODE: { uint8_t simple_pairing_mode; STREAM_TO_UINT8(simple_pairing_mode, p_cmd); - log_classic_pairing_event(RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, - opcode, hci_event, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN, simple_pairing_mode); + bluetooth::shim::LogMetricClassicPairingEvent( + RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, + cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, simple_pairing_mode); break; } case HCI_WRITE_SECURE_CONNS_SUPPORT: { uint8_t secure_conn_host_support; STREAM_TO_UINT8(secure_conn_host_support, p_cmd); - log_classic_pairing_event(RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, - opcode, hci_event, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN, secure_conn_host_support); + bluetooth::shim::LogMetricClassicPairingEvent( + RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, + cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, secure_conn_host_support); break; } case HCI_AUTHENTICATION_REQUESTED: STREAM_TO_UINT16(handle, p_cmd); - log_classic_pairing_event(RawAddress::kEmpty, handle, opcode, hci_event, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN, 0); + bluetooth::shim::LogMetricClassicPairingEvent(RawAddress::kEmpty, handle, opcode, hci_event, + cmd_status, + android::bluetooth::hci::STATUS_UNKNOWN, 0); break; case HCI_SET_CONN_ENCRYPTION: { STREAM_TO_UINT16(handle, p_cmd); uint8_t encryption_enable; STREAM_TO_UINT8(encryption_enable, p_cmd); - log_classic_pairing_event(RawAddress::kEmpty, handle, opcode, hci_event, cmd_status, - android::bluetooth::hci::STATUS_UNKNOWN, encryption_enable); + bluetooth::shim::LogMetricClassicPairingEvent( + RawAddress::kEmpty, handle, opcode, hci_event, cmd_status, + android::bluetooth::hci::STATUS_UNKNOWN, encryption_enable); break; } case HCI_DELETE_STORED_LINK_KEY: { uint8_t delete_all_flag; STREAM_TO_BDADDR(bd_addr, p_cmd); STREAM_TO_UINT8(delete_all_flag, p_cmd); - log_classic_pairing_event(bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, - hci_event, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, - delete_all_flag); + bluetooth::shim::LogMetricClassicPairingEvent( + bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, cmd_status, + android::bluetooth::hci::STATUS_UNKNOWN, delete_all_flag); break; } case HCI_RMT_NAME_REQUEST: @@ -528,14 +537,16 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd, case HCI_REM_OOB_DATA_REQ_REPLY: case HCI_REM_OOB_DATA_REQ_NEG_REPLY: STREAM_TO_BDADDR(bd_addr, p_cmd); - log_classic_pairing_event(bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, - hci_event, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, 0); + bluetooth::shim::LogMetricClassicPairingEvent( + bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, cmd_status, + android::bluetooth::hci::STATUS_UNKNOWN, 0); break; case HCI_IO_CAP_REQ_NEG_REPLY: STREAM_TO_BDADDR(bd_addr, p_cmd); STREAM_TO_UINT8(reason, p_cmd); - log_classic_pairing_event(bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, - hci_event, cmd_status, reason, 0); + bluetooth::shim::LogMetricClassicPairingEvent(bd_addr, + bluetooth::common::kUnknownConnectionHandle, + opcode, hci_event, cmd_status, reason, 0); break; } } @@ -599,8 +610,9 @@ static void btu_hcif_log_command_complete_metrics(uint16_t opcode, const uint8_t case HCI_WRITE_SIMPLE_PAIRING_MODE: case HCI_WRITE_SECURE_CONNS_SUPPORT: STREAM_TO_UINT8(status, p_return_params); - log_classic_pairing_event(RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, - opcode, hci_event, status, reason, 0); + bluetooth::shim::LogMetricClassicPairingEvent(RawAddress::kEmpty, + bluetooth::common::kUnknownConnectionHandle, + opcode, hci_event, status, reason, 0); break; case HCI_READ_ENCR_KEY_SIZE: { uint16_t handle; @@ -608,8 +620,8 @@ static void btu_hcif_log_command_complete_metrics(uint16_t opcode, const uint8_t STREAM_TO_UINT8(status, p_return_params); STREAM_TO_UINT16(handle, p_return_params); STREAM_TO_UINT8(key_size, p_return_params); - log_classic_pairing_event(RawAddress::kEmpty, handle, opcode, hci_event, status, reason, - key_size); + bluetooth::shim::LogMetricClassicPairingEvent(RawAddress::kEmpty, handle, opcode, hci_event, + status, reason, key_size); break; } case HCI_LINK_KEY_REQUEST_REPLY: @@ -624,8 +636,9 @@ static void btu_hcif_log_command_complete_metrics(uint16_t opcode, const uint8_t case HCI_REM_OOB_DATA_REQ_NEG_REPLY: STREAM_TO_UINT8(status, p_return_params); STREAM_TO_BDADDR(bd_addr, p_return_params); - log_classic_pairing_event(bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, - hci_event, status, reason, 0); + bluetooth::shim::LogMetricClassicPairingEvent(bd_addr, + bluetooth::common::kUnknownConnectionHandle, + opcode, hci_event, status, reason, 0); break; } } diff --git a/system/stack/gatt/gatt_api.cc b/system/stack/gatt/gatt_api.cc index 1b60132b00..7b1a425f5e 100644 --- a/system/stack/gatt/gatt_api.cc +++ b/system/stack/gatt/gatt_api.cc @@ -34,6 +34,7 @@ #include "internal_include/bt_target.h" #include "internal_include/stack_config.h" #include "main/shim/helpers.h" +#include "main/shim/metrics_api.h" #include "os/system_properties.h" #include "osi/include/allocator.h" #include "stack/arbiter/acl_arbiter.h" @@ -48,7 +49,6 @@ #include "stack/include/l2cap_interface.h" #include "stack/include/l2cdefs.h" #include "stack/include/sdp_api.h" -#include "stack/include/stack_metrics_logging.h" #include "types/bluetooth/uuid.h" #include "types/bt_transport.h" #include "types/raw_address.h" @@ -1476,7 +1476,8 @@ bool GATT_Connect(tGATT_IF gatt_if, const RawAddress& bd_addr, tBLE_ADDR_TYPE ad return true; } - log_le_connection_lifecycle(ToGdAddress(bd_addr), true /* is_connect */, is_direct); + bluetooth::shim::LogMetricLeConnectionLifecycle(ToGdAddress(bd_addr), true /* is_connect */, + is_direct); bool ret = false; if (is_direct) { @@ -1618,8 +1619,8 @@ tGATT_STATUS GATT_Disconnect(tCONN_ID conn_id) { return GATT_ILLEGAL_PARAMETER; } - log_le_connection_lifecycle(ToGdAddress(p_tcb->peer_bda), true /* is_connect */, - false /* is_direct */); + bluetooth::shim::LogMetricLeConnectionLifecycle(ToGdAddress(p_tcb->peer_bda), + true /* is_connect */, false /* is_direct */); tGATT_IF gatt_if = gatt_get_gatt_if(conn_id); gatt_update_app_use_link_flag(gatt_if, p_tcb, false, true); diff --git a/system/stack/hid/hidd_api.cc b/system/stack/hid/hidd_api.cc index 169868bbfc..58d9bdc07a 100644 --- a/system/stack/hid/hidd_api.cc +++ b/system/stack/hid/hidd_api.cc @@ -38,13 +38,13 @@ #include "hidd_int.h" #include "hiddefs.h" #include "internal_include/bt_target.h" +#include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "stack/include/bt_psm_types.h" #include "stack/include/bt_types.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdp_api.h" #include "stack/include/sdpdefs.h" -#include "stack/include/stack_metrics_logging.h" #include "stack/sdp/sdp_discovery_db.h" #include "types/raw_address.h" @@ -83,12 +83,14 @@ tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback) { log::verbose(""); if (hd_cb.reg_flag) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_ALREADY_REGISTERED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_ALREADY_REGISTERED, 1); return HID_ERR_ALREADY_REGISTERED; } if (host_cback == NULL) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_HOST_CALLBACK_NULL, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_HOST_CALLBACK_NULL, 1); return HID_ERR_INVALID_PARAM; } @@ -122,7 +124,7 @@ tHID_STATUS HID_DevDeregister(void) { log::verbose(""); if (!hd_cb.reg_flag) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_DEREGISTER, 1); return HID_ERR_NOT_REGISTERED; } @@ -263,9 +265,10 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description, if (desc_len > HIDD_APP_DESCRIPTOR_LEN) { log::error("descriptor length = {}, larger than max {}", desc_len, HIDD_APP_DESCRIPTOR_LEN); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum:: - HIDD_ERR_NOT_REGISTERED_DUE_TO_DESCRIPTOR_LENGTH, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum:: + HIDD_ERR_NOT_REGISTERED_DUE_TO_DESCRIPTOR_LENGTH, + 1); return HID_ERR_NOT_REGISTERED; }; @@ -273,9 +276,10 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description, if (p_buf == NULL) { log::error("Buffer allocation failure for size = {}", buf_len); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum:: - HIDD_ERR_NOT_REGISTERED_DUE_TO_BUFFER_ALLOCATION, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum:: + HIDD_ERR_NOT_REGISTERED_DUE_TO_BUFFER_ALLOCATION, + 1); return HID_ERR_NOT_REGISTERED; } @@ -346,8 +350,8 @@ tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, char* p_description, if (!result) { log::error("failed to complete SDP record"); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_SDP, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_SDP, 1); return HID_ERR_NOT_REGISTERED; } @@ -376,7 +380,7 @@ tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id, uint16_ return hidd_conn_send_data(HID_CHANNEL_INTR, HID_TRANS_DATA, HID_PAR_REP_TYPE_INPUT, id, len, p_data); } - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_INVALID_PARAM_SEND_REPORT, 1); return HID_ERR_INVALID_PARAM; } @@ -444,19 +448,20 @@ tHID_STATUS HID_DevUnplugDevice(const RawAddress& addr) { ******************************************************************************/ tHID_STATUS HID_DevConnect(void) { if (!hd_cb.reg_flag) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_CONNECT, 1); return HID_ERR_NOT_REGISTERED; } if (!hd_cb.device.in_use) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_DEVICE_NOT_IN_USE_AT_CONNECT, 1); return HID_ERR_INVALID_PARAM; } if (hd_cb.device.state != HIDD_DEV_NO_CONN) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_ALREADY_CONN, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_ALREADY_CONN, 1); return HID_ERR_ALREADY_CONN; } @@ -474,13 +479,13 @@ tHID_STATUS HID_DevConnect(void) { ******************************************************************************/ tHID_STATUS HID_DevDisconnect(void) { if (!hd_cb.reg_flag) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_DISCONNECT, 1); return HID_ERR_NOT_REGISTERED; } if (!hd_cb.device.in_use) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_DEVICE_NOT_IN_USE_AT_DISCONNECT, 1); return HID_ERR_INVALID_PARAM; @@ -492,10 +497,11 @@ tHID_STATUS HID_DevDisconnect(void) { tHID_STATUS ret = hidd_conn_disconnect(); hd_cb.device.conn.conn_state = HID_CONN_STATE_UNUSED; hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, HID_ERR_DISCONNECTING, NULL); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_DISCONNECTING, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_DISCONNECTING, 1); return ret; } - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NO_CONNECTION_AT_DISCONNECT, 1); return HID_ERR_NO_CONNECTION; } @@ -565,7 +571,7 @@ tHID_STATUS HID_DevGetDevice(RawAddress* addr) { if (hd_cb.device.in_use) { *addr = hd_cb.device.addr; } else { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_GET_DEVICE, 1); return HID_ERR_NOT_REGISTERED; } diff --git a/system/stack/hid/hidd_conn.cc b/system/stack/hid/hidd_conn.cc index 7276af8acd..5f94c1c870 100644 --- a/system/stack/hid/hidd_conn.cc +++ b/system/stack/hid/hidd_conn.cc @@ -37,13 +37,13 @@ #include "hiddefs.h" #include "internal_include/bt_target.h" #include "l2cap_types.h" +#include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "stack/hid/hidd_int.h" #include "stack/include/bt_hdr.h" #include "stack/include/bt_psm_types.h" #include "stack/include/l2cap_interface.h" #include "stack/include/l2cdefs.h" -#include "stack/include/stack_metrics_logging.h" #include "types/bt_transport.h" #include "types/raw_address.h" @@ -300,7 +300,7 @@ static void hidd_l2cif_config_cfm(uint16_t cid, uint16_t /* initiator */, tL2CAP log::warn("could not start L2CAP connection for INTR"); hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, HID_ERR_L2CAP_FAILED, NULL); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_NOT_STARTED_INCOMING, 1); return; } else { @@ -577,8 +577,8 @@ tHID_STATUS hidd_conn_reg(void) { HID_PSM_CONTROL, dev_reg_info, false /* enable_snoop */, nullptr, HID_DEV_MTU_SIZE, 0, BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) { log::error("HID Control (device) registration failed"); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_CONTROL, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_CONTROL, 1); return HID_ERR_L2CAP_FAILED; } @@ -587,8 +587,8 @@ tHID_STATUS hidd_conn_reg(void) { 0, BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) { stack::l2cap::get_interface().L2CA_Deregister(HID_PSM_CONTROL); log::error("HID Interrupt (device) registration failed"); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_INTERRUPT, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_INTERRUPT, 1); return HID_ERR_L2CAP_FAILED; } @@ -627,14 +627,15 @@ tHID_STATUS hidd_conn_initiate(void) { if (!p_dev->in_use) { log::warn("no virtual cable established"); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NOT_REGISTERED_AT_INITIATE, 1); return HID_ERR_NOT_REGISTERED; } if (p_dev->conn.conn_state != HID_CONN_STATE_UNUSED) { log::warn("connection already in progress"); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_CONN_IN_PROCESS, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_CONN_IN_PROCESS, 1); return HID_ERR_CONN_IN_PROCESS; } @@ -649,8 +650,8 @@ tHID_STATUS hidd_conn_initiate(void) { HID_PSM_CONTROL, p_dev->addr, BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) == 0) { log::warn("could not start L2CAP connection"); hd_cb.callback(hd_cb.device.addr, HID_DHOST_EVT_CLOSE, HID_ERR_L2CAP_FAILED, NULL); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_INITIATE, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_L2CAP_FAILED_INITIATE, 1); } else { p_dev->conn.conn_state = HID_CONN_STATE_CONNECTING_CTRL; } @@ -723,7 +724,7 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type, uint8_t param tHID_CONN* p_hcon = &hd_cb.device.conn; if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_CONGESTED_AT_FLAG_CHECK, 1); return HID_ERR_CONGESTED; } @@ -744,13 +745,15 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type, uint8_t param } break; default: - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_INVALID_PARAM, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_INVALID_PARAM, 1); return HID_ERR_INVALID_PARAM; } p_buf = (BT_HDR*)osi_malloc(buf_size); if (p_buf == NULL) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NO_RESOURCES, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NO_RESOURCES, 1); return HID_ERR_NO_RESOURCES; } @@ -792,7 +795,7 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type, uint8_t param return HID_SUCCESS; } - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_NO_CONNECTION_AT_SEND_DATA, 1); return HID_ERR_NO_CONNECTION; } @@ -800,7 +803,7 @@ tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type, uint8_t param log::verbose("report sent"); if (stack::l2cap::get_interface().L2CA_DataWrite(cid, p_buf) == tL2CAP_DW_RESULT::FAILED) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDD_ERR_CONGESTED_AT_DATA_WRITE, 1); return HID_ERR_CONGESTED; } diff --git a/system/stack/hid/hidh_api.cc b/system/stack/hid/hidh_api.cc index 97d811ed5b..1ab5ba2a6a 100644 --- a/system/stack/hid/hidh_api.cc +++ b/system/stack/hid/hidh_api.cc @@ -37,6 +37,7 @@ #include "hiddefs.h" #include "hidh_int.h" #include "internal_include/bt_target.h" +#include "main/shim/metrics_api.h" #include "osi/include/alarm.h" #include "osi/include/allocator.h" #include "sdp_api.h" @@ -44,7 +45,6 @@ #include "stack/include/bt_hdr.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdpdefs.h" -#include "stack/include/stack_metrics_logging.h" #include "stack/sdp/sdp_discovery_db.h" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" @@ -69,7 +69,8 @@ static void hidh_search_callback(const RawAddress& bd_addr, tSDP_RESULT sdp_resu tHID_STATUS HID_HostGetSDPRecord(const RawAddress& addr, tSDP_DISCOVERY_DB* p_db, uint32_t db_len, tHID_HOST_SDP_CALLBACK* sdp_cback) { if (hh_cb.sdp_busy) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_SDP_BUSY, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_SDP_BUSY, 1); return HID_ERR_SDP_BUSY; } @@ -87,7 +88,8 @@ tHID_STATUS HID_HostGetSDPRecord(const RawAddress& addr, tSDP_DISCOVERY_DB* p_db return HID_SUCCESS; } else { log::warn("Unable to start SDP service search request peer:{}", addr); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_RESOURCES_SDP, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_RESOURCES_SDP, 1); return HID_ERR_NO_RESOURCES; } } @@ -289,12 +291,13 @@ tHID_STATUS HID_HostRegister(tHID_HOST_DEV_CALLBACK* dev_cback) { tHID_STATUS st; if (hh_cb.reg_flag) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_ALREADY_REGISTERED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_ALREADY_REGISTERED, 1); return HID_ERR_ALREADY_REGISTERED; } if (dev_cback == NULL) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_REGISTER, 1); return HID_ERR_INVALID_PARAM; } @@ -392,7 +395,7 @@ tHID_STATUS HID_HostAddDev(const RawAddress& addr, uint16_t attr_mask, uint8_t* } if (i == HID_HOST_MAX_DEVICES) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_RESOURCES_ADD_DEVICE, 1); return HID_ERR_NO_RESOURCES; } @@ -427,7 +430,7 @@ tHID_STATUS HID_HostRemoveDev(uint8_t dev_handle) { } if ((dev_handle >= HID_HOST_MAX_DEVICES) || (!hh_cb.devices[dev_handle].in_use)) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_REMOVE_DEV, 1); return HID_ERR_INVALID_PARAM; @@ -457,13 +460,14 @@ tHID_STATUS HID_HostOpenDev(uint8_t dev_handle) { } if ((dev_handle >= HID_HOST_MAX_DEVICES) || (!hh_cb.devices[dev_handle].in_use)) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_OPEN_DEV, 1); return HID_ERR_INVALID_PARAM; } if (hh_cb.devices[dev_handle].state != HID_DEV_NO_CONN) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_ALREADY_CONN, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_ALREADY_CONN, 1); return HID_ERR_ALREADY_CONN; } @@ -494,13 +498,13 @@ tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type, uint8_t param, if ((dev_handle >= HID_HOST_MAX_DEVICES) || (!hh_cb.devices[dev_handle].in_use)) { log::error("HID_ERR_INVALID_PARAM"); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_WRITE_DEV, 1); status = HID_ERR_INVALID_PARAM; } else if (hh_cb.devices[dev_handle].state != HID_DEV_CONNECTED) { log::error("HID_ERR_NO_CONNECTION dev_handle {}", dev_handle); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_CONNECTION_AT_HOST_WRITE_DEV, 1); status = HID_ERR_NO_CONNECTION; @@ -530,14 +534,14 @@ tHID_STATUS HID_HostCloseDev(uint8_t dev_handle) { } if ((dev_handle >= HID_HOST_MAX_DEVICES) || (!hh_cb.devices[dev_handle].in_use)) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_HOST_CLOSE_DEV, 1); return HID_ERR_INVALID_PARAM; } if (hh_cb.devices[dev_handle].state != HID_DEV_CONNECTED) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_CONNECTION_AT_HOST_CLOSE_DEV, 1); return HID_ERR_NO_CONNECTION; diff --git a/system/stack/hid/hidh_conn.cc b/system/stack/hid/hidh_conn.cc index cdc7906d16..71785478a1 100644 --- a/system/stack/hid/hidh_conn.cc +++ b/system/stack/hid/hidh_conn.cc @@ -39,6 +39,7 @@ #include "internal_include/bt_target.h" #include "l2cap_types.h" #include "l2cdefs.h" +#include "main/shim/metrics_api.h" #include "osi/include/alarm.h" #include "osi/include/allocator.h" #include "osi/include/osi.h" @@ -48,7 +49,6 @@ #include "stack/include/btm_client_interface.h" #include "stack/include/btm_log_history.h" #include "stack/include/l2cap_interface.h" -#include "stack/include/stack_metrics_logging.h" #include "types/bt_transport.h" #include "types/raw_address.h" @@ -119,7 +119,7 @@ tHID_STATUS hidh_conn_reg(void) { HID_PSM_CONTROL, hst_reg_info, false /* enable_snoop */, nullptr, HID_HOST_MTU, 0, BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) { log::error("HID-Host Control Registration failed"); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_L2CAP_FAILED_AT_REGISTER_CONTROL, 1); return HID_ERR_L2CAP_FAILED; @@ -129,7 +129,7 @@ tHID_STATUS hidh_conn_reg(void) { BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)) { stack::l2cap::get_interface().L2CA_Deregister(HID_PSM_CONTROL); log::error("HID-Host Interrupt Registration failed"); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_L2CAP_FAILED_AT_REGISTER_INTERRUPT, 1); return HID_ERR_L2CAP_FAILED; @@ -549,7 +549,8 @@ static void hidh_l2cif_disconnect_ind(uint16_t l2cap_cid, bool ack_needed) { (disc_res == HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED) || (disc_res == HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE) || (disc_res == HCI_ERR_REPEATED_ATTEMPTS)) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_AUTH_FAILED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_AUTH_FAILED, 1); hid_close_evt_reason = HID_ERR_AUTH_FAILED; } @@ -771,14 +772,14 @@ tHID_STATUS hidh_conn_snd_data(uint8_t dhandle, uint8_t trans_type, uint8_t para if (!get_btm_client_interface().peer.BTM_IsAclConnectionUp(hh_cb.devices[dhandle].addr, BT_TRANSPORT_BR_EDR)) { osi_free(buf); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_NO_CONNECTION_AT_SEND_DATA, 1); return HID_ERR_NO_CONNECTION; } if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED) { osi_free(buf); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_CONGESTED_AT_FLAG_CHECK, 1); return HID_ERR_CONGESTED; } @@ -799,7 +800,7 @@ tHID_STATUS hidh_conn_snd_data(uint8_t dhandle, uint8_t trans_type, uint8_t para buf_size = HID_INTERRUPT_BUF_SIZE; break; default: - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_INVALID_PARAM_AT_SEND_DATA, 1); return HID_ERR_INVALID_PARAM; } @@ -860,7 +861,7 @@ tHID_STATUS hidh_conn_snd_data(uint8_t dhandle, uint8_t trans_type, uint8_t para /* Send the buffer through L2CAP */ if ((p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED) || (stack::l2cap::get_interface().L2CA_DataWrite(cid, p_buf) == tL2CAP_DW_RESULT::FAILED)) { - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_CONGESTED_AT_SEND_DATA, 1); return HID_ERR_CONGESTED; } @@ -889,7 +890,8 @@ tHID_STATUS hidh_conn_initiate(uint8_t dhandle) { tHID_HOST_DEV_CTB* p_dev = &hh_cb.devices[dhandle]; if (p_dev->conn.conn_state != HID_CONN_STATE_UNUSED) { - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_CONN_IN_PROCESS, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_CONN_IN_PROCESS, 1); return HID_ERR_CONN_IN_PROCESS; } @@ -908,7 +910,7 @@ tHID_STATUS hidh_conn_initiate(uint8_t dhandle) { log::warn("HID-Host Originate failed"); hh_cb.callback(dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, HID_ERR_L2CAP_FAILED, NULL); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::HIDH_ERR_L2CAP_FAILED_AT_INITIATE, 1); } else { /* Transition to the next appropriate state, waiting for connection confirm diff --git a/system/stack/include/stack_metrics_logging.h b/system/stack/include/stack_metrics_logging.h deleted file mode 100644 index 9a0a80baa4..0000000000 --- a/system/stack/include/stack_metrics_logging.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> - -#include <cstdint> - -#include "hci/address.h" -#include "hci/hci_packets.h" -#include "types/raw_address.h" - -void log_classic_pairing_event(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value); - -void log_link_layer_connection_event(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, - 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); - -void log_smp_pairing_event(const RawAddress& address, uint16_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint16_t smp_fail_reason); - -void log_sdp_attribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value); - -void log_manufacturer_info(const RawAddress& address, - android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version); - -void log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum key, int64_t value); - -void log_hfp_audio_packet_loss_stats(const RawAddress& address, int num_decoded_frames, - double packet_loss_ratio, uint16_t codec_type); - -void log_mmc_transcode_rtt_stats(int maximum_rtt, double mean_rtt, int num_requests, - int codec_type); - -void log_le_pairing_fail(const RawAddress& raw_address, uint8_t failure_reason, bool is_outgoing); - -void log_le_connection_status(bluetooth::hci::Address address, bool is_connect, - bluetooth::hci::ErrorCode reason); - -void log_le_device_in_accept_list(bluetooth::hci::Address address, bool is_add); - -void log_le_connection_lifecycle(bluetooth::hci::Address address, bool is_connect, bool is_direct); - -void log_le_connection_completion(bluetooth::hci::Address address, bluetooth::hci::ErrorCode reason, - bool is_locally_initiated); diff --git a/system/stack/metrics/stack_metrics_logging.cc b/system/stack/metrics/stack_metrics_logging.cc deleted file mode 100644 index 398a72ce33..0000000000 --- a/system/stack/metrics/stack_metrics_logging.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "stack/include/stack_metrics_logging.h" - -#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> - -#include "common/metrics.h" -#include "main/shim/metrics_api.h" -#include "main/shim/shim.h" -#include "types/raw_address.h" - -void log_classic_pairing_event(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value) { - bluetooth::shim::LogMetricClassicPairingEvent(address, handle, hci_cmd, hci_event, cmd_status, - reason_code, event_value); -} - -void log_link_layer_connection_event(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, - 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) { - bluetooth::shim::LogMetricLinkLayerConnectionEvent(address, connection_handle, direction, - link_type, hci_cmd, hci_event, hci_ble_event, - cmd_status, reason_code); -} - -void log_smp_pairing_event(const RawAddress& address, uint16_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint16_t smp_fail_reason) { - bluetooth::shim::LogMetricSmpPairingEvent(address, smp_cmd, direction, smp_fail_reason); -} - -void log_sdp_attribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value) { - bluetooth::shim::LogMetricSdpAttribute(address, protocol_uuid, attribute_id, attribute_size, - attribute_value); -} - -void log_manufacturer_info(const RawAddress& address, - android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version) { - bluetooth::shim::LogMetricManufacturerInfo(address, address_type, source_type, source_name, - manufacturer, model, hardware_version, - software_version); -} - -void log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum key, int64_t value) { - bluetooth::shim::CountCounterMetrics(key, value); -} - -void log_hfp_audio_packet_loss_stats(const RawAddress& address, int num_decoded_frames, - double packet_loss_ratio, uint16_t codec_type) { - bluetooth::shim::LogMetricHfpPacketLossStats(address, num_decoded_frames, packet_loss_ratio, - codec_type); -} - -void log_mmc_transcode_rtt_stats(int maximum_rtt, double mean_rtt, int num_requests, - int codec_type) { - bluetooth::shim::LogMetricMmcTranscodeRttStats(maximum_rtt, mean_rtt, num_requests, codec_type); -} - -void log_le_pairing_fail(const RawAddress& raw_address, uint8_t failure_reason, bool is_outgoing) { - bluetooth::shim::LogMetricLePairingFail(raw_address, failure_reason, is_outgoing); -} - -void log_le_connection_status(bluetooth::hci::Address address, bool is_connect, - bluetooth::hci::ErrorCode reason) { - bluetooth::shim::LogMetricLeConnectionStatus(address, is_connect, reason); -} - -void log_le_device_in_accept_list(bluetooth::hci::Address address, bool is_add) { - bluetooth::shim::LogMetricLeDeviceInAcceptList(address, is_add); -} - -void log_le_connection_lifecycle(bluetooth::hci::Address address, bool is_connect, bool is_direct) { - bluetooth::shim::LogMetricLeConnectionLifecycle(address, is_connect, is_direct); -} - -void log_le_connection_completion(bluetooth::hci::Address address, bluetooth::hci::ErrorCode reason, - bool is_locally_initiated) { - bluetooth::shim::LogMetricLeConnectionCompletion(address, reason, is_locally_initiated); -} diff --git a/system/stack/mmc/metrics/mmc_rtt_logger.cc b/system/stack/mmc/metrics/mmc_rtt_logger.cc index 761d825b44..c95566f0cb 100644 --- a/system/stack/mmc/metrics/mmc_rtt_logger.cc +++ b/system/stack/mmc/metrics/mmc_rtt_logger.cc @@ -20,7 +20,7 @@ #include <cmath> #include <string> -#include "stack/include/stack_metrics_logging.h" +#include "main/shim/metrics_api.h" namespace mmc { @@ -43,7 +43,8 @@ void MmcRttLogger::UploadTranscodeRttStatics() { if (num_requests_ == 0) { return; } - log_mmc_transcode_rtt_stats(maximum_rtt_, rtt_sum_ / num_requests_, num_requests_, codec_type_); + bluetooth::shim::LogMetricMmcTranscodeRttStats(maximum_rtt_, rtt_sum_ / num_requests_, + num_requests_, codec_type_); num_requests_ = 0; rtt_sum_ = 0; maximum_rtt_ = 0; diff --git a/system/stack/rfcomm/port_rfc.cc b/system/stack/rfcomm/port_rfc.cc index 860fdf0450..c1518665d9 100644 --- a/system/stack/rfcomm/port_rfc.cc +++ b/system/stack/rfcomm/port_rfc.cc @@ -36,12 +36,12 @@ #include "internal_include/bt_target.h" #include "internal_include/bt_trace.h" #include "main/shim/entry.h" +#include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "osi/include/mutex.h" #include "stack/include/bt_hdr.h" #include "stack/include/bt_uuid16.h" #include "stack/include/rfc_metrics.h" -#include "stack/include/stack_metrics_logging.h" #include "stack/l2cap/l2c_int.h" #include "stack/rfcomm/port_int.h" #include "stack/rfcomm/rfc_int.h" @@ -186,7 +186,8 @@ void port_start_close(tPORT* p_port) { * clear tPort */ if (p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_CLOSED, p_port->handle); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_START_CLOSE, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_START_CLOSE, 1); } port_release_port(p_port); @@ -230,7 +231,7 @@ void PORT_StartCnf(tRFC_MCB* p_mcb, uint16_t result) { if (p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_START_FAILED, p_port->handle); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_START_CNF_FAILED, 1); } port_release_port(p_port); @@ -457,14 +458,14 @@ void PORT_DlcEstablishInd(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu) { if (p_port->rfc_cfg_info.data_path != BTSOCK_DATA_PATH_HARDWARE_OFFLOAD && p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_IND, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_IND, 1); } } else { if (p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_IND, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_IND, 1); } } @@ -493,7 +494,8 @@ void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint16_t if (result != RFCOMM_SUCCESS) { log::warn("Unable to establish configuration dlci:{} result:{}", dlci, result); port_rfc_closed(p_port, PORT_START_FAILED); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_START_FAILED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_START_FAILED, 1); return; } @@ -513,14 +515,14 @@ void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint16_t if (p_port->rfc_cfg_info.data_path != BTSOCK_DATA_PATH_HARDWARE_OFFLOAD && p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_CNF, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_CNF, 1); } } else { if (p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_CNF, - 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_CNF, 1); } } @@ -590,7 +592,8 @@ void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* /* p_settings RFCOMM_DlcReleaseReq(p_mcb, p_port->dlci); port_rfc_closed(p_port, PORT_PORT_NEG_FAILED); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_NEG_FAILED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_NEG_FAILED, 1); return; } @@ -661,7 +664,7 @@ void PORT_ControlInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_CTRL* p_pars) { if (p_port->rfc_cfg_info.data_path == BTSOCK_DATA_PATH_HARDWARE_OFFLOAD) { if (p_port->port_ctrl == PORT_CTRL_SETUP_COMPLETED && p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_IND, 1); } } @@ -708,7 +711,7 @@ void PORT_ControlCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_CTRL* /* p_pars */) { if (p_port->rfc_cfg_info.data_path == BTSOCK_DATA_PATH_HARDWARE_OFFLOAD) { if (p_port->port_ctrl == PORT_CTRL_SETUP_COMPLETED && p_port->p_mgmt_callback) { p_port->p_mgmt_callback(PORT_SUCCESS, p_port->handle); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::RFCOMM_CONNECTION_SUCCESS_CNF, 1); } } @@ -767,7 +770,8 @@ void PORT_DlcReleaseInd(tRFC_MCB* p_mcb, uint8_t dlci) { return; } port_rfc_closed(p_port, PORT_CLOSED); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_CLOSED, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_CLOSED, 1); } /******************************************************************************* @@ -788,7 +792,7 @@ void PORT_CloseInd(tRFC_MCB* p_mcb) { for (i = 0; i < MAX_RFC_PORTS; i++, p_port++) { if (p_port->rfc.p_mcb == p_mcb) { port_rfc_closed(p_port, PORT_PEER_CONNECTION_FAILED); - log_counter_metrics( + bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_PEER_CONNECTION_FAILED, 1); } } @@ -813,7 +817,8 @@ void PORT_TimeOutCloseMux(tRFC_MCB* p_mcb) { for (i = 0; i < MAX_RFC_PORTS; i++, p_port++) { if (p_port->rfc.p_mcb == p_mcb) { port_rfc_closed(p_port, PORT_PEER_TIMEOUT); - log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_PEER_TIMEOUT, 1); + bluetooth::shim::CountCounterMetrics( + android::bluetooth::CodePathCounterKeyEnum::RFCOMM_PORT_PEER_TIMEOUT, 1); } } } diff --git a/system/stack/sdp/sdp_utils.cc b/system/stack/sdp/sdp_utils.cc index 2fb4f4622b..324f4dd06e 100644 --- a/system/stack/sdp/sdp_utils.cc +++ b/system/stack/sdp/sdp_utils.cc @@ -39,6 +39,7 @@ #include "device/include/interop.h" #include "internal_include/bt_target.h" #include "internal_include/bt_trace.h" +#include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "osi/include/properties.h" #include "stack/include/avrc_api.h" @@ -50,7 +51,6 @@ #include "stack/include/btm_sec_api_types.h" #include "stack/include/l2cap_interface.h" #include "stack/include/sdpdefs.h" -#include "stack/include/stack_metrics_logging.h" #include "stack/sdp/internal/sdp_api.h" #include "stack/sdp/sdpint.h" #include "storage/config_keys.h" @@ -184,15 +184,15 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) } // Log the existence of a profile role // This can be different from Bluetooth Profile Descriptor List - log_sdp_attribute(bda, service_uuid, 0, 0, nullptr); + bluetooth::shim::LogMetricSdpAttribute(bda, service_uuid, 0, 0, nullptr); // Log profile version from Bluetooth Profile Descriptor List auto uuid_version_array = sdpu_find_profile_version(p_rec); for (const auto& uuid_version_pair : uuid_version_array) { uint16_t profile_uuid = uuid_version_pair.first; uint16_t version = uuid_version_pair.second; auto version_array = to_little_endian_array(version); - log_sdp_attribute(bda, profile_uuid, ATTR_ID_BT_PROFILE_DESC_LIST, version_array.size(), - version_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, profile_uuid, ATTR_ID_BT_PROFILE_DESC_LIST, + version_array.size(), version_array.data()); } // Log protocol version from Protocol Descriptor List uint16_t protocol_uuid = 0; @@ -217,8 +217,8 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) if (protocol_elements.num_params >= 1) { uint16_t version = protocol_elements.params[0]; auto version_array = to_little_endian_array(version); - log_sdp_attribute(bda, protocol_uuid, ATTR_ID_PROTOCOL_DESC_LIST, version_array.size(), - version_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, protocol_uuid, ATTR_ID_PROTOCOL_DESC_LIST, + version_array.size(), version_array.data()); } } } @@ -238,8 +238,8 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) } uint16_t supported_features = p_attr->attr_value.v.u16; auto version_array = to_little_endian_array(supported_features); - log_sdp_attribute(bda, service_uuid, ATTR_ID_SUPPORTED_FEATURES, version_array.size(), - version_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, service_uuid, ATTR_ID_SUPPORTED_FEATURES, + version_array.size(), version_array.data()); break; } case UUID_SERVCLASS_MESSAGE_NOTIFICATION: @@ -251,8 +251,8 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) } uint32_t map_supported_features = p_attr->attr_value.v.u32; auto features_array = to_little_endian_array(map_supported_features); - log_sdp_attribute(bda, service_uuid, ATTR_ID_MAP_SUPPORTED_FEATURES, features_array.size(), - features_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, service_uuid, ATTR_ID_MAP_SUPPORTED_FEATURES, + features_array.size(), features_array.data()); break; } case UUID_SERVCLASS_PBAP_PCE: @@ -264,8 +264,8 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) } uint32_t pbap_supported_features = p_attr->attr_value.v.u32; auto features_array = to_little_endian_array(pbap_supported_features); - log_sdp_attribute(bda, service_uuid, ATTR_ID_PBAP_SUPPORTED_FEATURES, features_array.size(), - features_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, service_uuid, ATTR_ID_PBAP_SUPPORTED_FEATURES, + features_array.size(), features_array.data()); break; } } @@ -278,15 +278,17 @@ void sdpu_log_attribute_metrics(const RawAddress& bda, tSDP_DISCOVERY_DB* p_db) tSDP_DI_GET_RECORD di_record = {}; if (SDP_GetDiRecord(1, &di_record, p_db) == tSDP_STATUS::SDP_SUCCESS) { auto version_array = to_little_endian_array(di_record.spec_id); - log_sdp_attribute(bda, UUID_SERVCLASS_PNP_INFORMATION, ATTR_ID_SPECIFICATION_ID, - version_array.size(), version_array.data()); + bluetooth::shim::LogMetricSdpAttribute(bda, UUID_SERVCLASS_PNP_INFORMATION, + ATTR_ID_SPECIFICATION_ID, version_array.size(), + version_array.data()); std::stringstream ss; // [N - native]::SDP::[DIP - Device ID Profile] ss << "N:SDP::DIP::" << loghex(di_record.rec.vendor_id_source); - log_manufacturer_info(bda, android::bluetooth::AddressTypeEnum::ADDRESS_TYPE_PUBLIC, - android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL, ss.str(), - loghex(di_record.rec.vendor), loghex(di_record.rec.product), - loghex(di_record.rec.version), ""); + bluetooth::shim::LogMetricManufacturerInfo( + bda, android::bluetooth::AddressTypeEnum::ADDRESS_TYPE_PUBLIC, + android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL, ss.str(), + loghex(di_record.rec.vendor), loghex(di_record.rec.product), + loghex(di_record.rec.version), ""); std::string bda_string = bda.ToString(); // write manufacturer, model, HW version to config diff --git a/system/stack/smp/smp_utils.cc b/system/stack/smp/smp_utils.cc index e5aefe3c6a..9be3de7db1 100644 --- a/system/stack/smp/smp_utils.cc +++ b/system/stack/smp/smp_utils.cc @@ -35,6 +35,7 @@ #include "internal_include/stack_config.h" #include "main/shim/entry.h" #include "main/shim/helpers.h" +#include "main/shim/metrics_api.h" #include "metrics/bluetooth_event.h" #include "osi/include/allocator.h" #include "p_256_ecc_pp.h" @@ -51,7 +52,6 @@ #include "stack/include/l2cap_interface.h" #include "stack/include/l2cdefs.h" #include "stack/include/smp_status.h" -#include "stack/include/stack_metrics_logging.h" #include "types/raw_address.h" #define SMP_PAIRING_REQ_SIZE 7 @@ -320,7 +320,7 @@ void smp_log_metrics(const RawAddress& bd_addr, bool is_outgoing, const uint8_t* uint8_t failure_reason = 0; if (raw_cmd == SMP_OPCODE_PAIRING_FAILED && buf_len >= 1) { STREAM_TO_UINT8(failure_reason, p_buf); - log_le_pairing_fail(bd_addr, failure_reason, is_outgoing); + bluetooth::shim::LogMetricLePairingFail(bd_addr, failure_reason, is_outgoing); } if (smp_cb.is_pair_cancel) { failure_reason = SMP_USER_CANCELLED; // Tracking pairing cancellations @@ -330,7 +330,8 @@ void smp_log_metrics(const RawAddress& bd_addr, bool is_outgoing, const uint8_t* android::bluetooth::DirectionEnum direction = is_outgoing ? android::bluetooth::DirectionEnum::DIRECTION_OUTGOING : android::bluetooth::DirectionEnum::DIRECTION_INCOMING; - log_smp_pairing_event(bd_addr, metric_cmd, direction, static_cast<uint16_t>(failure_reason)); + bluetooth::shim::LogMetricSmpPairingEvent(bd_addr, metric_cmd, direction, + static_cast<uint16_t>(failure_reason)); } /******************************************************************************* @@ -1011,7 +1012,8 @@ void smp_proc_pairing_cmpl(tSMP_CB* p_cb) { if (metric_status > SMP_MAX_FAIL_RSN_PER_SPEC) { metric_status |= SMP_METRIC_STATUS_INTERNAL_FLAG; } - log_smp_pairing_event(p_cb->pairing_bda, metric_cmd, direction, metric_status); + bluetooth::shim::LogMetricSmpPairingEvent(p_cb->pairing_bda, metric_cmd, direction, + metric_status); } if (p_cb->status == SMP_SUCCESS && p_cb->smp_over_br) { diff --git a/system/test/Android.bp b/system/test/Android.bp index c35931ea17..106dedb7bd 100644 --- a/system/test/Android.bp +++ b/system/test/Android.bp @@ -450,13 +450,6 @@ filegroup { } filegroup { - name: "TestMockStackMetrics", - srcs: [ - "mock/mock_stack_metrics*.cc", - ], -} - -filegroup { name: "TestMockStackGap", srcs: [ "mock/mock_stack_gap*.cc", diff --git a/system/test/mock/mock_stack_metrics_logging.cc b/system/test/mock/mock_stack_metrics_logging.cc deleted file mode 100644 index ff2cee4472..0000000000 --- a/system/test/mock/mock_stack_metrics_logging.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Generated mock file from original source file - * Functions generated:5 - * - * mockcify.pl ver 0.2 - */ -// Mock include file to share data between tests and mock -#include "test/mock/mock_stack_metrics_logging.h" - -#include <string> - -// Original included files, if any -#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> - -#include "stack/include/stack_metrics_logging.h" -#include "test/common/mock_functions.h" -#include "types/raw_address.h" - -// Mocked compile conditionals, if any -// Mocked internal structures, if any - -namespace test { -namespace mock { -namespace stack_metrics_logging { - -// Function state capture and return values, if needed -struct log_classic_pairing_event log_classic_pairing_event; -struct log_link_layer_connection_event log_link_layer_connection_event; -struct log_smp_pairing_event log_smp_pairing_event; -struct log_le_pairing_fail log_le_pairing_fail; -struct log_sdp_attribute log_sdp_attribute; -struct log_manufacturer_info log_manufacturer_info; -struct log_counter_metrics log_counter_metrics; -struct log_hfp_audio_packet_loss_stats log_hfp_audio_packet_loss_stats; -struct log_mmc_transcode_rtt_stats log_mmc_transcode_rtt_stats; -struct log_le_connection_status log_le_connection_status; -struct log_le_device_in_accept_list log_le_device_in_accept_list; -struct log_le_connection_lifecycle log_le_connection_lifecycle; -struct log_le_connection_completion log_le_connection_completion; - -} // namespace stack_metrics_logging -} // namespace mock -} // namespace test - -// Mocked functions, if any -void log_classic_pairing_event(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_classic_pairing_event( - address, handle, hci_cmd, hci_event, cmd_status, reason_code, event_value); -} -void log_link_layer_connection_event(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, - 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) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_link_layer_connection_event( - address, connection_handle, direction, link_type, hci_cmd, hci_event, hci_ble_event, - cmd_status, reason_code); -} -void log_smp_pairing_event(const RawAddress& address, uint16_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint16_t smp_fail_reason) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_smp_pairing_event(address, smp_cmd, direction, - smp_fail_reason); -} - -void log_le_pairing_fail(const RawAddress& raw_address, uint8_t failure_reason, bool is_outgoing) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_le_pairing_fail(raw_address, failure_reason, is_outgoing); -} - -void log_sdp_attribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_sdp_attribute(address, protocol_uuid, attribute_id, - attribute_size, attribute_value); -} -void log_manufacturer_info(const RawAddress& address, - android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_manufacturer_info(address, address_type, source_type, - source_name, manufacturer, model, - hardware_version, software_version); -} - -void log_counter_metrics(android::bluetooth::CodePathCounterKeyEnum key, int64_t value) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_counter_metrics(key, value); -} - -void log_hfp_audio_packet_loss_stats(const RawAddress& address, int num_decoded_frames, - double packet_loss_ratio, uint16_t codec_type) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_hfp_audio_packet_loss_stats(address, num_decoded_frames, - packet_loss_ratio, codec_type); -} - -void log_mmc_transcode_rtt_stats(int maximum_rtt, double mean_rtt, int num_requests, - int codec_type) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_mmc_transcode_rtt_stats(maximum_rtt, mean_rtt, - num_requests, codec_type); -} - -void log_le_connection_status(bluetooth::hci::Address address, bool is_connect, - bluetooth::hci::ErrorCode reason) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_le_connection_status(address, is_connect, reason); -} - -void log_le_device_in_accept_list(bluetooth::hci::Address address, bool is_add) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_le_device_in_accept_list(address, is_add); -} - -void log_le_connection_lifecycle(bluetooth::hci::Address address, bool is_connect, bool is_direct) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_le_connection_lifecycle(address, is_connect, is_direct); -} - -void log_le_connection_completion(bluetooth::hci::Address address, bluetooth::hci::ErrorCode reason, - bool is_locally_initiated) { - inc_func_call_count(__func__); - test::mock::stack_metrics_logging::log_le_connection_completion(address, reason, - is_locally_initiated); -} -// END mockcify generation diff --git a/system/test/mock/mock_stack_metrics_logging.h b/system/test/mock/mock_stack_metrics_logging.h deleted file mode 100644 index 40212e60ea..0000000000 --- a/system/test/mock/mock_stack_metrics_logging.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Generated mock file from original source file - * Functions generated:5 - * - * mockcify.pl ver 0.2 - */ - -#include <string> - -// Original included files, if any -#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> -#include <frameworks/proto_logging/stats/enums/bluetooth/hci/enums.pb.h> - -#include "hci/address.h" -#include "hci/hci_packets.h" -#include "types/raw_address.h" - -// Mocked compile conditionals, if any - -namespace test { -namespace mock { -namespace stack_metrics_logging { - -// Shared state between mocked functions and tests -// Name: log_classic_pairing_event -// Params: const RawAddress& address, uint16_t handle, uint32_t hci_cmd, -// uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, int64_t -// event_value Returns: void -struct log_classic_pairing_event { - std::function<void(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, - uint16_t hci_event, uint16_t cmd_status, uint16_t reason_code, - int64_t event_value)> - body{[](const RawAddress& /* address */, uint16_t /* handle */, uint32_t /* hci_cmd */, - uint16_t /* hci_event */, uint16_t /* cmd_status */, uint16_t /* reason_code */, - int64_t /* event_value */) {}}; - void operator()(const RawAddress& address, uint16_t handle, uint32_t hci_cmd, uint16_t hci_event, - uint16_t cmd_status, uint16_t reason_code, int64_t event_value) { - body(address, handle, hci_cmd, hci_event, cmd_status, reason_code, event_value); - } -}; -extern struct log_classic_pairing_event log_classic_pairing_event; -// Name: log_link_layer_connection_event -// Params: const RawAddress* address, uint32_t connection_handle, -// android::bluetooth::DirectionEnum direction, 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 Returns: void -struct log_link_layer_connection_event { - std::function<void(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, 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)> - body{[](const RawAddress* /* address */, uint32_t /* connection_handle */, - android::bluetooth::DirectionEnum /* direction */, 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 */) {}}; - void operator()(const RawAddress* address, uint32_t connection_handle, - android::bluetooth::DirectionEnum direction, 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) { - body(address, connection_handle, direction, link_type, hci_cmd, hci_event, hci_ble_event, - cmd_status, reason_code); - } -}; -extern struct log_link_layer_connection_event log_link_layer_connection_event; -// Name: log_smp_pairing_event -// Params: const RawAddress& address, uint16_t smp_cmd, -// android::bluetooth::DirectionEnum direction, uint8_t smp_fail_reason Returns: -// void -struct log_smp_pairing_event { - std::function<void(const RawAddress& address, uint16_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint16_t smp_fail_reason)> - body{[](const RawAddress& /* address */, uint16_t /* smp_cmd */, - android::bluetooth::DirectionEnum /* direction */, - uint16_t /* smp_fail_reason */) {}}; - void operator()(const RawAddress& address, uint16_t smp_cmd, - android::bluetooth::DirectionEnum direction, uint16_t smp_fail_reason) { - body(address, smp_cmd, direction, smp_fail_reason); - } -}; -extern struct log_smp_pairing_event log_smp_pairing_event; - -// Name: log_le_pairing_fail -// Params: const RawAddress& raw_address, uint8_t failure_reason, bool -// is_outgoing Returns: -// void -// Name: log_sdp_attribute -// Params: const RawAddress& address, uint16_t protocol_uuid, uint16_t -// attribute_id, size_t attribute_size, const char* attribute_value Returns: -// void -struct log_le_pairing_fail { - std::function<void(const RawAddress& raw_address, uint8_t failure_reason, bool is_outgoing)> body{ - [](const RawAddress& /* address */, uint8_t /* failure reason */, - bool /* is_outgoing */) {}}; - void operator()(const RawAddress& raw_address, uint8_t failure_reason, bool is_outgoing) { - body(raw_address, failure_reason, is_outgoing); - } -}; -extern struct log_le_pairing_fail log_le_pairing_fail; - -struct log_sdp_attribute { - std::function<void(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value)> - body{[](const RawAddress& /* address */, uint16_t /* protocol_uuid */, - uint16_t /* attribute_id */, size_t /* attribute_size */, - const char* /* attribute_value */) {}}; - void operator()(const RawAddress& address, uint16_t protocol_uuid, uint16_t attribute_id, - size_t attribute_size, const char* attribute_value) { - body(address, protocol_uuid, attribute_id, attribute_size, attribute_value); - } -}; -extern struct log_sdp_attribute log_sdp_attribute; -// Name: log_manufacturer_info -// Params: const RawAddress& address, android::bluetooth::DeviceInfoSrcEnum -// source_type, const std::string& source_name, const std::string& manufacturer, -// const std::string& model, const std::string& hardware_version, const -// std::string& software_version Returns: void -struct log_manufacturer_info { - std::function<void(const RawAddress& address, android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version)> - body2{[](const RawAddress& /* address */, - android::bluetooth::AddressTypeEnum /* address_type */, - android::bluetooth::DeviceInfoSrcEnum /* source_type */, - const std::string& /* source_name */, const std::string& /* manufacturer */, - const std::string& /* model */, const std::string& /* hardware_version */, - const std::string& /* software_version */) {}}; - void operator()(const RawAddress& address, android::bluetooth::AddressTypeEnum address_type, - android::bluetooth::DeviceInfoSrcEnum source_type, const std::string& source_name, - const std::string& manufacturer, const std::string& model, - const std::string& hardware_version, const std::string& software_version) { - body2(address, address_type, source_type, source_name, manufacturer, model, hardware_version, - software_version); - } - std::function<void(const RawAddress& address, android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version)> - body{[](const RawAddress& /* address */, - android::bluetooth::DeviceInfoSrcEnum /* source_type */, - const std::string& /* source_name */, const std::string& /* manufacturer */, - const std::string& /* model */, const std::string& /* hardware_version */, - const std::string& /* software_version */) {}}; - void operator()(const RawAddress& address, android::bluetooth::DeviceInfoSrcEnum source_type, - const std::string& source_name, const std::string& manufacturer, - const std::string& model, const std::string& hardware_version, - const std::string& software_version) { - body(address, source_type, source_name, manufacturer, model, hardware_version, - software_version); - } -}; -extern struct log_manufacturer_info log_manufacturer_info; - -// Name: log_counter_metrics -struct log_counter_metrics { - std::function<void(android::bluetooth::CodePathCounterKeyEnum key, int64_t value)> body{ - [](android::bluetooth::CodePathCounterKeyEnum /* key */, int64_t /* value */) {}}; - void operator()(android::bluetooth::CodePathCounterKeyEnum key, int64_t value) { - body(key, value); - } -}; -extern struct log_counter_metrics log_counter_metrics; - -// Name: log_hfp_audio_packet_loss_stats -struct log_hfp_audio_packet_loss_stats { - std::function<void(const RawAddress& address, int num_decoded_frames, double packet_loss_ratio, - uint16_t codec_type)> - body{[](const RawAddress& /* address */, int /* num_decoded_frames */, - double /* packet_loss_ratio */, uint16_t /* codec_type */) {}}; - void operator()(const RawAddress& address, int num_decoded_frames, double packet_loss_ratio, - uint16_t codec_type) { - body(address, num_decoded_frames, packet_loss_ratio, codec_type); - } -}; -extern struct log_hfp_audio_packet_loss_stats log_hfp_audio_packet_loss_stats; - -// Name: log_mmc_transcode_rtt_stats -struct log_mmc_transcode_rtt_stats { - std::function<void(int maximum_rtt, double mean_rtt, int num_requests, int codec_type)> body{ - [](int /* maximum_rtt */, double /* mean_rtt */, int /* num_requests */, - int /* codec_type */) {}}; - void operator()(int maximum_rtt, double mean_rtt, int num_requests, int codec_type) { - body(maximum_rtt, mean_rtt, num_requests, codec_type); - } -}; -extern struct log_mmc_transcode_rtt_stats log_mmc_transcode_rtt_stats; - -// Name: log_le_connection_status -struct log_le_connection_status { - std::function<void(bluetooth::hci::Address address, bool is_connect, - bluetooth::hci::ErrorCode reason)> - body{[](bluetooth::hci::Address /* address */, bool /* is_connect */, - bluetooth::hci::ErrorCode /* reason */) {}}; - void operator()(bluetooth::hci::Address address, bool is_connect, - bluetooth::hci::ErrorCode reason) { - body(address, is_connect, reason); - } -}; -extern struct log_le_connection_status log_le_connection_status; - -// Name: log_le_device_in_accept_list -struct log_le_device_in_accept_list { - std::function<void(bluetooth::hci::Address address, bool is_add)> body{ - [](bluetooth::hci::Address /* address */, bool /* is_add */) {}}; - void operator()(bluetooth::hci::Address address, bool is_add) { body(address, is_add); } -}; -extern struct log_le_device_in_accept_list log_le_device_in_accept_list; - -// Name: log_le_connection_lifecycle -struct log_le_connection_lifecycle { - std::function<void(bluetooth::hci::Address address, bool is_connect, bool is_direct)> body{ - [](bluetooth::hci::Address /* address */, bool /* is_connect */, bool /* is_direct */) { - }}; - void operator()(bluetooth::hci::Address address, bool is_connect, bool is_direct) { - body(address, is_connect, is_direct); - } -}; -extern struct log_le_device_in_accept_list log_le_device_in_accept_list; - -// Name: log_le_connection_completion -struct log_le_connection_completion { - std::function<void(bluetooth::hci::Address address, bluetooth::hci::ErrorCode reason, - bool is_locally_initiated)> - body{[](bluetooth::hci::Address /* address */, bluetooth::hci::ErrorCode /* reason */, - bool /* is locally initiated */) {}}; - void operator()(bluetooth::hci::Address address, bluetooth::hci::ErrorCode reason, - bool is_locally_initiated) { - body(address, reason, is_locally_initiated); - } -}; -extern struct log_le_connection_completion log_le_connection_completion; - -} // namespace stack_metrics_logging -} // namespace mock -} // namespace test - -// END mockcify generation |