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

Commit d6f2ee13 authored by Rahul Arya's avatar Rahul Arya Committed by Automerger Merge Worker
Browse files

Merge "Add module to execute Remote Name Requests" am: 5dfd0a68 am: 7ce085e1 am: bc4f7d23

parents 8a33fafa bc4f7d23
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -61,21 +61,10 @@ class PyNeighbor(object):
        """
        return InquirySession(self.device, inquiry_msg)

    def _register_remote_host_supported_features_notification(self):
        """
        REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION event will be sent when a device sends remote name request
        """
        if self.remote_host_supported_features_notification_registered:
            return
        msg = hci_facade.EventRequest(code=int(hci.EventCode.REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION))
        self.device.hci.RequestEvent(msg)
        self.remote_host_supported_features_notification_registered = True

    def get_remote_name(self, remote_address: str):
        """
        Get the remote name and return a session which can be used for event queue assertion
        """
        self._register_remote_host_supported_features_notification()
        self.device.neighbor.ReadRemoteName(
            neighbor_facade.RemoteNameRequestMsg(address=remote_address.encode('utf8'),
                                                 page_scan_repetition_mode=1,
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ filegroup {
        "le_scanning_manager.cc",
        "link_key.cc",
        "msft.cc",
        "remote_name_request.cc",
        "uuid.cc",
        "vendor_specific_event_manager.cc",
    ],
@@ -52,6 +53,7 @@ filegroup {
        "hci_layer_test.cc",
        "hci_layer_unittest.cc",
        "hci_packets_test.cc",
        "remote_name_request_test.cc",
        "uuid_unittest.cc",
        "le_periodic_sync_manager_test.cc",
        "le_scanning_manager_test.cc",
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ source_set("BluetoothHciSources") {
    "le_scanning_manager.cc",
    "link_key.cc",
    "msft.cc",
    "remote_name_request.cc",
    "uuid.cc",
    "vendor_specific_event_manager.cc",
  ]
+21 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include "hci/acl_manager/round_robin_scheduler.h"
#include "hci/controller.h"
#include "hci/hci_layer.h"
#include "hci/remote_name_request.h"
#include "hci_acl_manager_generated.h"
#include "security/security_module.h"
#include "storage/storage_module.h"
@@ -65,11 +66,21 @@ struct AclManager::impl {
    round_robin_scheduler_ = new RoundRobinScheduler(handler_, controller_, hci_layer_->GetAclQueueEnd());
    acl_scheduler_ = acl_manager_.GetDependency<AclScheduler>();

    if (bluetooth::common::init_flags::gd_remote_name_request_is_enabled()) {
      remote_name_request_module_ = acl_manager_.GetDependency<RemoteNameRequestModule>();
    }

    bool crash_on_unknown_handle = false;
    {
      const std::lock_guard<std::mutex> lock(dumpsys_mutex_);
      classic_impl_ = new classic_impl(
          hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle, acl_scheduler_);
          hci_layer_,
          controller_,
          handler_,
          round_robin_scheduler_,
          crash_on_unknown_handle,
          acl_scheduler_,
          remote_name_request_module_);
      le_impl_ = new le_impl(hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle);
    }

@@ -126,6 +137,7 @@ struct AclManager::impl {
  classic_impl* classic_impl_ = nullptr;
  le_impl* le_impl_ = nullptr;
  AclScheduler* acl_scheduler_ = nullptr;
  RemoteNameRequestModule* remote_name_request_module_ = nullptr;
  os::Handler* handler_ = nullptr;
  Controller* controller_ = nullptr;
  HciLayer* hci_layer_ = nullptr;
@@ -140,8 +152,10 @@ AclManager::AclManager() : pimpl_(std::make_unique<impl>(*this)) {}

void AclManager::RegisterCallbacks(ConnectionCallbacks* callbacks, os::Handler* handler) {
  ASSERT(callbacks != nullptr && handler != nullptr);
  GetHandler()->Post(common::BindOnce(&classic_impl::handle_register_callbacks,
                                      common::Unretained(pimpl_->classic_impl_), common::Unretained(callbacks),
  GetHandler()->Post(common::BindOnce(
      &classic_impl::handle_register_callbacks,
      common::Unretained(pimpl_->classic_impl_),
      common::Unretained(callbacks),
      common::Unretained(handler)));
}

@@ -337,6 +351,9 @@ void AclManager::ListDependencies(ModuleList* list) const {
  list->add<Controller>();
  list->add<storage::StorageModule>();
  list->add<AclScheduler>();
  if (bluetooth::common::init_flags::gd_remote_name_request_is_enabled()) {
    list->add<RemoteNameRequestModule>();
  }
}

void AclManager::Start() {
+18 −5
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "hci/acl_manager/event_checkers.h"
#include "hci/acl_manager/round_robin_scheduler.h"
#include "hci/controller.h"
#include "hci/remote_name_request.h"
#include "os/metrics.h"
#include "security/security_manager_listener.h"
#include "security/security_module.h"
@@ -54,11 +55,13 @@ struct classic_impl : public security::ISecurityManagerListener {
      os::Handler* handler,
      RoundRobinScheduler* round_robin_scheduler,
      bool crash_on_unknown_handle,
      AclScheduler* acl_scheduler)
      AclScheduler* acl_scheduler,
      RemoteNameRequestModule* remote_name_request_module)
      : hci_layer_(hci_layer),
        controller_(controller),
        round_robin_scheduler_(round_robin_scheduler),
        acl_scheduler_(acl_scheduler) {
        acl_scheduler_(acl_scheduler),
        remote_name_request_module_(remote_name_request_module) {
    hci_layer_ = hci_layer;
    controller_ = controller;
    handler_ = handler;
@@ -421,16 +424,25 @@ struct classic_impl : public security::ISecurityManagerListener {
            Role::PERIPHERAL,
            Initiator::REMOTE_INITIATED),
        handler_->BindOnce(
            [=](AclScheduler* scheduler, Address address, ErrorCode status, std::string valid_incoming_addresses) {
            [=](RemoteNameRequestModule* remote_name_request_module,
                Address address,
                ErrorCode status,
                std::string valid_incoming_addresses) {
              ASSERT_LOG(
                  status == ErrorCode::UNKNOWN_CONNECTION,
                  "No prior connection request for %s expecting:%s",
                  address.ToString().c_str(),
                  valid_incoming_addresses.c_str());
              LOG_WARN("No matching connection to %s (%s)", address.ToString().c_str(), ErrorCodeText(status).c_str());
              LOG_WARN("Firmware error after RemoteNameRequestCancel?");
              LOG_WARN("Firmware error after RemoteNameRequestCancel?");  // see b/184239841
              if (bluetooth::common::init_flags::gd_remote_name_request_is_enabled()) {
                ASSERT_LOG(
                    remote_name_request_module != nullptr,
                    "RNR module enabled but module not provided");
                remote_name_request_module->ReportRemoteNameRequestCancellation(address);
              }
            },
            common::Unretained(acl_scheduler_),
            common::Unretained(remote_name_request_module_),
            address,
            status));
  }
@@ -795,6 +807,7 @@ struct classic_impl : public security::ISecurityManagerListener {
  Controller* controller_ = nullptr;
  RoundRobinScheduler* round_robin_scheduler_ = nullptr;
  AclScheduler* acl_scheduler_ = nullptr;
  RemoteNameRequestModule* remote_name_request_module_ = nullptr;
  AclConnectionInterface* acl_connection_interface_ = nullptr;
  os::Handler* handler_ = nullptr;
  ConnectionCallbacks* client_callbacks_ = nullptr;
Loading