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

Commit 3d872bba authored by shihchienc's avatar shihchienc
Browse files

BTM: Let CSIS active scanning take effect

Currently when there is an ongoing background scanning like 10% or 25%,
CSIS active scannning would not take effect since the first scanning
come first. This makes finding coordinate members more difficult as the
scanning % is not enough.

This Patch checks if current scan is for CSIS then stops any ongoing
scanning and uses low latency scanning for finding coordinate members.
This increases paring speed and also decreases the failure that we
do not find coordinate members.

Bug: 273958309
Test: make sure we find csis member with 100% scanning
Change-Id: I4b469166690f20306fcdcb57d7ca4a311d5969bc
parent 5d2398cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1281,7 +1281,7 @@ class CsisClientImpl : public CsisClient {

          instance->OnActiveScanResult(&p_data->inq_res);
        });
    BTA_DmBleScan(enable, bluetooth::csis::kDefaultScanDurationS);
    BTA_DmBleScan(enable, bluetooth::csis::kDefaultScanDurationS, true);

    /* Need to call it by ourselfs */
    if (!enable) {
+8 −5
Original line number Diff line number Diff line
@@ -4016,9 +4016,11 @@ void bta_dm_ble_config_local_privacy(bool privacy_enable) {
  BTM_BleConfigPrivacy(privacy_enable);
}

static void bta_dm_start_scan(uint8_t duration_sec) {
  tBTM_STATUS status = BTM_BleObserve(
      true, duration_sec, bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb);
static void bta_dm_start_scan(uint8_t duration_sec,
                              bool low_latency_scan = false) {
  tBTM_STATUS status =
      BTM_BleObserve(true, duration_sec, bta_dm_observe_results_cb,
                     bta_dm_observe_cmpl_cb, low_latency_scan);

  if (status != BTM_CMD_STARTED) {
    tBTA_DM_SEARCH data = {
@@ -4051,7 +4053,8 @@ void bta_dm_ble_observe(bool start, uint8_t duration,
  bta_dm_start_scan(duration);
}

void bta_dm_ble_scan(bool start, uint8_t duration_sec) {
void bta_dm_ble_scan(bool start, uint8_t duration_sec,
                     bool low_latency_scan = false) {
  /* Start or stop only if there is no active main scanner */
  if (bta_dm_search_cb.p_scan_cback != NULL) return;

@@ -4060,7 +4063,7 @@ void bta_dm_ble_scan(bool start, uint8_t duration_sec) {
    return;
  }

  bta_dm_start_scan(duration_sec);
  bta_dm_start_scan(duration_sec, low_latency_scan);
}

void bta_dm_ble_csis_observe(bool observe, tBTA_DM_SEARCH_CBACK* p_cback) {
+5 −3
Original line number Diff line number Diff line
@@ -605,14 +605,16 @@ void BTA_DmBleObserve(bool start, uint8_t duration,
 * Parameters       start: start or stop the scan procedure,
 *                  duration_sec: Duration of the scan. Continuous scan if 0 is
 *                                passed,
 *                  low_latency_scan: whether this is an low latency scan,
 *                                    default is false.
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_DmBleScan(bool start, uint8_t duration_sec) {
void BTA_DmBleScan(bool start, uint8_t duration_sec, bool low_latency_scan) {
  APPL_TRACE_API("%s:start = %d ", __func__, start);
  do_in_main_thread(FROM_HERE,
                    base::Bind(bta_dm_ble_scan, start, duration_sec));
  do_in_main_thread(FROM_HERE, base::Bind(bta_dm_ble_scan, start, duration_sec,
                                          low_latency_scan));
}

/*******************************************************************************
+1 −1
Original line number Diff line number Diff line
@@ -538,7 +538,7 @@ void bta_dm_ble_set_conn_params(const RawAddress&, uint16_t, uint16_t, uint16_t,
                                uint16_t);
void bta_dm_close_gatt_conn(tBTA_DM_MSG* p_data);
void bta_dm_ble_observe(bool, uint8_t, tBTA_DM_SEARCH_CBACK*);
void bta_dm_ble_scan(bool, uint8_t);
void bta_dm_ble_scan(bool, uint8_t, bool);
void bta_dm_ble_csis_observe(bool, tBTA_DM_SEARCH_CBACK*);
void bta_dm_ble_update_conn_params(const RawAddress&, uint16_t, uint16_t,
                                   uint16_t, uint16_t, uint16_t, uint16_t);
+3 −1
Original line number Diff line number Diff line
@@ -1146,11 +1146,13 @@ void BTA_DmBleObserve(bool start, uint8_t duration,
 * Parameters       start: start or stop the scan procedure,
 *                  duration_sec: Duration of the scan. Continuous scan if 0 is
 *                                passed,
 *                  low_latency_scan: whether this is a low latency scan,
 *                                    default is false,
 *
 * Returns          void
 *
 ******************************************************************************/
void BTA_DmBleScan(bool start, uint8_t duration);
void BTA_DmBleScan(bool start, uint8_t duration, bool low_latency_scan = false);

/*******************************************************************************
 *
Loading