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

Commit b8564629 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Introduce BTM_BleOpportunisticObserve" am: d6446040 am: 71a20ea0

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1741135

Change-Id: I52541d2ffae855a5603e50e181f1ac41b6ed8e7f
parents 5b64fd71 71a20ea0
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -720,6 +720,15 @@ tBTM_STATUS bluetooth::shim::BTM_BleObserve(bool start, uint8_t duration_sec,
  return BTM_CMD_STARTED;
}

void bluetooth::shim::BTM_BleOpportunisticObserve(
    bool enable, tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (enable) {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = nullptr;
  }
}

void bluetooth::shim::BTM_EnableInterlacedPageScan() {
  Stack::GetInstance()->GetBtm()->SetInterlacedPageScan();
}
+20 −0
Original line number Diff line number Diff line
@@ -98,6 +98,26 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
                           tBTM_INQ_RESULTS_CB* p_results_cb,
                           tBTM_CMPL_CB* p_cmpl_cb);

/*******************************************************************************
 *
 * Function         BTM_BleOpportunisticObserve
 *
 * Description      Register/unregister opportunistic scan callback. This method
 *                  does not trigger scan start/stop, but if scan is ever started,
 *                  this callback would get called with scan results. Additionally,
 *                  this callback is not reset on each scan start/stop. It's
 *                  intended to be used by LE Audio related profiles, that would
 *                  find yet unpaired members of CSIS set, or broadcasts.
 *
 * Parameters       enable: enable/disable observing.
 *                  p_results_cb: callback for results.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTM_BleOpportunisticObserve(bool enable,
                                 tBTM_INQ_RESULTS_CB* p_results_cb);

void BTM_EnableInterlacedInquiryScan();

void BTM_EnableInterlacedPageScan();
+30 −0
Original line number Diff line number Diff line
@@ -374,6 +374,20 @@ inline bool BTM_LE_STATES_SUPPORTED(const uint8_t* x, uint8_t bit_num) {
  return ((x)[offset] & mask);
}

void BTM_BleOpportunisticObserve(bool enable,
                                 tBTM_INQ_RESULTS_CB* p_results_cb) {
  if (bluetooth::shim::is_gd_shim_enabled()) {
    bluetooth::shim::BTM_BleOpportunisticObserve(enable, p_results_cb);
    return;
  }

  if (enable) {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = p_results_cb;
  } else {
    btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb = NULL;
  }
}

/*******************************************************************************
 *
 * Function         BTM_BleObserve
@@ -1990,6 +2004,14 @@ void btm_ble_process_adv_pkt_cont(uint16_t evt_type, uint8_t addr_type,
                       const_cast<uint8_t*>(adv_data.data()), adv_data.size());
  }

  tBTM_INQ_RESULTS_CB* p_opportunistic_obs_results_cb =
      btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb;
  if (p_opportunistic_obs_results_cb) {
    (p_opportunistic_obs_results_cb)((tBTM_INQ_RESULTS*)&p_i->inq_info.results,
                                     const_cast<uint8_t*>(adv_data.data()),
                                     adv_data.size());
  }

  cache.Clear(addr_type, bda);
}

@@ -2056,6 +2078,14 @@ void btm_ble_process_adv_pkt_cont_for_inquiry(
                       const_cast<uint8_t*>(advertising_data.data()),
                       advertising_data.size());
  }

  tBTM_INQ_RESULTS_CB* p_opportunistic_obs_results_cb =
      btm_cb.ble_ctr_cb.p_opportunistic_obs_results_cb;
  if (p_opportunistic_obs_results_cb) {
    (p_opportunistic_obs_results_cb)(
        (tBTM_INQ_RESULTS*)&p_i->inq_info.results,
        const_cast<uint8_t*>(advertising_data.data()), advertising_data.size());
  }
}

void btm_ble_process_phy_update_pkt(uint8_t len, uint8_t* data) {
+3 −0
Original line number Diff line number Diff line
@@ -223,6 +223,9 @@ typedef struct {
  tBTM_CMPL_CB* p_obs_cmpl_cb;
  alarm_t* observer_timer;

  /* opportunistic observer */
  tBTM_INQ_RESULTS_CB* p_opportunistic_obs_results_cb;

  /* background connection procedure cb value */
  uint16_t scan_int;
  uint16_t scan_win;
+20 −0
Original line number Diff line number Diff line
@@ -168,6 +168,26 @@ extern tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
                                  tBTM_INQ_RESULTS_CB* p_results_cb,
                                  tBTM_CMPL_CB* p_cmpl_cb);

/*******************************************************************************
 *
 * Function         BTM_BleOpportunisticObserve
 *
 * Description      Register/unregister opportunistic scan callback. This method
 *                  does not trigger scan start/stop, but if scan is ever started,
 *                  this callback would get called with scan results. Additionally,
 *                  this callback is not reset on each scan start/stop. It's
 *                  intended to be used by LE Audio related profiles, that would
 *                  find yet unpaired members of CSIS set, or broadcasts.
 *
 * Parameters       enable: enable/disable observing.
 *                  p_results_cb: callback for results.
 *
 * Returns          void
 *
 ******************************************************************************/
extern void BTM_BleOpportunisticObserve(bool enable,
                                        tBTM_INQ_RESULTS_CB* p_results_cb);

/** Returns local device encryption root (ER) */
const Octet16& BTM_GetDeviceEncRoot();

Loading