From 04442a41e9d7efd32c1acda5cae60509535b2cc6 Mon Sep 17 00:00:00 2001 From: Jack He Date: Sat, 13 May 2017 13:52:12 -0700 Subject: [PATCH] MCAP: Add test interface for PTS test (2/2) * PTS tests requires MCAP APIs to be called at protocol level * This CL creates a test interface to enable the above functionality Bug: 37867299 Test: make, no user visible effect Change-Id: I15cc6cc613ce8f7c57564296e45077ab877c269b (cherry picked from commit 722ce12babbd3d1e814f6e704860699a0b726e4f) --- btif/src/bluetooth.cc | 9 +++++++++ stack/include/mca_api.h | 39 +++++++++++++++++++++++++++++++++++++++ stack/mcap/mca_api.cc | 26 ++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/btif/src/bluetooth.cc b/btif/src/bluetooth.cc index 41a3564d5..988511717 100644 --- a/btif/src/bluetooth.cc +++ b/btif/src/bluetooth.cc @@ -66,6 +66,9 @@ #include "osi/include/wakelock.h" #include "stack_manager.h" +/* Test interface includes */ +#include "mca_api.h" + /******************************************************************************* * Static variables ******************************************************************************/ @@ -107,6 +110,9 @@ extern btrc_interface_t* btif_rc_ctrl_get_interface(); /*SDP search client*/ extern btsdp_interface_t* btif_sdp_get_interface(); +/* List all test interface here */ +extern btmcap_test_interface_t* stack_mcap_get_interface(); + /******************************************************************************* * Functions ******************************************************************************/ @@ -364,6 +370,9 @@ static const void* get_profile_interface(const char* profile_id) { if (is_profile(profile_id, BT_PROFILE_AV_RC_CTRL_ID)) return btif_rc_ctrl_get_interface(); + if (is_profile(profile_id, BT_TEST_INTERFACE_MCAP_ID)) + return stack_mcap_get_interface(); + return NULL; } diff --git a/stack/include/mca_api.h b/stack/include/mca_api.h index 037d280fb..2d0128feb 100644 --- a/stack/include/mca_api.h +++ b/stack/include/mca_api.h @@ -511,4 +511,43 @@ extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR* p_pkt); ******************************************************************************/ extern uint16_t MCA_GetL2CapChannel(tMCA_DL mdl); +/** + * The following definitions are for test interface only, they mirror function + * definitions above. This struct allows an external application to load and + * call these methods without linking against the core library. + */ +typedef struct { + size_t size; + void (*init)(void); + tMCA_HANDLE (*register_application)(tMCA_REG* p_reg, + tMCA_CTRL_CBACK* p_cback); + void (*deregister_application)(tMCA_HANDLE handle); + tMCA_RESULT (*create_mdep)(tMCA_HANDLE handle, tMCA_DEP* p_dep, + tMCA_CS* p_cs); + tMCA_RESULT (*delete_mdep)(tMCA_HANDLE handle, tMCA_DEP dep); + tMCA_RESULT (*connect_mcl)(tMCA_HANDLE handle, BD_ADDR bd_addr, + uint16_t ctrl_psm, uint16_t sec_mask); + tMCA_RESULT (*disconnect_mcl)(tMCA_CL mcl); + tMCA_RESULT (*create_mdl_request)(tMCA_CL mcl, tMCA_DEP dep, + uint16_t data_psm, uint16_t mdl_id, + uint8_t peer_dep_id, uint8_t cfg, + const tMCA_CHNL_CFG* p_chnl_cfg); + tMCA_RESULT (*create_mdl_response)(tMCA_CL mcl, tMCA_DEP dep, uint16_t mdl_id, + uint8_t cfg, uint8_t rsp_code, + const tMCA_CHNL_CFG* p_chnl_cfg); + tMCA_RESULT (*close_mdl_request)(tMCA_DL mdl); + tMCA_RESULT (*reconnect_mdl_request)(tMCA_CL mcl, tMCA_DEP dep, + uint16_t data_psm, uint16_t mdl_id, + const tMCA_CHNL_CFG* p_chnl_cfg); + tMCA_RESULT (*reconnect_mdl_response)(tMCA_CL mcl, tMCA_DEP dep, + uint16_t mdl_id, uint8_t rsp_code, + const tMCA_CHNL_CFG* p_chnl_cfg); + tMCA_RESULT (*data_channel_config)(tMCA_CL mcl, + const tMCA_CHNL_CFG* p_chnl_cfg); + tMCA_RESULT (*abort_mdl)(tMCA_CL mcl); + tMCA_RESULT (*delete_mdl)(tMCA_CL mcl, uint16_t mdl_id); + tMCA_RESULT (*write_mdl)(tMCA_DL mdl, BT_HDR* p_pkt); + uint16_t (*get_l2cap_channel)(tMCA_DL mdl); +} btmcap_test_interface_t; + #endif /* MCA_API_H */ diff --git a/stack/mcap/mca_api.cc b/stack/mcap/mca_api.cc index 2625b0956..c0ca4ea55 100644 --- a/stack/mcap/mca_api.cc +++ b/stack/mcap/mca_api.cc @@ -827,3 +827,29 @@ uint16_t MCA_GetL2CapChannel(tMCA_DL mdl) { if (p_dcb) lcid = p_dcb->lcid; return lcid; } + +static const btmcap_test_interface_t mcap_test_interface = { + sizeof(btmcap_test_interface_t), + MCA_Init, + MCA_Register, + MCA_Deregister, + MCA_CreateDep, + MCA_DeleteDep, + MCA_ConnectReq, + MCA_DisconnectReq, + MCA_CreateMdl, + MCA_CreateMdlRsp, + MCA_CloseReq, + MCA_ReconnectMdl, + MCA_ReconnectMdlRsp, + MCA_DataChnlCfg, + MCA_Abort, + MCA_Delete, + MCA_WriteReq, + MCA_GetL2CapChannel, +}; + +const btmcap_test_interface_t* stack_mcap_get_interface(void) { + BTIF_TRACE_EVENT("%s", __func__); + return &mcap_test_interface; +} -- 2.11.0