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

Commit 0749df1c authored by Huirong Liao's avatar Huirong Liao
Browse files

Fix BR/EDR device may be flush by ble device

[Root Cause]
if there are too much ble device(adv), br/edr will be overwritten
by ble device, then targe device will not in inquiry db.
then it will not do RNR for some device without name.

[Solution]
so enlarge the inquiry db and reserve half of it for BR/EDR and ble.

Bug: 266219643
Test: atest net_test_btif_stack pass

Change-Id: I955fb52696ad9cdacc0aff7cbb4bf2dd81f342b0
parent 921d1c8c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@

/* The size in bytes of the BTM inquiry database. */
#ifndef BTM_INQ_DB_SIZE
#define BTM_INQ_DB_SIZE 40
#define BTM_INQ_DB_SIZE 80
#endif

/* Sets the Page_Scan_Window:  the length of time that the device is performing
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ std::mutex btm_cb_mutex_;

bool btm_inq_find_bdaddr(const RawAddress& p_bda);
extern tINQ_DB_ENT* btm_inq_db_find(const RawAddress& raw_address);
extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda);
extern tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda, bool is_ble);

/**
 * Legacy bluetooth btm stack entry points
+2 −2
Original line number Diff line number Diff line
@@ -2807,7 +2807,7 @@ void btm_ble_process_adv_pkt_cont(uint16_t evt_type, tBLE_ADDR_TYPE addr_type,
  /* If existing entry, use that, else get  a new one (possibly reusing the
   * oldest) */
  if (p_i == NULL) {
    p_i = btm_inq_db_new(bda);
    p_i = btm_inq_db_new(bda, true);
    if (p_i != NULL) {
      p_inq->inq_cmpl_info.num_resp++;
      p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
@@ -2913,7 +2913,7 @@ void btm_ble_process_adv_pkt_cont_for_inquiry(
  /* If existing entry, use that, else get  a new one (possibly reusing the
   * oldest) */
  if (p_i == NULL) {
    p_i = btm_inq_db_new(bda);
    p_i = btm_inq_db_new(bda, true);
    if (p_i != NULL) {
      p_inq->inq_cmpl_info.num_resp++;
      p_i->time_of_resp = bluetooth::common::time_get_os_boottime_ms();
+10 −7
Original line number Diff line number Diff line
@@ -1161,16 +1161,19 @@ tINQ_DB_ENT* btm_inq_db_find(const RawAddress& p_bda) {
 * Returns          pointer to entry
 *
 ******************************************************************************/
tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda) {
  uint16_t xx;
  uint64_t ot = UINT64_MAX;
tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda, bool is_ble) {
  uint16_t xx = 0, yy = 0;
  uint32_t ot = 0xFFFFFFFF;
  int8_t i_rssi = 0;

  if (is_ble) yy = BTM_INQ_DB_SIZE / 2;
  else yy = 0;

  std::lock_guard<std::mutex> lock(inq_db_lock_);
  tINQ_DB_ENT* p_ent = inq_db_;
  tINQ_DB_ENT* p_old = inq_db_;
  tINQ_DB_ENT* p_ent = &inq_db_[yy];
  tINQ_DB_ENT* p_old = &inq_db_[yy];

  for (xx = 0; xx < BTM_INQ_DB_SIZE; xx++, p_ent++) {
  for (xx = 0; xx < BTM_INQ_DB_SIZE / 2; xx++, p_ent++) {
    if (!p_ent->in_use) {
      memset(p_ent, 0, sizeof(tINQ_DB_ENT));
      p_ent->inq_info.results.remote_bd_addr = p_bda;
@@ -1324,7 +1327,7 @@ void btm_process_inq_results(const uint8_t* p, uint8_t hci_evt_len,
    /* If existing entry, use that, else get a new one (possibly reusing the
     * oldest) */
    if (p_i == NULL) {
      p_i = btm_inq_db_new(bda);
      p_i = btm_inq_db_new(bda, false);
      is_new = true;
    }

+1 −1
Original line number Diff line number Diff line
@@ -33,5 +33,5 @@ void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode);
void btm_process_cancel_complete(tHCI_STATUS status, uint8_t mode);

void btm_acl_process_sca_cmpl_pkt(uint8_t len, uint8_t* data);
tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda);
tINQ_DB_ENT* btm_inq_db_new(const RawAddress& p_bda, bool is_ble);
void btm_inq_db_set_inq_by_rssi(void);
Loading