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

Commit 41025a8e authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6950159 from 1abaf2f2 to sc-release

Change-Id: I39a7c479d1de94c82b66c0aee18da49ff38a6f29
parents 53c077bb 1abaf2f2
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -32,9 +32,9 @@ namespace hci {
const ModuleFactory LeAdvertisingManager::Factory = ModuleFactory([]() { return new LeAdvertisingManager(); });

enum class AdvertisingApiType {
  LE_4_0 = 1,
  LEGACY = 1,
  ANDROID_HCI = 2,
  LE_5_0 = 3,
  EXTENDED = 3,
};

struct Advertiser {
@@ -103,11 +103,11 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    }

    if (controller_->IsSupported(hci::OpCode::LE_SET_EXTENDED_ADVERTISING_PARAMETERS)) {
      advertising_api_type_ = AdvertisingApiType::LE_5_0;
      advertising_api_type_ = AdvertisingApiType::EXTENDED;
    } else if (controller_->IsSupported(hci::OpCode::LE_MULTI_ADVT)) {
      advertising_api_type_ = AdvertisingApiType::ANDROID_HCI;
    } else {
      advertising_api_type_ = AdvertisingApiType::LE_4_0;
      advertising_api_type_ = AdvertisingApiType::LEGACY;
    }
  }

@@ -184,7 +184,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      address_manager_registered = false;
      paused = false;
    }
    if (advertising_api_type_ == AdvertisingApiType::LE_5_0) {
    if (advertising_api_type_ == AdvertisingApiType::EXTENDED) {
      le_advertising_interface_->EnqueueCommand(
          hci::LeRemoveAdvertisingSetBuilder::Create(advertiser_id),
          module_handler_->BindOnce(impl::check_status<LeRemoveAdvertisingSetCompleteView>));
@@ -206,7 +206,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    }

    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetAdvertisingParametersBuilder::Create(
                config.interval_min,
@@ -276,7 +276,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
        curr_set.advertising_handle_ = id;
        enabled_sets_[id] = curr_set;
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        ExtendedAdvertisingConfig new_config = config;
        new_config.legacy_pdus = true;

@@ -299,7 +299,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      os::Handler* handler) {
    id_map_[id] = reg_id;

    if (advertising_api_type_ != AdvertisingApiType::LE_5_0) {
    if (advertising_api_type_ != AdvertisingApiType::EXTENDED) {
      create_advertiser(id, config, scan_callback, set_terminated_callback, handler);
      return;
    }
@@ -429,7 +429,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    // then the Controller will return the error code Command Disallowed (0x0C).
    // Thus, we should disable it before removing it.
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0):
      case (AdvertisingApiType::LEGACY):
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetAdvertisingEnableBuilder::Create(Enable::DISABLED),
            module_handler_->BindOnce(impl::check_status<LeSetAdvertisingEnableCompleteView>));
@@ -439,7 +439,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            hci::LeMultiAdvtSetEnableBuilder::Create(Enable::DISABLED, advertiser_id),
            module_handler_->BindOnce(impl::check_status<LeMultiAdvtCompleteView>));
        break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::DISABLED, enabled_vector),
            module_handler_->BindOnce(impl::check_status<LeSetExtendedAdvertisingEnableCompleteView>));
