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

Commit ec338dca authored by Myles Watson's avatar Myles Watson Committed by Automerger Merge Worker
Browse files

Merge changes I6a587050,I01d6f540 into main am: 6f132c11

parents 34381327 6f132c11
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -1411,11 +1411,12 @@ class CsisClientImpl : public CsisClient {
                            */
                           if (instance == nullptr) return;

                           if (event == BTA_DM_INQ_CMPL_EVT) {
                           if (event == BTA_DM_OBSERVE_CMPL_EVT) {
                             power_telemetry::GetInstance().LogBleScan(
                                 static_cast<int>(p_data->inq_cmpl.num_resps));
                                 static_cast<int>(
                                     p_data->observe_cmpl.num_resps));
                             log::info("BLE observe complete. Num Resp: {}",
                                       p_data->inq_cmpl.num_resps);
                                       p_data->observe_cmpl.num_resps);
                             csis_ad_type_filter_set(false);
                             instance->OnCsisObserveCompleted();
                             instance->CsisObserverSetBackground(true);
@@ -1535,11 +1536,12 @@ class CsisClientImpl : public CsisClient {
                            */
                           if (instance == nullptr) return;

                           if (event == BTA_DM_INQ_CMPL_EVT) {
                           if (event == BTA_DM_OBSERVE_CMPL_EVT) {
                             power_telemetry::GetInstance().LogBleScan(
                                 static_cast<int>(p_data->inq_cmpl.num_resps));
                                 static_cast<int>(
                                     p_data->observe_cmpl.num_resps));
                             log::verbose("BLE observe complete. Num Resp: {}",
                                          p_data->inq_cmpl.num_resps);
                                          p_data->observe_cmpl.num_resps);
                             return;
                           }

+2 −2
Original line number Diff line number Diff line
@@ -1206,9 +1206,9 @@ TEST_F(CsisClientTest, test_csis_member_not_found) {
  ASSERT_NE(p_results_cb, nullptr);

  tBTA_DM_SEARCH result;
  result.inq_cmpl.num_resps = 80;
  result.observe_cmpl.num_resps = 80;

  p_results_cb(BTA_DM_INQ_CMPL_EVT, &result);
  p_results_cb(BTA_DM_OBSERVE_CMPL_EVT, &result);

  /* Verify that scanner has been called to stop filtering  */
  ASSERT_EQ(2, get_func_call_count("set_empty_filter"));
+12 −23
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ tBTA_DM_SEARCH_CB bta_dm_search_cb;
static void bta_dm_gatt_disc_complete(uint16_t conn_id, tGATT_STATUS status);
static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
                                  uint16_t eir_len);
static void bta_dm_inq_cmpl(uint8_t num);
static void bta_dm_inq_cmpl();
static void bta_dm_inq_cmpl_cb(void* p_result);
static void bta_dm_service_search_remname_cback(const RawAddress& bd_addr,
                                                DEV_CLASS dc, BD_NAME bd_name);
@@ -288,7 +288,7 @@ static void bta_dm_search_start(tBTA_DM_MSG* p_data) {
      log::warn("Unable to start device discovery search btm_status:{}",
                btm_status_text(btm_status));
      // Not started so completion callback is executed now
      bta_dm_inq_cmpl(0);
      bta_dm_inq_cmpl();
      break;
  }
}
@@ -321,7 +321,7 @@ static void bta_dm_search_cancel() {
    }
#endif
  } else {
    bta_dm_inq_cmpl(0);
    bta_dm_inq_cmpl();
  }
}

