Loading system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,7 @@ cc_library_static { static_libs: [ "avrcp-target-service", "lib-bt-packets", "libbt-platform-protos-lite", ], shared_libs: [ "android.hardware.bluetooth.audio@2.0", Loading system/bta/sdp/bta_sdp_act.cc +7 −0 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ * This file contains action functions for SDP search. ******************************************************************************/ #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <hardware/bt_sdp.h> #include <cstdint> #include "bta/include/bta_sdp_api.h" #include "bta/sdp/bta_sdp_int.h" #include "btif/include/btif_sock_sdp.h" #include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "stack/include/sdp_api.h" #include "types/bluetooth/uuid.h" Loading Loading @@ -435,6 +438,8 @@ static void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data) { tBTA_SDP bta_sdp; bta_sdp.sdp_search_comp = evt_data; bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, (void*)&uuid); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::SDP_SUCCESS, 1); osi_free(const_cast<void*>( user_data)); // We no longer need the user data to track the search } Loading Loading @@ -513,6 +518,8 @@ void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) { tBTA_SDP bta_sdp; bta_sdp.sdp_search_comp = result; bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, NULL); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::SDP_FAILURE, 1); } } /* Loading system/bta/test/bta_dip_test.cc +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <gtest/gtest.h> #include "bta/sdp/bta_sdp_act.cc" #include "main/shim/metrics_api.h" #include "stack/sdp/sdp_api.cc" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" Loading Loading @@ -49,6 +50,10 @@ static void sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, return; } bool bluetooth::shim::CountCounterMetrics(int32_t key, int64_t count) { return true; } class BtaDipTest : public ::testing::Test { protected: void SetUp() override { Loading system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,7 @@ cc_library_static { static_libs: [ "libbt-hci", "libFraunhoferAAC", "libbt-platform-protos-lite", ], shared_libs: [ "libcutils", Loading system/stack/l2cap/l2c_csm.cc +53 −2 Original line number Diff line number Diff line Loading @@ -23,20 +23,22 @@ ******************************************************************************/ #define LOG_TAG "l2c_csm" #include <base/logging.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <string> #include "bt_target.h" #include "common/time_util.h" #include "l2c_int.h" #include "l2cdefs.h" #include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "osi/include/log.h" #include "stack/btm/btm_sec.h" #include "stack/include/acl_api.h" #include "stack/include/bt_hdr.h" #include <base/logging.h> /******************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /******************************************************************************/ Loading Loading @@ -218,6 +220,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { } else { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONNECT_CONFIRM_NEG, 1); } break; Loading Loading @@ -252,6 +258,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_NO_COMPATIBLE_CHANNEL_AT_CSM_CLOSED, 1); } else { l2cu_send_peer_connect_req(p_ccb); alarm_set_on_mloop(p_ccb->l2c_ccb_timer, Loading @@ -264,6 +274,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { case L2CEVT_SEC_COMP_NEG: /* something is really bad with security */ l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_SECURITY_NEG_AT_CSM_CLOSED, 1); break; case L2CEVT_L2CAP_CREDIT_BASED_CONNECT_REQ: /* Peer connect request */ Loading Loading @@ -316,6 +330,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { case L2CEVT_TIMEOUT: l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_TIMEOUT_AT_CSM_CLOSED, 1); break; case L2CEVT_L2CAP_DATA: /* Peer data packet rcvd */ Loading Loading @@ -392,6 +410,10 @@ static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_NO_COMPATIBLE_CHANNEL_AT_W4_SEC, 1); } else { alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, Loading @@ -412,6 +434,10 @@ static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_SECURITY_NEG_AT_W4_SEC, 1); break; case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */ Loading Loading @@ -660,6 +686,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, "cid %d, result 0x%04x", local_cid, p_ci->l2cap_result); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, p_ci->l2cap_result); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CREDIT_BASED_CONNECT_RSP_NEG, 1); l2cu_release_ccb(p_ccb); break; Loading @@ -670,6 +700,8 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, << ", reason=" << loghex(p_ci->l2cap_result); l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::L2CAP_CONNECT_RSP_NEG, 1); break; case L2CEVT_TIMEOUT: Loading @@ -682,6 +714,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, LOG(WARNING) << __func__ << ": lcid= " << loghex(cid); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CONN_TIMEOUT); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_TIMEOUT_AT_CONNECT_RSP, 1); l2cu_release_ccb(temp_p_ccb); } p_lcb->pending_ecoc_conn_cnt = 0; Loading @@ -692,6 +728,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, LOG(WARNING) << __func__ << ": lcid= " << loghex(p_ccb->local_cid); l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONN_OTHER_ERROR_AT_CONNECT_RSP, 1); } break; Loading Loading @@ -723,6 +763,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, if (!l2c_fcr_chk_chan_modes(p_ccb)) { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_INFO_NO_COMPATIBLE_CHANNEL_AT_RSP, 1); } else { /* We have feature info, so now send peer connect request */ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, Loading Loading @@ -944,6 +988,10 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CFG_FAILED_NO_REASON); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONFIG_REQ_FAILURE, 1); } } } Loading Loading @@ -1038,6 +1086,9 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CFG_FAILED_NO_REASON); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::L2CAP_CONFIG_RSP_NEG, 1); } } break; Loading Loading
system/bta/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,7 @@ cc_library_static { static_libs: [ "avrcp-target-service", "lib-bt-packets", "libbt-platform-protos-lite", ], shared_libs: [ "android.hardware.bluetooth.audio@2.0", Loading
system/bta/sdp/bta_sdp_act.cc +7 −0 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ * This file contains action functions for SDP search. ******************************************************************************/ #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <hardware/bt_sdp.h> #include <cstdint> #include "bta/include/bta_sdp_api.h" #include "bta/sdp/bta_sdp_int.h" #include "btif/include/btif_sock_sdp.h" #include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "stack/include/sdp_api.h" #include "types/bluetooth/uuid.h" Loading Loading @@ -435,6 +438,8 @@ static void bta_sdp_search_cback(tSDP_RESULT result, const void* user_data) { tBTA_SDP bta_sdp; bta_sdp.sdp_search_comp = evt_data; bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, (void*)&uuid); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::SDP_SUCCESS, 1); osi_free(const_cast<void*>( user_data)); // We no longer need the user data to track the search } Loading Loading @@ -513,6 +518,8 @@ void bta_sdp_search(const RawAddress bd_addr, const bluetooth::Uuid uuid) { tBTA_SDP bta_sdp; bta_sdp.sdp_search_comp = result; bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, NULL); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::SDP_FAILURE, 1); } } /* Loading
system/bta/test/bta_dip_test.cc +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <gtest/gtest.h> #include "bta/sdp/bta_sdp_act.cc" #include "main/shim/metrics_api.h" #include "stack/sdp/sdp_api.cc" #include "types/bluetooth/uuid.h" #include "types/raw_address.h" Loading Loading @@ -49,6 +50,10 @@ static void sdp_dm_cback(tBTA_SDP_EVT event, tBTA_SDP* p_data, return; } bool bluetooth::shim::CountCounterMetrics(int32_t key, int64_t count) { return true; } class BtaDipTest : public ::testing::Test { protected: void SetUp() override { Loading
system/stack/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -204,6 +204,7 @@ cc_library_static { static_libs: [ "libbt-hci", "libFraunhoferAAC", "libbt-platform-protos-lite", ], shared_libs: [ "libcutils", Loading
system/stack/l2cap/l2c_csm.cc +53 −2 Original line number Diff line number Diff line Loading @@ -23,20 +23,22 @@ ******************************************************************************/ #define LOG_TAG "l2c_csm" #include <base/logging.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <string> #include "bt_target.h" #include "common/time_util.h" #include "l2c_int.h" #include "l2cdefs.h" #include "main/shim/metrics_api.h" #include "osi/include/allocator.h" #include "osi/include/log.h" #include "stack/btm/btm_sec.h" #include "stack/include/acl_api.h" #include "stack/include/bt_hdr.h" #include <base/logging.h> /******************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /******************************************************************************/ Loading Loading @@ -218,6 +220,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { } else { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONNECT_CONFIRM_NEG, 1); } break; Loading Loading @@ -252,6 +258,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_NO_COMPATIBLE_CHANNEL_AT_CSM_CLOSED, 1); } else { l2cu_send_peer_connect_req(p_ccb); alarm_set_on_mloop(p_ccb->l2c_ccb_timer, Loading @@ -264,6 +274,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { case L2CEVT_SEC_COMP_NEG: /* something is really bad with security */ l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_SECURITY_NEG_AT_CSM_CLOSED, 1); break; case L2CEVT_L2CAP_CREDIT_BASED_CONNECT_REQ: /* Peer connect request */ Loading Loading @@ -316,6 +330,10 @@ static void l2c_csm_closed(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { case L2CEVT_TIMEOUT: l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_TIMEOUT_AT_CSM_CLOSED, 1); break; case L2CEVT_L2CAP_DATA: /* Peer data packet rcvd */ Loading Loading @@ -392,6 +410,10 @@ static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_NO_COMPATIBLE_CHANNEL_AT_W4_SEC, 1); } else { alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, Loading @@ -412,6 +434,10 @@ static void l2c_csm_orig_w4_sec_comp(tL2C_CCB* p_ccb, tL2CEVT event, l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_SECURITY_NEG_AT_W4_SEC, 1); break; case L2CEVT_L2CA_DATA_WRITE: /* Upper layer data to send */ Loading Loading @@ -660,6 +686,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, "cid %d, result 0x%04x", local_cid, p_ci->l2cap_result); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, p_ci->l2cap_result); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CREDIT_BASED_CONNECT_RSP_NEG, 1); l2cu_release_ccb(p_ccb); break; Loading @@ -670,6 +700,8 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, << ", reason=" << loghex(p_ci->l2cap_result); l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::L2CAP_CONNECT_RSP_NEG, 1); break; case L2CEVT_TIMEOUT: Loading @@ -682,6 +714,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, LOG(WARNING) << __func__ << ": lcid= " << loghex(cid); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CONN_TIMEOUT); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_TIMEOUT_AT_CONNECT_RSP, 1); l2cu_release_ccb(temp_p_ccb); } p_lcb->pending_ecoc_conn_cnt = 0; Loading @@ -692,6 +728,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, LOG(WARNING) << __func__ << ": lcid= " << loghex(p_ccb->local_cid); l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONN_OTHER_ERROR_AT_CONNECT_RSP, 1); } break; Loading Loading @@ -723,6 +763,10 @@ static void l2c_csm_w4_l2cap_connect_rsp(tL2C_CCB* p_ccb, tL2CEVT event, if (!l2c_fcr_chk_chan_modes(p_ccb)) { l2cu_release_ccb(p_ccb); (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(local_cid, L2CAP_CONN_OTHER_ERROR); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_INFO_NO_COMPATIBLE_CHANNEL_AT_RSP, 1); } else { /* We have feature info, so now send peer connect request */ alarm_set_on_mloop(p_ccb->l2c_ccb_timer, L2CAP_CHNL_CONNECT_TIMEOUT_MS, Loading Loading @@ -944,6 +988,10 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CFG_FAILED_NO_REASON); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum:: L2CAP_CONFIG_REQ_FAILURE, 1); } } } Loading Loading @@ -1038,6 +1086,9 @@ static void l2c_csm_config(tL2C_CCB* p_ccb, tL2CEVT event, void* p_data) { if (p_ccb->connection_initiator == L2CAP_INITIATOR_LOCAL) { (*p_ccb->p_rcb->api.pL2CA_Error_Cb)(p_ccb->local_cid, L2CAP_CFG_FAILED_NO_REASON); bluetooth::shim::CountCounterMetrics( android::bluetooth::CodePathCounterKeyEnum::L2CAP_CONFIG_RSP_NEG, 1); } } break; Loading