OSDN Git Service

MCAP: Add test interface for PTS test (2/2)
authorJack He <siyuanh@google.com>
Sat, 13 May 2017 20:52:12 +0000 (13:52 -0700)
committerJack He <siyuanh@google.com>
Wed, 24 May 2017 21:48:07 +0000 (14:48 -0700)
* 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
stack/include/mca_api.h
stack/mcap/mca_api.cc

index 41a3564..9885117 100644 (file)
@@ -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;
 }
 
index 037d280..2d0128f 100644 (file)
@@ -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 */
index 2625b09..c0ca4ea 100644 (file)
@@ -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;
+}