@@ -437,7 +437,7 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr,
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_inq_cmpl(uint8_t num) {
static void bta_dm_inq_cmpl() {
  if (bta_dm_search_get_state() == BTA_DM_SEARCH_CANCELLING) {
    bta_dm_search_set_state(BTA_DM_SEARCH_IDLE);
    bta_dm_execute_queued_request();
@@ -448,13 +448,8 @@ static void bta_dm_inq_cmpl(uint8_t num) {
    return;
  }

  tBTA_DM_SEARCH data;

  log::verbose("bta_dm_inq_cmpl");

  data.inq_cmpl.num_resps = num;
  bta_dm_search_cb.p_search_cback(BTA_DM_INQ_CMPL_EVT, &data);

  bta_dm_search_cb.p_btm_inq_info =
      get_btm_client_interface().db.BTM_InqDbFirst();
  if (bta_dm_search_cb.p_btm_inq_info != NULL) {
@@ -1536,10 +1531,10 @@ static void bta_dm_inq_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
 * Returns          void
 *
 ******************************************************************************/
static void bta_dm_inq_cmpl_cb(void* p_result) {
static void bta_dm_inq_cmpl_cb(void* /* p_result */) {
  log::verbose("");

  bta_dm_inq_cmpl(((tBTM_INQUIRY_CMPL*)p_result)->num_resp);
  bta_dm_inq_cmpl();
}

/*******************************************************************************
@@ -1797,13 +1792,12 @@ static void bta_dm_opportunistic_observe_results_cb(tBTM_INQ_RESULTS* p_inq,
 *
 ******************************************************************************/
static void bta_dm_observe_cmpl_cb(void* p_result) {
  tBTA_DM_SEARCH data;

  log::verbose("bta_dm_observe_cmpl_cb");

  data.inq_cmpl.num_resps = ((tBTM_INQUIRY_CMPL*)p_result)->num_resp;
  if (bta_dm_search_cb.p_csis_scan_cback) {
    bta_dm_search_cb.p_csis_scan_cback(BTA_DM_INQ_CMPL_EVT, &data);
    auto num_resps = ((tBTM_INQUIRY_CMPL*)p_result)->num_resp;
    tBTA_DM_SEARCH data{.observe_cmpl{.num_resps = num_resps}};
    bta_dm_search_cb.p_csis_scan_cback(BTA_DM_OBSERVE_CMPL_EVT, &data);
  }
}

@@ -1814,15 +1808,10 @@ static void bta_dm_start_scan(uint8_t duration_sec,
      low_latency_scan);

  if (status != BTM_CMD_STARTED) {
    tBTA_DM_SEARCH data = {
        .inq_cmpl =
            {
                .num_resps = 0,
            },
    };
    log::warn("BTM_BleObserve  failed. status {}", status);
    if (bta_dm_search_cb.p_csis_scan_cback) {
      bta_dm_search_cb.p_csis_scan_cback(BTA_DM_INQ_CMPL_EVT, &data);
      tBTA_DM_SEARCH data{.observe_cmpl = {.num_resps = 0}};
      bta_dm_search_cb.p_csis_scan_cback(BTA_DM_OBSERVE_CMPL_EVT, &data);
    }
  }
}
@@ -2455,7 +2444,7 @@ void bta_dm_execute_queued_request() { ::bta_dm_execute_queued_request(); }
void bta_dm_find_services(const RawAddress& bd_addr) {
  ::bta_dm_find_services(bd_addr);
}
void bta_dm_inq_cmpl(uint8_t num) { ::bta_dm_inq_cmpl(num); }
void bta_dm_inq_cmpl() { ::bta_dm_inq_cmpl(); }
void bta_dm_inq_cmpl_cb(void* p_result) { ::bta_dm_inq_cmpl_cb(p_result); }
void bta_dm_observe_cmpl_cb(void* p_result) {
  ::bta_dm_observe_cmpl_cb(p_result);
+6 −4
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ typedef enum : uint8_t {
  BTA_DM_DID_RES_EVT = 6,            /* Vendor/Product ID search result */
  BTA_DM_GATT_OVER_SDP_RES_EVT = 7,  /* GATT services over SDP discovered */
  BTA_DM_NAME_READ_EVT = 8,          /* Name read complete. */
  BTA_DM_OBSERVE_CMPL_EVT = 9,       /* Observe complete. */
} tBTA_DM_SEARCH_EVT;

inline std::string bta_dm_search_evt_text(const tBTA_DM_SEARCH_EVT& event) {
@@ -237,6 +238,7 @@ inline std::string bta_dm_search_evt_text(const tBTA_DM_SEARCH_EVT& event) {
    CASE_RETURN_TEXT(BTA_DM_DID_RES_EVT);
    CASE_RETURN_TEXT(BTA_DM_GATT_OVER_SDP_RES_EVT);
    CASE_RETURN_TEXT(BTA_DM_NAME_READ_EVT);
    CASE_RETURN_TEXT(BTA_DM_OBSERVE_CMPL_EVT);
    default:
      return base::StringPrintf("UNKNOWN[%hhu]", event);
  }
@@ -270,10 +272,10 @@ typedef struct {
  uint16_t clock_offset;
} tBTA_DM_INQ_RES;

/* Structure associated with BTA_DM_INQ_CMPL_EVT */
/* Structure associated with BTA_DM_OBSERVE_CMPL_EVT */
typedef struct {
  uint8_t num_resps; /* Number of inquiry responses. */
} tBTA_DM_INQ_CMPL;
  uint8_t num_resps; /* Number of responses. */
} tBTA_DM_OBSERVE_CMPL;

/* Structure associated with BTA_DM_DISC_RES_EVT */
typedef struct {
@@ -307,11 +309,11 @@ typedef struct {
/* Union of all search callback structures */
typedef union {
  tBTA_DM_INQ_RES inq_res;   /* Inquiry result for a peer device. */
  tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
  tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
  tBTA_DM_DISC_BLE_RES
      disc_ble_res;             /* discovery result for GATT based service */
  tBTA_DM_DID_RES did_res;      /* Vendor and Product ID of peer device */
  tBTA_DM_OBSERVE_CMPL observe_cmpl; /* Observe complete. */
} tBTA_DM_SEARCH;

/* Search callback */
+3 −5
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ void bta_dm_disc_search_cb(const tBTA_DM_SEARCH_CB& search_cb);
void bta_dm_discover_next_device();
void bta_dm_execute_queued_request();
void bta_dm_find_services(const RawAddress& bd_addr);
void bta_dm_inq_cmpl(uint8_t num);
void bta_dm_inq_cmpl();
void bta_dm_inq_cmpl_cb(void* p_result);
void bta_dm_observe_cmpl_cb(void* p_result);
void bta_dm_observe_results_cb(tBTM_INQ_RESULTS* p_inq, const uint8_t* p_eir,
@@ -136,10 +136,8 @@ TEST_F(BtaDiscTest, bta_dm_find_services) {
}

TEST_F(BtaDiscTest, bta_dm_inq_cmpl) {
  bluetooth::legacy::testing::bta_dm_inq_cmpl(0);
  bluetooth::legacy::testing::bta_dm_inq_cmpl(1);
  bluetooth::legacy::testing::bta_dm_inq_cmpl(2);
  bluetooth::legacy::testing::bta_dm_inq_cmpl(255);
  bluetooth::legacy::testing::bta_dm_inq_cmpl();
  bluetooth::legacy::testing::bta_dm_inq_cmpl();
}

TEST_F(BtaDiscTest, bta_dm_inq_cmpl_cb) {