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

Commit 25efd4a1 authored by Md Shahriar Hossain Sajib's avatar Md Shahriar Hossain Sajib Committed by Cherrypicker Worker
Browse files

Stop btif queue to get stuck on the same node

If something goes wrong during processing a hf client connect request,
the request node is creating a deadlock for other requests, blocking the
queue forever. Releasing the blocking node if something goes wrong.
Cherry picked from wear OS

Bug: 263323082
Bug: 232734797
Test: manual
Change-Id: If24762367a3ba18f14b54c24b5cf7bbe71de62e3
(cherry picked from commit 05d6df87ff6164273be2c0df2e25f2515663a356)
(cherry picked from commit c621a3a0)
Merged-In: If24762367a3ba18f14b54c24b5cf7bbe71de62e3
parent dd0a78fd
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -80,17 +80,17 @@ void BTA_HfClientDisable(void) { bta_hf_client_api_disable(); }
 * Description      Opens up a RF connection to the remote device and
 *                  subsequently set it up for a HF SLC
 *
 * Returns          void
 * Returns          bt_status_t
 *
 ******************************************************************************/
void BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) {
bt_status_t BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) {
  APPL_TRACE_DEBUG("%s", __func__);
  tBTA_HF_CLIENT_API_OPEN* p_buf =
      (tBTA_HF_CLIENT_API_OPEN*)osi_malloc(sizeof(tBTA_HF_CLIENT_API_OPEN));

  if (!bta_hf_client_allocate_handle(bd_addr, p_handle)) {
    APPL_TRACE_ERROR("%s: could not allocate handle", __func__);
    return;
    return BT_STATUS_FAIL;
  }

  p_buf->hdr.event = BTA_HF_CLIENT_API_OPEN_EVT;
@@ -98,6 +98,7 @@ void BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) {
  p_buf->bd_addr = bd_addr;

  bta_sys_sendmsg(p_buf);
  return BT_STATUS_SUCCESS;
}

/*******************************************************************************
+2 −2
Original line number Diff line number Diff line
@@ -321,10 +321,10 @@ void BTA_HfClientDisable(void);
 *                  calls to do any AT operations
 *
 *
 * Returns          void
 * Returns          bt_status_t
 *
 ******************************************************************************/
void BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle);
bt_status_t BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle);

/*******************************************************************************
 *
+1 −3
Original line number Diff line number Diff line
@@ -313,9 +313,7 @@ static bt_status_t connect_int(RawAddress* bd_addr, uint16_t uuid) {
   * The handle is valid until we have called BTA_HfClientClose or the LL
   * has notified us of channel close due to remote closing, error etc.
   */
  BTA_HfClientOpen(cb->peer_bda, &cb->handle);

  return BT_STATUS_SUCCESS;
  return BTA_HfClientOpen(cb->peer_bda, &cb->handle);
}

static bt_status_t connect(RawAddress* bd_addr) {
+2 −1
Original line number Diff line number Diff line
@@ -51,8 +51,9 @@ void BTA_HfClientAudioOpen(uint16_t handle) {
void BTA_HfClientClose(uint16_t handle) { mock_function_count_map[__func__]++; }
void BTA_HfClientDisable(void) { mock_function_count_map[__func__]++; }
void BTA_HfClientDumpStatistics(int fd) { mock_function_count_map[__func__]++; }
void BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) {
bt_status_t BTA_HfClientOpen(const RawAddress& bd_addr, uint16_t* p_handle) {
  mock_function_count_map[__func__]++;
  return BT_STATUS_SUCCESS;
}
void BTA_HfClientSendAT(uint16_t handle, tBTA_HF_CLIENT_AT_CMD_TYPE at,
                        uint32_t val1, uint32_t val2, const char* str) {