From: Subramanian Srinivasan Date: Mon, 16 May 2016 18:14:03 +0000 (-0700) Subject: Process Gatt read multiple response properly X-Git-Tag: android-x86-7.1-r1~64 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=94b4a1ad31;p=android-x86%2Fsystem-bt.git Process Gatt read multiple response properly The Gatt server multi response queue is made NULL after each Gatt server response is sent by BT stack in response to the remote Gatt client's request. But the multi response queue is not initialized again to process subsequent read multiple Gatt server responses. Hence, the BT stack does not send Gatt server responses for the subsequent read multiple requests from remote device which inturn leads to disconnection. This change would process read multiple responses by initializing the queue when it is null. Some of Bluetooth certification test cases involve testing Gatt server's capability to process and send read multiple response. Test case: TC_GAR_SR_BV_05_C This change also cleans up unnecessary initialization and freeing of multi rsp queue. This change makes sure that the stack initializes multi rsp queue only when it is necessary(ie only when the Gatt multiple read response is being processed). Bug: 29011255 Change-Id: Ia3e2e1569ee16cac9c518f95501945257b9fb7fd (cherry picked from commit 3737592a7846766083041e81d72a2fab0b27fb38) --- diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.c index bda5b41e9..8bbd6503b 100644 --- a/stack/gatt/gatt_main.c +++ b/stack/gatt/gatt_main.c @@ -403,7 +403,6 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans GATT_TRACE_ERROR("gatt_connect failed"); fixed_queue_free(p_tcb->pending_enc_clcb, NULL); fixed_queue_free(p_tcb->pending_ind_q, NULL); - fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL); memset(p_tcb, 0, sizeof(tGATT_TCB)); } else diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c index f5c5f0f4b..11ef79c83 100644 --- a/stack/gatt/gatt_sr.c +++ b/stack/gatt/gatt_sr.c @@ -122,13 +122,16 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status, tGATTS_RSP *p_msg, UINT16 mtu) { UINT16 ii, total_len, len; - BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(tGATTS_RSP)); UINT8 *p; BOOLEAN is_overflow = FALSE; - GATT_TRACE_DEBUG ("process_read_multi_rsp status=%d mtu=%d", status, mtu); + GATT_TRACE_DEBUG ("%s status=%d mtu=%d", __func__, status, mtu); + + if (p_cmd->multi_rsp_q == NULL) + p_cmd->multi_rsp_q = fixed_queue_new(SIZE_MAX); /* Enqueue the response */ + BT_HDR *p_buf = (BT_HDR *)osi_malloc(sizeof(tGATTS_RSP)); memcpy((void *)p_buf, (const void *)p_msg, sizeof(tGATTS_RSP)); fixed_queue_enqueue(p_cmd->multi_rsp_q, p_buf); diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.c index f56925d74..c2db77036 100644 --- a/stack/gatt/gatt_utils.c +++ b/stack/gatt/gatt_utils.c @@ -972,7 +972,6 @@ tGATT_TCB * gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport) p_tcb->pending_ind_q = fixed_queue_new(SIZE_MAX); p_tcb->conf_timer = alarm_new("gatt.conf_timer"); p_tcb->ind_ack_timer = alarm_new("gatt.ind_ack_timer"); - p_tcb->sr_cmd.multi_rsp_q = fixed_queue_new(SIZE_MAX); p_tcb->in_use = TRUE; p_tcb->tcb_idx = i; p_tcb->transport = transport;