@@ -456,13 +456,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb

  void set_parameters(AdvertiserId advertiser_id, ExtendedAdvertisingConfig config) {
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        // sid must be in range 0x00 to 0x0F. Since no controller supports more than
        // 16 advertisers, it's safe to make sid equal to id.
        config.sid = advertiser_id % kAdvertisingSetIdMask;
@@ -539,13 +539,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb

  void set_data(AdvertiserId advertiser_id, bool set_scan_rsp, std::vector<GapData> data) {
    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        // TODO(b/149221472): Support fragmentation
        auto operation = Operation::COMPLETE_ADVERTISEMENT;
        auto fragment_preference = FragmentPreference::CONTROLLER_SHOULD_NOT;
@@ -575,13 +575,13 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
    Enable enable_value = enable ? Enable::ENABLED : Enable::DISABLED;

    switch (advertising_api_type_) {
      case (AdvertisingApiType::LE_4_0): {
      case (AdvertisingApiType::LEGACY): {
        // TODO
      } break;
      case (AdvertisingApiType::ANDROID_HCI): {
        // TODO
      } break;
      case (AdvertisingApiType::LE_5_0): {
      case (AdvertisingApiType::EXTENDED): {
        le_advertising_interface_->EnqueueCommand(
            hci::LeSetExtendedAdvertisingEnableBuilder::Create(enable_value, enabled_sets),
            module_handler_->BindOnceOn(
@@ -648,7 +648,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      }

      switch (advertising_api_type_) {
        case (AdvertisingApiType::LE_4_0): {
        case (AdvertisingApiType::LEGACY): {
          le_advertising_interface_->EnqueueCommand(
              hci::LeSetAdvertisingEnableBuilder::Create(Enable::DISABLED),
              module_handler_->BindOnceOn(
@@ -667,7 +667,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            }
          }
        } break;
        case (AdvertisingApiType::LE_5_0): {
        case (AdvertisingApiType::EXTENDED): {
          if (enabled_sets.size() != 0) {
            le_advertising_interface_->EnqueueCommand(
                hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::DISABLED, enabled_sets),
@@ -695,7 +695,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
      }

      switch (advertising_api_type_) {
        case (AdvertisingApiType::LE_4_0): {
        case (AdvertisingApiType::LEGACY): {
          le_advertising_interface_->EnqueueCommand(
              hci::LeSetAdvertisingEnableBuilder::Create(Enable::ENABLED),
              module_handler_->BindOnceOn(
@@ -714,7 +714,7 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
            }
          }
        } break;
        case (AdvertisingApiType::LE_5_0): {
        case (AdvertisingApiType::EXTENDED): {
          if (enabled_sets.size() != 0) {
            le_advertising_interface_->EnqueueCommand(
                hci::LeSetExtendedAdvertisingEnableBuilder::Create(Enable::ENABLED, enabled_sets),
+10 −10
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ constexpr uint16_t kDefaultLeScanInterval = 4800;
const ModuleFactory LeScanningManager::Factory = ModuleFactory([]() { return new LeScanningManager(); });

enum class ScanApiType {
  LE_4_0 = 1,
  LEGACY = 1,
  ANDROID_HCI = 2,
  LE_5_0 = 3,
  EXTENDED = 3,
};

struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback {
@@ -59,11 +59,11 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    le_scanning_interface_ = hci_layer_->GetLeScanningInterface(
        module_handler_->BindOn(this, &LeScanningManager::impl::handle_scan_results));
    if (controller_->IsSupported(OpCode::LE_SET_EXTENDED_SCAN_PARAMETERS)) {
      api_type_ = ScanApiType::LE_5_0;
      api_type_ = ScanApiType::EXTENDED;
    } else if (controller_->IsSupported(OpCode::LE_EXTENDED_SCAN_PARAMS)) {
      api_type_ = ScanApiType::ANDROID_HCI;
    } else {
      api_type_ = ScanApiType::LE_4_0;
      api_type_ = ScanApiType::LEGACY;
    }
    configure_scan();
  }
@@ -128,7 +128,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    uint8_t phys_in_use = 1;

    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(hci::LeSetExtendedScanParametersBuilder::Create(
                                                   own_address_type_, filter_policy_, phys_in_use, parameter_vector),
                                               module_handler_->BindOnce(impl::check_status));
@@ -140,7 +140,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
            module_handler_->BindOnce(impl::check_status));

        break;
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanParametersBuilder::Create(LeScanType::ACTIVE, interval_ms_, window_ms_, own_address_type_,
                                                    filter_policy_),
@@ -164,14 +164,14 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    }

    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetExtendedScanEnableBuilder::Create(Enable::ENABLED,
                                                        FilterDuplicates::DISABLED /* filter duplicates */, 0, 0),
            module_handler_->BindOnce(impl::check_status));
        break;
      case ScanApiType::ANDROID_HCI:
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanEnableBuilder::Create(Enable::ENABLED, Enable::DISABLED /* filter duplicates */),
            module_handler_->BindOnce(impl::check_status));
@@ -190,7 +190,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
    }
    registered_callback_->Handler()->Post(std::move(on_stopped));
    switch (api_type_) {
      case ScanApiType::LE_5_0:
      case ScanApiType::EXTENDED:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetExtendedScanEnableBuilder::Create(Enable::DISABLED,
                                                        FilterDuplicates::DISABLED /* filter duplicates */, 0, 0),
@@ -198,7 +198,7 @@ struct LeScanningManager::impl : public bluetooth::hci::LeAddressManagerCallback
        registered_callback_ = nullptr;
        break;
      case ScanApiType::ANDROID_HCI:
      case ScanApiType::LE_4_0:
      case ScanApiType::LEGACY:
        le_scanning_interface_->EnqueueCommand(
            hci::LeSetScanEnableBuilder::Create(Enable::DISABLED, Enable::DISABLED /* filter duplicates */),
            module_handler_->BindOnce(impl::check_status));
+4 −13
Original line number Diff line number Diff line
@@ -833,7 +833,6 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,
                                     uint8_t num_read_pages) {
  uint16_t handle = p_acl_cb->hci_handle;
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev_by_handle(handle);
  uint8_t page_idx;

  if (p_dev_rec == nullptr) {
    return;
@@ -841,17 +840,8 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,

  p_dev_rec->num_read_pages = num_read_pages;

  /* Move the pages to placeholder */
  for (page_idx = 0; page_idx < num_read_pages; page_idx++) {
    if (page_idx > HCI_EXT_FEATURES_PAGE_MAX) {
      LOG_WARN("Received more extended page features than allowed page=%d",
               page_idx);
      break;
    }
    memcpy(p_dev_rec->feature_pages[page_idx],
           p_acl_cb->peer_lmp_feature_pages[page_idx],
           HCI_FEATURE_BYTES_PER_PAGE);
  }
  p_dev_rec->remote_supports_hci_role_switch =
      HCI_SWITCH_SUPPORTED(p_acl_cb->peer_lmp_feature_pages[0]);

  if (!(p_dev_rec->sec_flags & BTM_SEC_NAME_KNOWN) ||
      p_dev_rec->is_originator) {
@@ -874,7 +864,7 @@ void btm_process_remote_ext_features(tACL_CONN* p_acl_cb,

  if (req_pend) {
    /* Request for remaining Security Features (if any) */
    l2cu_resubmit_pending_sec_req(&p_dev_rec->bd_addr);
    l2cu_resubmit_pending_sec_req(&p_acl_cb->remote_addr);
  }
}

@@ -2557,6 +2547,7 @@ void btm_ble_refresh_local_resolvable_private_addr(
 ******************************************************************************/
void btm_sec_set_peer_sec_caps(bool ssp_supported, bool sc_supported,
                               tBTM_SEC_DEV_REC* p_dev_rec) {
  p_dev_rec->remote_feature_received = true;
  if ((btm_cb.security_mode == BTM_SEC_MODE_SP ||
       btm_cb.security_mode == BTM_SEC_MODE_SC) &&
      ssp_supported) {
+2 −12
Original line number Diff line number Diff line
@@ -100,7 +100,6 @@ bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
  }

  p_dev_rec->num_read_pages = 0;
  memset(p_dev_rec->feature_pages, 0, sizeof(p_dev_rec->feature_pages));

  if (p_link_key) {
    VLOG(2) << __func__ << ": BDA: " << bd_addr;
@@ -274,21 +273,12 @@ bool btm_dev_support_role_switch(const RawAddress& bd_addr) {
    return false;
  }

  if (HCI_SWITCH_SUPPORTED(p_dev_rec->feature_pages[0])) {
  if (p_dev_rec->remote_supports_hci_role_switch) {
    BTM_TRACE_DEBUG("%s Peer controller supports role switch", __func__);
    return true;
  }

  /* If the feature field is all zero, we never received them */
  bool feature_empty = true;
  for (int xx = 0; xx < BD_FEATURES_LEN; xx++) {
    if (p_dev_rec->feature_pages[0][xx] != 0x00) {
      feature_empty = false; /* at least one is != 0 */
      break;
    }
  }

  if (feature_empty) {
  if (!p_dev_rec->remote_feature_received) {
    BTM_TRACE_DEBUG(
        "%s Unknown peer capabilities, assuming peer supports role switch",
        __func__);
+2 −12
Original line number Diff line number Diff line
@@ -701,8 +701,6 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
                                      uint8_t* p_pin) {
  tBTM_SEC_DEV_REC* p_dev_rec;
  tBTM_STATUS status;
  uint8_t* p_features;
  uint8_t ii;
  VLOG(1) << __func__ << " BDA: " << bd_addr;

  BTM_TRACE_DEBUG("%s: Transport used %d, bd_addr=%s", __func__, transport,
@@ -789,14 +787,6 @@ tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
    }
  }

  for (ii = 0; ii <= HCI_EXT_FEATURES_PAGE_MAX; ii++) {
    p_features = p_dev_rec->feature_pages[ii];
    BTM_TRACE_EVENT("  remote_features page[%1d] = %02x-%02x-%02x-%02x", ii,
                    p_features[0], p_features[1], p_features[2], p_features[3]);
    BTM_TRACE_EVENT("                              %02x-%02x-%02x-%02x",
                    p_features[4], p_features[5], p_features[6], p_features[7]);
  }

  BTM_TRACE_EVENT("BTM_SecBond: Remote sm4: 0x%x  HCI Handle: 0x%04x",
                  p_dev_rec->sm4, p_dev_rec->hci_handle);

@@ -2415,7 +2405,7 @@ void btm_io_capabilities_req(const RawAddress& p) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_or_alloc_dev(p);

  if ((btm_cb.security_mode == BTM_SEC_MODE_SC) &&
      (p_dev_rec->num_read_pages == 0)) {
      (!p_dev_rec->remote_feature_received)) {
    BTM_TRACE_EVENT("%s: Device security mode is SC only.",
                    "To continue need to know remote features.", __func__);

Loading