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

Commit 883af60d authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Make FixedChannel and Link aware of address type

Bug: 140938432
Bug: 142341141
Change-Id: I120179eef18f3ac59e32e9196f700e51c47d1a84
parent d9e79e20
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ namespace bluetooth {
namespace l2cap {
namespace le {

hci::Address FixedChannel::GetDevice() const {
hci::AddressWithType FixedChannel::GetDevice() const {
  return impl_->GetDevice();
}

+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ class FixedChannel {
    ASSERT(l2cap_handler_ != nullptr);
  }

  hci::Address GetDevice() const;
  hci::AddressWithType GetDevice() const;

  /**
   * Register close callback. If close callback is registered, when a channel is closed, the channel's resource will
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ namespace internal {
FixedChannelImpl::FixedChannelImpl(Cid cid, Link* link, os::Handler* l2cap_handler)
    : cid_(cid), device_(link->GetDevice()), link_(link), l2cap_handler_(l2cap_handler) {
  ASSERT_LOG(cid_ >= kFirstFixedChannel && cid_ <= kLastFixedChannel, "Invalid cid: %d", cid_);
  ASSERT(!device_.IsEmpty());
  ASSERT(!device_.GetAddress().IsEmpty());
  ASSERT(link_ != nullptr);
  ASSERT(l2cap_handler_ != nullptr);
}
+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class FixedChannelImpl {

  virtual ~FixedChannelImpl() = default;

  hci::Address GetDevice() const {
  hci::AddressWithType GetDevice() const {
    return device_;
  }

@@ -70,7 +70,7 @@ class FixedChannelImpl {
  // For logging purpose only
  const Cid cid_;
  // For logging purpose only
  const hci::Address device_;
  const hci::AddressWithType device_;
  // Needed to handle Acquire() and Release()
  Link* link_;
  os::Handler* l2cap_handler_;
+11 −9
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ namespace l2cap {
namespace le {
namespace internal {

using hci::Address;
using hci::AddressWithType;
using l2cap::internal::testing::MockParameterProvider;
using testing::MockLink;
using ::testing::Return;
@@ -61,7 +63,7 @@ class L2capLeFixedChannelImplTest : public ::testing::Test {
TEST_F(L2capLeFixedChannelImplTest, get_device) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);
  EXPECT_EQ(device, fixed_channel_impl.GetDevice());
@@ -70,7 +72,7 @@ TEST_F(L2capLeFixedChannelImplTest, get_device) {
TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

@@ -91,7 +93,7 @@ TEST_F(L2capLeFixedChannelImplTest, close_triggers_callback) {
TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_immediately) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

@@ -112,7 +114,7 @@ TEST_F(L2capLeFixedChannelImplTest, register_callback_after_close_should_call_im
TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

@@ -136,7 +138,7 @@ TEST_F(L2capLeFixedChannelImplTest, close_twice_should_fail) {
TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

@@ -156,7 +158,7 @@ TEST_F(L2capLeFixedChannelImplTest, multiple_registeration_should_fail) {
TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fail) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);
  EXPECT_DEATH(fixed_channel_impl.Acquire(), ".*Acquire.*");
@@ -165,7 +167,7 @@ TEST_F(L2capLeFixedChannelImplTest, call_acquire_before_registeration_should_fai
TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fail) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);
  EXPECT_DEATH(fixed_channel_impl.Release(), ".*Release.*");
@@ -174,7 +176,7 @@ TEST_F(L2capLeFixedChannelImplTest, call_release_before_registeration_should_fai
TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

@@ -202,7 +204,7 @@ TEST_F(L2capLeFixedChannelImplTest, test_acquire_release_channel) {
TEST_F(L2capLeFixedChannelImplTest, test_acquire_after_close) {
  MockParameterProvider mock_parameter_provider;
  MockLink mock_le_link(l2cap_handler_, &mock_parameter_provider);
  hci::Address device{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}};
  AddressWithType device{{{0x01, 0x02, 0x03, 0x04, 0x05, 0x06}}, hci::AddressType::PUBLIC_DEVICE_ADDRESS};
  EXPECT_CALL(mock_le_link, GetDevice()).WillRepeatedly(Return(device));
  FixedChannelImpl fixed_channel_impl(kSmpBrCid, &mock_le_link, l2cap_handler_);

Loading