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

Commit a8c22b8f authored by Zach Johnson's avatar Zach Johnson
Browse files

BTM_CancelInquiry always returns success

It's only called if inquiry is in progress
and inquiry can only happen if the device is up

so the single failure mode cannot happen.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: Id4d6fca5f8195ef344aa4115c068f0d195287efc
parent bcb9b5f7
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -824,16 +824,12 @@ void bta_dm_search_cancel() {
  tBTA_DM_MSG* p_msg;

  if (BTM_IsInquiryActive()) {
    if (BTM_CancelInquiry() == BTM_SUCCESS) {
    BTM_CancelInquiry();
    bta_dm_search_cancel_notify();
    p_msg = (tBTA_DM_MSG*)osi_malloc(sizeof(tBTA_DM_MSG));
    p_msg->hdr.event = BTA_DM_SEARCH_CMPL_EVT;
    p_msg->hdr.layer_specific = BTA_DM_API_DISCOVER_EVT;
    bta_sys_sendmsg(p_msg);
    } else {
      /* flag a search cancel is pending */
      bta_dm_search_cb.cancel_pending = true;
    }
  }
  /* If no Service Search going on then issue cancel remote name in case it is
     active */
+1 −2
Original line number Diff line number Diff line
@@ -593,7 +593,7 @@ uint16_t bluetooth::shim::BTM_IsInquiryActive(void) {
  return BTM_INQUIRY_INACTIVE;
}

tBTM_STATUS bluetooth::shim::BTM_CancelInquiry(void) {
void bluetooth::shim::BTM_CancelInquiry(void) {
  LOG_DEBUG("%s Cancel inquiry", __func__);
  Stack::GetInstance()->GetBtm()->CancelInquiry();

@@ -635,7 +635,6 @@ tBTM_STATUS bluetooth::shim::BTM_CancelInquiry(void) {
      btm_cb.btm_inq_vars.scan_type == INQ_GENERAL) {
    btm_cb.btm_inq_vars.scan_type = INQ_NONE;
  }
  return BTM_SUCCESS;
}

tBTM_STATUS bluetooth::shim::BTM_ReadRemoteDeviceName(
+1 −5
Original line number Diff line number Diff line
@@ -201,12 +201,8 @@ uint16_t BTM_IsInquiryActive(void);
 *
 * Description      This function cancels an inquiry if active
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_NO_RESOURCES if could not allocate a message buffer
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_CancelInquiry(void);
void BTM_CancelInquiry(void);

/*******************************************************************************
 *
+4 −11
Original line number Diff line number Diff line
@@ -533,22 +533,17 @@ uint16_t BTM_IsInquiryActive(void) {
 *
 * Description      This function cancels an inquiry if active
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_NO_RESOURCES if could not allocate a message buffer
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_CancelInquiry(void) {
void BTM_CancelInquiry(void) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    return bluetooth::shim::BTM_CancelInquiry();
    bluetooth::shim::BTM_CancelInquiry();
    return;
  }

  tBTM_STATUS status = BTM_SUCCESS;
  tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars;
  BTM_TRACE_API("BTM_CancelInquiry called");

  /*** Make sure the device is ready ***/
  if (!BTM_IsDeviceUp()) return (BTM_WRONG_MODE);
  CHECK(BTM_IsDeviceUp());

  /* Only cancel if not in periodic mode, otherwise the caller should call
   * BTM_CancelPeriodicMode */
@@ -578,8 +573,6 @@ tBTM_STATUS BTM_CancelInquiry(void) {
    p_inq->inq_counter++;
    btm_clr_inq_result_flt();
  }

  return (status);
}

/*******************************************************************************
+1 −5
Original line number Diff line number Diff line
@@ -327,12 +327,8 @@ uint16_t BTM_IsInquiryActive(void);
 *
 * Description      This function cancels an inquiry if active
 *
 * Returns          BTM_SUCCESS if successful
 *                  BTM_NO_RESOURCES if could not allocate a message buffer
 *                  BTM_WRONG_MODE if the device is not up.
 *
 ******************************************************************************/
tBTM_STATUS BTM_CancelInquiry(void);
void BTM_CancelInquiry(void);

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