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

Commit a62f22ab authored by Matt Swartwout's avatar Matt Swartwout Committed by Jack He
Browse files

Do not assume device_type from non-connectable advertisting packets

which omit flags entirely.

Non-connectable device may omit the flags section entirely, and no
assumptions should be made about the flag values in that case (CSSv10,
1.3.1). Currently, we will assume the device_type to be DUMO in that
case, which is incorrect. Prevent this by only setting device_type when
the flags are present or the packet is connectable.

Bug: 194397272
Test: Tested with partner device and verified that incorrect attempted
BT Classic connections are eliminated.
Tag: #compatibility

Change-Id: Ia448abf3fb1c0ee3cdae8133048043ecf2c8b9ff
parent 68844755
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1647,10 +1647,14 @@ void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,

  p_i->inq_count = p_inq->inq_counter; /* Mark entry for current inquiry */

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

  if (!data.empty()) {
@@ -1685,7 +1689,13 @@ void btm_ble_update_inq_result(tINQ_DB_ENT* p_i, uint8_t addr_type,
    }
  }

  if ((p_cur->flag & BTM_BLE_BREDR_NOT_SPT) == 0 &&
  // 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.
  bool should_process_flags =
      has_advertising_flags || ble_evt_type_is_connectable(evt_type);
  if (should_process_flags && (p_cur->flag & BTM_BLE_BREDR_NOT_SPT) == 0 &&
      !ble_evt_type_is_directed(evt_type)) {
    if (p_cur->ble_addr_type != BLE_ADDR_RANDOM) {
      LOG_VERBOSE("NOT_BR_EDR support bit not set, treat device as DUMO");