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

Commit b690f629 authored by Chris Manton's avatar Chris Manton
Browse files

gd: Plumb through security policy for service

Security policy gets checked to decide auth level

Bug: 140778599
Test: Compiles
Change-Id: I9fae4c0617f9d9826ed36a89e4d01f0d80f6ffa9
parent fd0ccbce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ bool DynamicChannelManager::RegisterService(Psm psm, DynamicChannelConfiguration
                                            OnConnectionOpenCallback on_connection_open, os::Handler* handler) {
  internal::DynamicChannelServiceImpl::PendingRegistration pending_registration{
      .user_handler_ = handler,
      .security_policy_ = security_policy,
      .on_registration_complete_callback_ = std::move(on_registration_complete),
      .on_connection_open_callback_ = std::move(on_connection_open),
      .configuration_ = configuration_option,
+9 −1
Original line number Diff line number Diff line
@@ -22,6 +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"

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

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

  SecurityPolicy GetSecurityPolicy() const {
    return security_policy_;
  }

  friend class DynamicChannelServiceManagerImpl;

 protected:
  // protected access for mocking
  DynamicChannelServiceImpl(os::Handler* user_handler,
                            SecurityPolicy security_policy,
                            DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback,
                            DynamicChannelConfigurationOption config_option)
      : user_handler_(user_handler), on_connection_open_callback_(std::move(on_connection_open_callback)),
      : 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_;
  DynamicChannelManager::OnConnectionOpenCallback on_connection_open_callback_;
  DynamicChannelConfigurationOption config_option_;
};
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ void DynamicChannelServiceManagerImpl::Register(Psm psm,
  } else {
    service_map_.try_emplace(psm,
                             DynamicChannelServiceImpl(pending_registration.user_handler_,
                                                       pending_registration.security_policy_,
                                                       std::move(pending_registration.on_connection_open_callback_),
                                                       pending_registration.configuration_));
    std::unique_ptr<DynamicChannelService> user_service(new DynamicChannelService(psm, this, l2cap_layer_handler_));