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

Commit 06f0f469 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2CAP: Separate classic security policy and LE

Also, when allocating a fixed or dynamic channel, SecurityPolicy is not
needed

Test: cert/run --host
Change-Id: Icf345d3286b98eb9e20714c5332b548868ac6a55
parent 0215ff1b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ bool DynamicChannelManager::ConnectChannel(hci::Address device, DynamicChannelCo
}

bool DynamicChannelManager::RegisterService(Psm psm, DynamicChannelConfigurationOption configuration_option,
                                            const SecurityPolicy& security_policy,
                                            const classic::SecurityPolicy& security_policy,
                                            OnRegistrationCompleteCallback on_registration_complete,
                                            OnConnectionOpenCallback on_connection_open, os::Handler* handler) {
  internal::DynamicChannelServiceImpl::PendingRegistration pending_registration{
+1 −1
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@
#include "l2cap/classic/dynamic_channel.h"
#include "l2cap/classic/dynamic_channel_configuration_option.h"
#include "l2cap/classic/dynamic_channel_service.h"
#include "l2cap/classic/security_policy.h"
#include "l2cap/l2cap_packets.h"
#include "l2cap/psm.h"
#include "l2cap/security_policy.h"
#include "os/handler.h"

namespace bluetooth {
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ bool FixedChannelManager::ConnectServices(hci::Address device, OnConnectionFailu
  return true;
}

bool FixedChannelManager::RegisterService(Cid cid, const SecurityPolicy& security_policy,
bool FixedChannelManager::RegisterService(Cid cid, const classic::SecurityPolicy& security_policy,
                                          OnRegistrationCompleteCallback on_registration_complete,
                                          OnConnectionOpenCallback on_connection_open, os::Handler* handler) {
  internal::FixedChannelServiceImpl::PendingRegistration pending_registration{
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "l2cap/cid.h"
#include "l2cap/classic/fixed_channel.h"
#include "l2cap/classic/fixed_channel_service.h"
#include "l2cap/security_policy.h"
#include "l2cap/classic/security_policy.h"
#include "os/handler.h"

namespace bluetooth {
+7 −8
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@
#include "l2cap/classic/dynamic_channel_configuration_option.h"
#include "l2cap/classic/dynamic_channel_manager.h"
#include "l2cap/classic/dynamic_channel_service.h"
#include "l2cap/security_policy.h"
#include "l2cap/classic/security_policy.h"

namespace bluetooth {
namespace l2cap {
@@ -34,7 +34,7 @@ class DynamicChannelServiceImpl {

  struct PendingRegistration {
    os::Handler* user_handler_ = nullptr;
    SecurityPolicy security_policy_;
    classic::SecurityPolicy security_policy_;
    DynamicChannelManager::OnRegistrationCompleteCallback on_registration_complete_callback_;
    DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback_;
    DynamicChannelConfigurationOption configuration_;
@@ -48,7 +48,7 @@ class DynamicChannelServiceImpl {
    return config_option_;
  }

  SecurityPolicy GetSecurityPolicy() const {
  classic::SecurityPolicy GetSecurityPolicy() const {
    return security_policy_;
  }

@@ -56,16 +56,15 @@ class DynamicChannelServiceImpl {

 protected:
  // protected access for mocking
  DynamicChannelServiceImpl(os::Handler* user_handler,
                            SecurityPolicy security_policy,
  DynamicChannelServiceImpl(os::Handler* user_handler, classic::SecurityPolicy security_policy,
                            DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback,
                            DynamicChannelConfigurationOption config_option)
      : user_handler_(user_handler), security_policy_(security_policy), on_connection_open_callback_(std::move(on_connection_open_callback)),
        config_option_(config_option) {}
      : user_handler_(user_handler), security_policy_(security_policy),
        on_connection_open_callback_(std::move(on_connection_open_callback)), config_option_(config_option) {}

 private:
  os::Handler* user_handler_ = nullptr;
  SecurityPolicy security_policy_;
  classic::SecurityPolicy security_policy_;
  DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback_;
  DynamicChannelConfigurationOption config_option_;
};
Loading