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

Commit 089b49b1 authored by Rahul Arya's avatar Rahul Arya Committed by Gerrit Code Review
Browse files

Merge "Add Remote Name Request shim"

parents e325b0a0 da5152ab
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -22,11 +22,16 @@
#include <optional>

#include "gd/hci/acl_manager.h"
#include "gd/hci/remote_name_request.h"
#include "main/shim/dumpsys.h"
#include "main/shim/entry.h"
#include "main/shim/helpers.h"
#include "main/shim/stack.h"
#include "osi/include/allocator.h"
#include "stack/btm/btm_sec.h"
#include "stack/btm/security_device_record.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/inq_hci_link_interface.h"
#include "types/ble_address_with_type.h"
#include "types/raw_address.h"

@@ -152,3 +157,55 @@ void bluetooth::shim::ACL_LeSubrateRequest(
  Stack::GetInstance()->GetAcl()->LeSubrateRequest(
      hci_handle, subrate_min, subrate_max, max_latency, cont_num, sup_tout);
}

void bluetooth::shim::ACL_RemoteNameRequest(const RawAddress& addr,
                                            uint8_t page_scan_rep_mode,
                                            uint8_t page_scan_mode,
                                            uint16_t clock_offset) {
  bluetooth::shim::GetRemoteNameRequest()->StartRemoteNameRequest(
      ToGdAddress(addr),
      hci::RemoteNameRequestBuilder::Create(
          ToGdAddress(addr), hci::PageScanRepetitionMode(page_scan_rep_mode),
          clock_offset & (~BTM_CLOCK_OFFSET_VALID),
          (clock_offset & BTM_CLOCK_OFFSET_VALID)
              ? hci::ClockOffsetValid::VALID
              : hci::ClockOffsetValid::INVALID),
      GetGdShimHandler()->BindOnce([](hci::ErrorCode status) {
        if (status != hci::ErrorCode::SUCCESS) {
          btm_process_remote_name(nullptr, nullptr, 0,
                                  static_cast<tHCI_STATUS>(status));
          btm_sec_rmt_name_request_complete(nullptr, nullptr,
                                            static_cast<tHCI_STATUS>(status));
        }
      }),
      GetGdShimHandler()->BindOnce(
          [](RawAddress addr, uint64_t features) {
            static_assert(sizeof(features) == 8);
            auto addr_array = addr.ToArray();
            auto p = (uint8_t*)osi_malloc(addr_array.size() + sizeof(features));
            std::copy(addr_array.begin(), addr_array.end(), p);
            for (int i = 0; i != sizeof(features); ++i) {
              p[addr_array.size() + i] = features & ((1 << 8) - 1);
              features >>= 8;
            }
            btm_sec_rmt_host_support_feat_evt(p);
          },
          addr),
      GetGdShimHandler()->BindOnce(
          [](RawAddress addr, hci::ErrorCode status,
             std::array<uint8_t, 248> name) {
            auto p = (uint8_t*)osi_malloc(name.size());
            std::copy(name.begin(), name.end(), p);

            btm_process_remote_name(&addr, p, name.size(),
                                    static_cast<tHCI_STATUS>(status));
            btm_sec_rmt_name_request_complete(&addr, p,
                                              static_cast<tHCI_STATUS>(status));
          },
          addr));
}

void bluetooth::shim::ACL_CancelRemoteNameRequest(const RawAddress& addr) {
  bluetooth::shim::GetRemoteNameRequest()->CancelRemoteNameRequest(
      ToGdAddress(addr));
}
+5 −0
Original line number Diff line number Diff line
@@ -60,5 +60,10 @@ void ACL_LeSubrateRequest(uint16_t hci_handle, uint16_t subrate_min,
                          uint16_t subrate_max, uint16_t max_latency,
                          uint16_t cont_num, uint16_t sup_tout);

void ACL_RemoteNameRequest(const RawAddress& bd_addr,
                           uint8_t page_scan_rep_mode, uint8_t page_scan_mode,
                           uint16_t clock_offset);
void ACL_CancelRemoteNameRequest(const RawAddress& addr);

}  // namespace shim
}  // namespace bluetooth
+7 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "gd/hci/le_advertising_manager.h"
#include "gd/hci/le_scanning_manager.h"
#include "gd/hci/msft.h"
#include "gd/hci/remote_name_request.h"
#include "gd/hci/vendor_specific_event_manager.h"
#include "gd/metrics/counter_metrics.h"
#include "gd/neighbor/connectability.h"
@@ -97,6 +98,12 @@ neighbor::PageModule* GetPage() {
      ->GetInstance<neighbor::PageModule>();
}

hci::RemoteNameRequestModule* GetRemoteNameRequest() {
  return Stack::GetInstance()
      ->GetStackManager()
      ->GetInstance<hci::RemoteNameRequestModule>();
}

hci::LeScanningManager* GetScanning() {
  return Stack::GetInstance()
      ->GetStackManager()
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ namespace hci {
class Controller;
class HciLayer;
class AclManager;
class RemoteNameRequestModule;
class LeAdvertisingManager;
class LeScanningManager;
class VendorSpecificEventManager;
@@ -94,6 +95,7 @@ hci::HciLayer* GetHciLayer();
l2cap::classic::L2capClassicModule* GetL2capClassicModule();
l2cap::le::L2capLeModule* GetL2capLeModule();
neighbor::PageModule* GetPage();
hci::RemoteNameRequestModule* GetRemoteNameRequest();
hci::LeScanningManager* GetScanning();
bluetooth::security::SecurityModule* GetSecurityModule();
hal::SnoopLogger* GetSnoopLogger();
+4 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "gd/hci/le_advertising_manager.h"
#include "gd/hci/le_scanning_manager.h"
#include "gd/hci/msft.h"
#include "gd/hci/remote_name_request.h"
#include "gd/hci/vendor_specific_event_manager.h"
#include "gd/l2cap/classic/l2cap_classic_module.h"
#include "gd/l2cap/le/l2cap_le_module.h"
@@ -149,6 +150,9 @@ void Stack::StartEverything() {
  modules.add<hci::Controller>();
  modules.add<hci::acl_manager::AclScheduler>();
  modules.add<hci::AclManager>();
  if (common::init_flags::gd_remote_name_request_is_enabled()) {
    modules.add<hci::RemoteNameRequestModule>();
  }
  if (common::init_flags::gd_l2cap_is_enabled()) {
    modules.add<l2cap::classic::L2capClassicModule>();
    modules.add<l2cap::le::L2capLeModule>();
Loading