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

Commit 796cb886 authored by Chris Manton's avatar Chris Manton Committed by Jack He
Browse files

Revert "Add btm_cb.notify_when_complete_cb when inquiry is cancelled"

This reverts commit 31a662d2.

Bug: 235293624
Tag: #refactor
Test: manual & atest CtsBluetoothTestCases
Reason for revert: Breaks

Merged-In: I1a9505fabd581201117ec54f711c4120a092afb7
Change-Id: I60bae5d51b6128489964f7ed32c4f9f2605471a0
parent 3d0f7c50
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -873,11 +873,9 @@ void bta_dm_search_start(tBTA_DM_MSG* p_data) {
 ******************************************************************************/
void bta_dm_search_cancel() {
  if (BTM_IsInquiryActive()) {
    LOG_DEBUG("Cancelling search with inquiry active");
    BTM_CancelInquiryNotifyWhenComplete([]() {
    BTM_CancelInquiry();
    bta_dm_search_cancel_notify();
    bta_dm_search_cmpl();
    });
  }
  /* If no Service Search going on then issue cancel remote name in case it is
     active */
+1 −33
Original line number Diff line number Diff line
@@ -461,18 +461,6 @@ void BTM_CancelInquiry(void) {
  }
}

void BTM_CancelInquiryNotifyWhenComplete(
    std::function<void()> notify_when_complete_cb) {
  if (btm_cb.notify_when_complete_cb) {
    LOG_ERROR(
        "Please do not overwrite a previous cancel inquiry notification "
        "callback");
    return;
  }
  btm_cb.notify_when_complete_cb = notify_when_complete_cb;
  BTM_CancelInquiry();
}

/*******************************************************************************
 *
 * Function         BTM_StartInquiry
@@ -1275,26 +1263,7 @@ void btm_sort_inq_result(void) {
 *
 ******************************************************************************/
void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) {
  if (mode == 0) {
    LOG_WARN("Inquiry completed but no modes were specified");
    return;
  }

  // The mode parameters may be a bitmask with only 2 valid bits indicating
  // completion
  if (mode & ~(BTM_INQUIRY_ACTIVE_MASK)) {
    LOG_WARN("Calling with illegal mode:0x%02x", mode);
  }

  if (mode == BTM_GENERAL_INQUIRY && btm_cb.notify_when_complete_cb) {
    LOG_DEBUG(
        "Cleaning up previous inquiry cancel with proper completion callback "
        "inq_active:0x%02x inqparms.mode:0x%02x",
        btm_cb.btm_inq_vars.inq_active, btm_cb.btm_inq_vars.inqparms.mode);
    btm_cb.notify_when_complete_cb();
    btm_cb.notify_when_complete_cb = {};
    return;
  }
  tBTM_CMPL_CB* p_inq_cb = btm_cb.btm_inq_vars.p_inq_cmpl_cb;
  tBTM_INQUIRY_VAR_ST* p_inq = &btm_cb.btm_inq_vars;

  p_inq->inqparms.mode &= ~(mode);
@@ -1328,7 +1297,6 @@ void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) {
      /* Clear the results callback if set */
      p_inq->p_inq_results_cb = NULL;
      p_inq->inq_active = BTM_INQUIRY_INACTIVE;
      tBTM_CMPL_CB* p_inq_cb = btm_cb.btm_inq_vars.p_inq_cmpl_cb;
      p_inq->p_inq_cmpl_cb = NULL;

      /* If we have a callback registered for inquiry complete, call it */
+0 −2
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ typedef struct tBTM_CB {
  tACL_CB acl_cb_;

  std::shared_ptr<TimestampedStringCircularBuffer> history_{nullptr};
  std::function<void()> notify_when_complete_cb;

  void Init(uint8_t initial_security_mode) {
    memset(&cfg, 0, sizeof(cfg));
@@ -354,7 +353,6 @@ typedef struct tBTM_CB {
        kBtmLogHistoryBufferSize);
    CHECK(history_ != nullptr);
    history_->Push(std::string("Initialized btm history"));
    notify_when_complete_cb = {};
  }

  void Free() {
+0 −2
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#define BTM_API_H

#include <cstdint>
#include <functional>

#include "device/include/esco_parameters.h"
#include "stack/btm/neighbor_inquiry.h"
@@ -317,7 +316,6 @@ uint16_t BTM_IsInquiryActive(void);
 *
 ******************************************************************************/
void BTM_CancelInquiry(void);
void BTM_CancelInquiryNotifyWhenComplete(std::function<void()>);

/*******************************************************************************
 *
+0 −1
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ struct btm_client_interface_t {
  // Neighbor
  struct {
    void (*BTM_CancelInquiry)();
    void (*BTM_CancelInquiryNotifyWhenComplete)();
    tBTM_INQ_INFO* (*BTM_InqDbNext)(tBTM_INQ_INFO* p_cur);
    tBTM_STATUS (*BTM_ClearInqDb)(const RawAddress* p_bda);
    tBTM_STATUS (*BTM_SetDiscoverability)(uint16_t inq_mode);
Loading