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

Commit 728c99c2 authored by Christine Hallstrom's avatar Christine Hallstrom
Browse files

Skip flag process if no data in ADV packet



Bug: 329888460
Bug: 329134426
Test: m .
Change-Id: Ic3a09af7d1ed9b10384380b72168868881cc65dc
Signed-off-by: default avatarEdward Wang <wangedward@google.com>
parent 17127f18
Loading
Loading
Loading
Loading
+39 −14
Original line number Diff line number Diff line
@@ -2355,11 +2355,13 @@ static void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,

  bool has_advertising_flags = false;
  if (!data.empty()) {
    uint8_t local_flag = 0;
    const uint8_t* p_flag =
        AdvertiseDataParser::GetFieldByType(data, BTM_BLE_AD_TYPE_FLAG, &len);
    if (p_flag != NULL && len != 0) {
      has_advertising_flags = true;
      p_cur->flag = *p_flag;
      local_flag = *p_flag;
    }

    p_cur->dev_class = btm_ble_get_appearance_as_cod(data);
@@ -2392,8 +2394,30 @@ static void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,
        break;
      }
    }
    if (IS_FLAG_ENABLED(ensure_valid_adv_flag)) {
      // Non-connectable packets may omit flags entirely, in which case nothing
      // should be assumed about their values (CSSv10, 1.3.1). Thus, do not
      // interpret the device type unless this packet has the flags set or is
      // connectable.
      if (ble_evt_type_is_connectable(evt_type) && !has_advertising_flags) {
        // Assume that all-zero flags were received
        has_advertising_flags = true;
        local_flag = 0;
      }
      if (has_advertising_flags && (local_flag & BTM_BLE_BREDR_NOT_SPT) == 0) {
        if (p_cur->ble_addr_type != BLE_ADDR_RANDOM) {
          LOG_VERBOSE("NOT_BR_EDR support bit not set, treat device as DUMO");
          p_cur->device_type |= BT_DEVICE_TYPE_DUMO;
        } else {
          LOG_VERBOSE("Random address, treat device as LE only");
        }
      } else {
        LOG_VERBOSE("NOT_BR/EDR support bit set, treat device as LE only");
      }
    }
  }

  if (!IS_FLAG_ENABLED(ensure_valid_adv_flag)) {
    // Non-connectable packets may omit flags entirely, in which case nothing
    // should be assumed about their values (CSSv10, 1.3.1). Thus, do not
    // interpret the device type unless this packet has the flags set or is
@@ -2412,6 +2436,7 @@ static void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,
      log::verbose("NOT_BR/EDR support bit set, treat device as LE only");
    }
  }
}

void btm_ble_process_adv_addr(RawAddress& bda, tBLE_ADDR_TYPE* addr_type) {
  /* map address to security record */