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

Commit c7ad1fb7 authored by Bidhya Sharma's avatar Bidhya Sharma
Browse files

Revert "Get device type using adv flag data"

This reverts commit 4e116b8f.

Reason for revert: b/277592572 and b/277181818

Change-Id: Ie1b056b30307e40511358dbe84c8593aa41c3ae2
parent 1f3cdb14
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -95,9 +95,7 @@ MutationEntry Device::RemoveFromTempConfig() {
LeDevice Device::Le() {
  auto device_type = GetDeviceType();
  ASSERT(device_type);
  ASSERT(
      device_type == DeviceType::LE || device_type == DeviceType::DUAL ||
      device_type == DeviceType::UNKNOWN);
  ASSERT(device_type == DeviceType::LE || device_type == DeviceType::DUAL);
  return LeDevice(config_, memory_only_config_, section_);
}

+1 −2
Original line number Diff line number Diff line
@@ -144,8 +144,7 @@ class BleScannerInterfaceImpl : public ::BleScannerInterface,
      bluetooth::hci::AdvertisingPacketContentFilterCommand&
          advertising_packet_content_filter_command,
      ApcfCommand apcf_command);
  void handle_remote_properties(uint16_t event_type, RawAddress bd_addr,
                                tBLE_ADDR_TYPE addr_type,
  void handle_remote_properties(RawAddress bd_addr, tBLE_ADDR_TYPE addr_type,
                                std::vector<uint8_t> advertising_data);

  class AddressCache {
+9 −26
Original line number Diff line number Diff line
@@ -513,8 +513,8 @@ void BleScannerInterfaceImpl::OnScanResult(
  do_in_jni_thread(
      FROM_HERE,
      base::BindOnce(&BleScannerInterfaceImpl::handle_remote_properties,
                     base::Unretained(this), event_type, raw_address,
                     ble_addr_type, advertising_data));
                     base::Unretained(this), raw_address, ble_addr_type,
                     advertising_data));

  do_in_jni_thread(
      FROM_HERE,
@@ -726,7 +726,7 @@ bool BleScannerInterfaceImpl::parse_filter_command(
}

void BleScannerInterfaceImpl::handle_remote_properties(
    uint16_t event_type, RawAddress bd_addr, tBLE_ADDR_TYPE addr_type,
    RawAddress bd_addr, tBLE_ADDR_TYPE addr_type,
    std::vector<uint8_t> advertising_data) {
  if (!bluetooth::shim::is_gd_stack_started_up()) {
    LOG_WARN("Gd stack is stopped, return");
@@ -738,33 +738,16 @@ void BleScannerInterfaceImpl::handle_remote_properties(
    return;
  }

  auto device_type = bluetooth::hci::DeviceType::LE;
  uint8_t flag_len;
  const uint8_t* p_flag = AdvertiseDataParser::GetFieldByType(
      advertising_data, BTM_BLE_AD_TYPE_FLAG, &flag_len);
  auto device_type = bluetooth::hci::DeviceType::UNKNOWN;
  bool is_adv_connectable = event_type & (1 << BLE_EVT_CONNECTABLE_BIT);
  // 1. If adv is connectable and flag data is not present, device type is
  // DUAL mode.
  if (is_adv_connectable && p_flag == nullptr) {

  if (p_flag != NULL && flag_len != 0) {
    if ((BTM_BLE_BREDR_NOT_SPT & *p_flag) == 0) {
      device_type = bluetooth::hci::DeviceType::DUAL;
    }
  // 2. If adv is not connectable and flag data is not present, device type is
  // UNKNOWN.
  else if (!is_adv_connectable && p_flag == nullptr) {
    device_type = bluetooth::hci::DeviceType::UNKNOWN;
  }
  // 3. If flag data is present, use `BR/EDR Not Supported` bit to find device
  // type.
  else {
    device_type = (BTM_BLE_BREDR_NOT_SPT & *p_flag)
                      ? bluetooth::hci::DeviceType::LE
                      : bluetooth::hci::DeviceType::DUAL;
  }
  LOG_DEBUG(
      "%s event_type: %d, is_adv_connectable: %d, flag data: %d, device_type: "
      "%d",
      __func__, event_type, is_adv_connectable, (p_flag ? *p_flag : 0),
      device_type);
  }

  uint8_t remote_name_len;
  const uint8_t* p_eir_remote_name = AdvertiseDataParser::GetFieldByType(