Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b649882a authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

gatt: Fix incorrect GATT confirmation on indication

If there is many GATT users, Android sends indication to all the users
and expects confimation.
Without this fix, we could endup sending multiple Confirmation to remote
device on single Indication - which is wrong.

This patch fixes this.
Found during PTS HAP testing.

Bug: 238171211
Test: atest BluetoothInstrumentationTests
Test: PTS
tag: #feature
Merged-In: Ieef9a0f3448ce8529624e777282e857a7f206c00
Change-Id: Ieef9a0f3448ce8529624e777282e857a7f206c00
(cherry picked from commit 090653c2)
parent 739bf6dc
Loading
Loading
Loading
Loading
+8 −10
Original line number Diff line number Diff line
@@ -1024,8 +1024,7 @@ tGATT_STATUS GATTC_ExecuteWrite(uint16_t conn_id, bool is_execute) {
 *
 ******************************************************************************/
tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t cid) {
  VLOG(1) << __func__ << " conn_id=" << loghex(conn_id)
          << ", cid=" << loghex(cid);
  LOG_INFO(" conn_id=0x%04x , cid=0x%04x", conn_id, cid);

  tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(GATT_GET_TCB_IDX(conn_id));
  if (!p_tcb) {
@@ -1034,20 +1033,19 @@ tGATT_STATUS GATTC_SendHandleValueConfirm(uint16_t conn_id, uint16_t cid) {
  }

  if (p_tcb->ind_count == 0) {
    VLOG(1) << " conn_id: " << loghex(conn_id)
            << " ignored not waiting for indicaiton ack";
    LOG_INFO("conn_id: 0x%04x ignored not waiting for indicaiton ack", conn_id);
    return GATT_SUCCESS;
  }

  LOG_INFO("Received confirmation, ind_count= %d, sending confirmation",
           p_tcb->ind_count);

  /* Just wait for first confirmation.*/
  p_tcb->ind_count = 0;
  gatt_stop_ind_ack_timer(p_tcb, cid);

  VLOG(1) << "notif_count= " << p_tcb->ind_count;
  /* send confirmation now */
  tGATT_STATUS ret = attp_send_cl_confirmation_msg(*p_tcb, cid);



  return ret;
  return attp_send_cl_confirmation_msg(*p_tcb, cid);
}

/******************************************************************************/