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

Commit 50584496 authored by Myles Watson's avatar Myles Watson
Browse files

bta_dm: Split OBSERVE_CMPL and INQ_CMPL

Bug: 330675788
Test: mma -j32
EXEMPT: Trivial refactor
Change-Id: I01d6f540da97974185a630152dc07f18998ed9bf
parent d965f000
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"));
+5 −11
Original line number Diff line number Diff line
@@ -1797,13 +1797,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 +1813,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);
    }
  }
}
+8 −0
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);
  }
@@ -275,6 +277,11 @@ typedef struct {
  uint8_t num_resps; /* Number of inquiry responses. */
} tBTA_DM_INQ_CMPL;

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

/* Structure associated with BTA_DM_DISC_RES_EVT */
typedef struct {
  RawAddress bd_addr;          /* BD address peer device. */
@@ -312,6 +319,7 @@ typedef union {
  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 */