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

Commit 16509bb4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Move ISecurityManagerListener out of internal namespace"

parents dbdc1326 803e36e0
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22,10 +22,12 @@

#include "os/log.h"
#include "security/pairing/classic_pairing_handler.h"
#include "security/security_manager.h"

using namespace bluetooth::security::internal;
using bluetooth::hci::Device;
using bluetooth::hci::DeviceType;
using bluetooth::security::ISecurityManagerListener;
using bluetooth::security::pairing::PairingHandler;

namespace {
+2 −35
Original line number Diff line number Diff line
@@ -24,43 +24,10 @@

namespace bluetooth {
namespace security {
namespace internal {

/**
 * Interface for listening to the channel for SMP commands.
 */
class ISecurityManagerListener {
 public:
  ISecurityManagerListener(os::Handler* handler) : handler_(handler) {}
  virtual ~ISecurityManagerListener() = default;

  /**
   * Called when a device is successfully bonded.
   *
   * @param device pointer to the bonded device
   */
  virtual void OnDeviceBonded(std::shared_ptr<bluetooth::hci::Device> device);
class ISecurityManagerListener;

  /**
   * Called when a device is successfully un-bonded.
   *
   * @param device pointer to the device that is no longer bonded
   */
  virtual void OnDeviceUnbonded(std::shared_ptr<bluetooth::hci::Device> device);

  /**
   * Called as a result of a failure during the bonding process.
   *
   * @param device pointer to the device that is no longer bonded
   */
  virtual void OnDeviceBondFailed(std::shared_ptr<bluetooth::hci::Device> device);

  bool operator==(const ISecurityManagerListener& rhs) const {
    return &*this == &rhs;
  }

  os::Handler* handler_ = nullptr;
};
namespace internal {

class SecurityManagerImpl /*: public channel::ISecurityManagerChannelListener*/ {
 public:
+4 −4
Original line number Diff line number Diff line
@@ -44,14 +44,14 @@ void SecurityManager::RemoveBond(std::shared_ptr<hci::ClassicDevice> device) {
                                           std::forward<std::shared_ptr<hci::ClassicDevice>>(device)));
}

void SecurityManager::RegisterCallbackListener(internal::ISecurityManagerListener* listener) {
void SecurityManager::RegisterCallbackListener(ISecurityManagerListener* listener) {
  security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::RegisterCallbackListener,
                                           common::Unretained(security_manager_impl_),
                                           std::forward<internal::ISecurityManagerListener*>(listener)));
                                           std::forward<ISecurityManagerListener*>(listener)));
}

void SecurityManager::UnregisterCallbackListener(internal::ISecurityManagerListener* listener) {
void SecurityManager::UnregisterCallbackListener(ISecurityManagerListener* listener) {
  security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::UnregisterCallbackListener,
                                           common::Unretained(security_manager_impl_),
                                           std::forward<internal::ISecurityManagerListener*>(listener)));
                                           std::forward<ISecurityManagerListener*>(listener)));
}
+38 −2
Original line number Diff line number Diff line
@@ -28,6 +28,42 @@
namespace bluetooth {
namespace security {

/**
 * Callback interface from SecurityManager.
 */
class ISecurityManagerListener {
 public:
  ISecurityManagerListener(os::Handler* handler) : handler_(handler) {}
  virtual ~ISecurityManagerListener() = default;

  /**
   * Called when a device is successfully bonded.
   *
   * @param device pointer to the bonded device
   */
  virtual void OnDeviceBonded(std::shared_ptr<bluetooth::hci::Device> device);

  /**
   * Called when a device is successfully un-bonded.
   *
   * @param device pointer to the device that is no longer bonded
   */
  virtual void OnDeviceUnbonded(std::shared_ptr<bluetooth::hci::Device> device);

  /**
   * Called as a result of a failure during the bonding process.
   *
   * @param device pointer to the device that is no longer bonded
   */
  virtual void OnDeviceBondFailed(std::shared_ptr<bluetooth::hci::Device> device);

  bool operator==(const ISecurityManagerListener& rhs) const {
    return &*this == &rhs;
  }

  os::Handler* handler_ = nullptr;
};

/**
 * Manages the security attributes, pairing, bonding of devices, and the
 * encryption/decryption of communications.
@@ -67,14 +103,14 @@ class SecurityManager {
   *
   * @param listener ISecurityManagerListener instance to handle callbacks
   */
  void RegisterCallbackListener(internal::ISecurityManagerListener* listener);
  void RegisterCallbackListener(ISecurityManagerListener* listener);

  /**
   * Unregister listener for callback events from SecurityManager
   *
   * @param listener ISecurityManagerListener instance to unregister
   */
  void UnregisterCallbackListener(internal::ISecurityManagerListener* listener);
  void UnregisterCallbackListener(ISecurityManagerListener* listener);

 protected:
  SecurityManager(os::Handler* security_handler, internal::SecurityManagerImpl* security_manager_impl)