system/bt
Revision | 1297a28b2b47f625413e7f416c7629967c6944e1 (tree) |
---|---|
Zeit | 2017-05-28 16:22:55 |
Autor | android-build-team Robot <android-build-team-robot@goog...> |
Commiter | android-build-team Robot |
release-request-fca2b5ac-03eb-4055-a549-b4fc2b292b64-for-git_oc-release-4049993 snap-temp-L04900000068539456
Change-Id: I7af38c959146a9406c712a170ffa6a9c380c3299
@@ -4639,9 +4639,15 @@ void btm_dm_start_gatt_discovery(BD_ADDR bd_addr) { | ||
4639 | 4639 | memset(bta_dm_search_cb.pending_close_bda, 0, BD_ADDR_LEN); |
4640 | 4640 | alarm_cancel(bta_dm_search_cb.gatt_close_timer); |
4641 | 4641 | btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id); |
4642 | - } else | |
4643 | - BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, | |
4644 | - BTA_GATT_TRANSPORT_LE); | |
4642 | + } else { | |
4643 | + if (BTM_IsAclConnectionUp(bd_addr, BT_TRANSPORT_LE)) { | |
4644 | + BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, | |
4645 | + BTA_GATT_TRANSPORT_LE, true); | |
4646 | + } else { | |
4647 | + BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, true, | |
4648 | + BTA_GATT_TRANSPORT_LE, false); | |
4649 | + } | |
4650 | + } | |
4645 | 4651 | } |
4646 | 4652 | |
4647 | 4653 | /******************************************************************************* |
@@ -432,7 +432,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB* p_clcb, tBTA_GATTC_DATA* p_data) { | ||
432 | 432 | |
433 | 433 | /* open/hold a connection */ |
434 | 434 | if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, true, |
435 | - p_data->api_conn.transport, false, | |
435 | + p_data->api_conn.transport, p_data->api_conn.opportunistic, | |
436 | 436 | p_data->api_conn.initiating_phys)) { |
437 | 437 | APPL_TRACE_ERROR("Connection open failure"); |
438 | 438 |
@@ -127,16 +127,20 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if) { | ||
127 | 127 | * transport: Transport to be used for GATT connection |
128 | 128 | * (BREDR/LE) |
129 | 129 | * initiating_phys: LE PHY to use, optional |
130 | + * opportunistic: wether the connection shall be opportunistic, | |
131 | + * and don't impact the disconnection timer | |
130 | 132 | * |
131 | 133 | ******************************************************************************/ |
132 | 134 | void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct, |
133 | - tBTA_GATT_TRANSPORT transport) { | |
135 | + tBTA_GATT_TRANSPORT transport, bool opportunistic) { | |
134 | 136 | uint8_t phy = controller_get_interface()->get_le_all_initiating_phys(); |
135 | - BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy); | |
137 | + BTA_GATTC_Open(client_if, remote_bda, is_direct, transport, phy, | |
138 | + opportunistic); | |
136 | 139 | } |
137 | 140 | |
138 | 141 | void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct, |
139 | - tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys) { | |
142 | + tBTA_GATT_TRANSPORT transport, uint8_t initiating_phys, | |
143 | + bool opportunistic) { | |
140 | 144 | tBTA_GATTC_API_OPEN* p_buf = |
141 | 145 | (tBTA_GATTC_API_OPEN*)osi_malloc(sizeof(tBTA_GATTC_API_OPEN)); |
142 | 146 |
@@ -145,6 +149,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, bool is_direct, | ||
145 | 149 | p_buf->is_direct = is_direct; |
146 | 150 | p_buf->transport = transport; |
147 | 151 | p_buf->initiating_phys = initiating_phys; |
152 | + p_buf->opportunistic = opportunistic; | |
148 | 153 | memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN); |
149 | 154 | |
150 | 155 | bta_sys_sendmsg(p_buf); |
@@ -102,6 +102,7 @@ typedef struct { | ||
102 | 102 | bool is_direct; |
103 | 103 | tBTA_TRANSPORT transport; |
104 | 104 | uint8_t initiating_phys; |
105 | + bool opportunistic; | |
105 | 106 | } tBTA_GATTC_API_OPEN; |
106 | 107 | |
107 | 108 | typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN; |
@@ -400,7 +400,8 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB* p_cb, BD_ADDR remote_bda) { | ||
400 | 400 | bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index; |
401 | 401 | p_cb->in_use = true; |
402 | 402 | |
403 | - BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE); | |
403 | + BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, true, BTA_GATT_TRANSPORT_LE, | |
404 | + false); | |
404 | 405 | } |
405 | 406 | |
406 | 407 | /******************************************************************************* |
@@ -2113,7 +2114,8 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB* p_cb, bool check_bond) { | ||
2113 | 2114 | if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/ |
2114 | 2115 | !p_cb->in_bg_conn && to_add) { |
2115 | 2116 | /* add device into BG connection to accept remote initiated connection */ |
2116 | - BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE); | |
2117 | + BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, false, BTA_GATT_TRANSPORT_LE, | |
2118 | + false); | |
2117 | 2119 | p_cb->in_bg_conn = true; |
2118 | 2120 | |
2119 | 2121 | BTA_DmBleStartAutoConn(); |
@@ -639,10 +639,11 @@ extern void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if); | ||
639 | 639 | * |
640 | 640 | ******************************************************************************/ |
641 | 641 | extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, |
642 | - bool is_direct, tBTA_GATT_TRANSPORT transport); | |
642 | + bool is_direct, tBTA_GATT_TRANSPORT transport, | |
643 | + bool opportunistic); | |
643 | 644 | extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, |
644 | 645 | bool is_direct, tBTA_GATT_TRANSPORT transport, |
645 | - uint8_t initiating_phys); | |
646 | + uint8_t initiating_phys, bool opportunistic); | |
646 | 647 | |
647 | 648 | /******************************************************************************* |
648 | 649 | * |
@@ -66,6 +66,9 @@ | ||
66 | 66 | #include "osi/include/wakelock.h" |
67 | 67 | #include "stack_manager.h" |
68 | 68 | |
69 | +/* Test interface includes */ | |
70 | +#include "mca_api.h" | |
71 | + | |
69 | 72 | /******************************************************************************* |
70 | 73 | * Static variables |
71 | 74 | ******************************************************************************/ |
@@ -107,6 +110,9 @@ extern btrc_interface_t* btif_rc_ctrl_get_interface(); | ||
107 | 110 | /*SDP search client*/ |
108 | 111 | extern btsdp_interface_t* btif_sdp_get_interface(); |
109 | 112 | |
113 | +/* List all test interface here */ | |
114 | +extern btmcap_test_interface_t* stack_mcap_get_interface(); | |
115 | + | |
110 | 116 | /******************************************************************************* |
111 | 117 | * Functions |
112 | 118 | ******************************************************************************/ |
@@ -364,6 +370,9 @@ static const void* get_profile_interface(const char* profile_id) { | ||
364 | 370 | if (is_profile(profile_id, BT_PROFILE_AV_RC_CTRL_ID)) |
365 | 371 | return btif_rc_ctrl_get_interface(); |
366 | 372 | |
373 | + if (is_profile(profile_id, BT_TEST_INTERFACE_MCAP_ID)) | |
374 | + return stack_mcap_get_interface(); | |
375 | + | |
367 | 376 | return NULL; |
368 | 377 | } |
369 | 378 |
@@ -87,15 +87,7 @@ tGAP_CLCB* gap_find_clcb_by_bd_addr(BD_ADDR bda) { | ||
87 | 87 | return NULL; |
88 | 88 | } |
89 | 89 | |
90 | -/******************************************************************************* | |
91 | - * | |
92 | - * Function gap_ble_find_clcb_by_conn_id | |
93 | - * | |
94 | - * Description The function searches all LCB with macthing connection ID | |
95 | - * | |
96 | - * Returns total number of clcb found. | |
97 | - * | |
98 | - ******************************************************************************/ | |
90 | +/* returns LCB with matching connection ID, or NULL if not found */ | |
99 | 91 | tGAP_CLCB* gap_ble_find_clcb_by_conn_id(uint16_t conn_id) { |
100 | 92 | uint8_t i_clcb; |
101 | 93 | tGAP_CLCB* p_clcb = NULL; |
@@ -107,7 +99,7 @@ tGAP_CLCB* gap_ble_find_clcb_by_conn_id(uint16_t conn_id) { | ||
107 | 99 | } |
108 | 100 | } |
109 | 101 | |
110 | - return p_clcb; | |
102 | + return NULL; | |
111 | 103 | } |
112 | 104 | |
113 | 105 | /******************************************************************************* |
@@ -132,10 +124,10 @@ tGAP_CLCB* gap_clcb_alloc(BD_ADDR bda) { | ||
132 | 124 | p_clcb->in_use = true; |
133 | 125 | memcpy(p_clcb->bda, bda, BD_ADDR_LEN); |
134 | 126 | p_clcb->pending_req_q = fixed_queue_new(SIZE_MAX); |
135 | - break; | |
127 | + return p_clcb; | |
136 | 128 | } |
137 | 129 | } |
138 | - return p_clcb; | |
130 | + return NULL; | |
139 | 131 | } |
140 | 132 | |
141 | 133 | /******************************************************************************* |
@@ -684,8 +676,7 @@ bool gap_ble_accept_cl_operation(BD_ADDR peer_bda, uint16_t uuid, | ||
684 | 676 | BT_TRANSPORT_LE)) |
685 | 677 | p_clcb->connected = true; |
686 | 678 | |
687 | - /* hold the link here */ | |
688 | - if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, true, BT_TRANSPORT_LE, false)) | |
679 | + if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, true, BT_TRANSPORT_LE, true)) | |
689 | 680 | return started; |
690 | 681 | |
691 | 682 | /* enqueue the request */ |
@@ -511,4 +511,43 @@ extern tMCA_RESULT MCA_WriteReq(tMCA_DL mdl, BT_HDR* p_pkt); | ||
511 | 511 | ******************************************************************************/ |
512 | 512 | extern uint16_t MCA_GetL2CapChannel(tMCA_DL mdl); |
513 | 513 | |
514 | +/** | |
515 | + * The following definitions are for test interface only, they mirror function | |
516 | + * definitions above. This struct allows an external application to load and | |
517 | + * call these methods without linking against the core library. | |
518 | + */ | |
519 | +typedef struct { | |
520 | + size_t size; | |
521 | + void (*init)(void); | |
522 | + tMCA_HANDLE (*register_application)(tMCA_REG* p_reg, | |
523 | + tMCA_CTRL_CBACK* p_cback); | |
524 | + void (*deregister_application)(tMCA_HANDLE handle); | |
525 | + tMCA_RESULT (*create_mdep)(tMCA_HANDLE handle, tMCA_DEP* p_dep, | |
526 | + tMCA_CS* p_cs); | |
527 | + tMCA_RESULT (*delete_mdep)(tMCA_HANDLE handle, tMCA_DEP dep); | |
528 | + tMCA_RESULT (*connect_mcl)(tMCA_HANDLE handle, BD_ADDR bd_addr, | |
529 | + uint16_t ctrl_psm, uint16_t sec_mask); | |
530 | + tMCA_RESULT (*disconnect_mcl)(tMCA_CL mcl); | |
531 | + tMCA_RESULT (*create_mdl_request)(tMCA_CL mcl, tMCA_DEP dep, | |
532 | + uint16_t data_psm, uint16_t mdl_id, | |
533 | + uint8_t peer_dep_id, uint8_t cfg, | |
534 | + const tMCA_CHNL_CFG* p_chnl_cfg); | |
535 | + tMCA_RESULT (*create_mdl_response)(tMCA_CL mcl, tMCA_DEP dep, uint16_t mdl_id, | |
536 | + uint8_t cfg, uint8_t rsp_code, | |
537 | + const tMCA_CHNL_CFG* p_chnl_cfg); | |
538 | + tMCA_RESULT (*close_mdl_request)(tMCA_DL mdl); | |
539 | + tMCA_RESULT (*reconnect_mdl_request)(tMCA_CL mcl, tMCA_DEP dep, | |
540 | + uint16_t data_psm, uint16_t mdl_id, | |
541 | + const tMCA_CHNL_CFG* p_chnl_cfg); | |
542 | + tMCA_RESULT (*reconnect_mdl_response)(tMCA_CL mcl, tMCA_DEP dep, | |
543 | + uint16_t mdl_id, uint8_t rsp_code, | |
544 | + const tMCA_CHNL_CFG* p_chnl_cfg); | |
545 | + tMCA_RESULT (*data_channel_config)(tMCA_CL mcl, | |
546 | + const tMCA_CHNL_CFG* p_chnl_cfg); | |
547 | + tMCA_RESULT (*abort_mdl)(tMCA_CL mcl); | |
548 | + tMCA_RESULT (*delete_mdl)(tMCA_CL mcl, uint16_t mdl_id); | |
549 | + tMCA_RESULT (*write_mdl)(tMCA_DL mdl, BT_HDR* p_pkt); | |
550 | + uint16_t (*get_l2cap_channel)(tMCA_DL mdl); | |
551 | +} btmcap_test_interface_t; | |
552 | + | |
514 | 553 | #endif /* MCA_API_H */ |
@@ -827,3 +827,29 @@ uint16_t MCA_GetL2CapChannel(tMCA_DL mdl) { | ||
827 | 827 | if (p_dcb) lcid = p_dcb->lcid; |
828 | 828 | return lcid; |
829 | 829 | } |
830 | + | |
831 | +static const btmcap_test_interface_t mcap_test_interface = { | |
832 | + sizeof(btmcap_test_interface_t), | |
833 | + MCA_Init, | |
834 | + MCA_Register, | |
835 | + MCA_Deregister, | |
836 | + MCA_CreateDep, | |
837 | + MCA_DeleteDep, | |
838 | + MCA_ConnectReq, | |
839 | + MCA_DisconnectReq, | |
840 | + MCA_CreateMdl, | |
841 | + MCA_CreateMdlRsp, | |
842 | + MCA_CloseReq, | |
843 | + MCA_ReconnectMdl, | |
844 | + MCA_ReconnectMdlRsp, | |
845 | + MCA_DataChnlCfg, | |
846 | + MCA_Abort, | |
847 | + MCA_Delete, | |
848 | + MCA_WriteReq, | |
849 | + MCA_GetL2CapChannel, | |
850 | +}; | |
851 | + | |
852 | +const btmcap_test_interface_t* stack_mcap_get_interface(void) { | |
853 | + BTIF_TRACE_EVENT("%s", __func__); | |
854 | + return &mcap_test_interface; | |
855 | +} |