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

Commit 38ed4e92 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

eatt: Adjust to new L2CAP API behaviour

There were a changes in the L2CAP layer which needs to be taken into
account by EATT.

L2CAP calls L2CA_DisconnectInd_Cb only when channel
has been disconnected by peer and there is also no confirmation on
L2CA_DisconnectReq.

Having above in mind, EATT needs to clear its channels list just
after calling L2CA_DisconnectReq() othwerwise state of EATT will
be incorrect.

Tag: #feature
Bug: 159786353
Sponsor: jpawlowski@
Test: atest --host net_test_eatt

Change-Id: I49949ca071f40abb9ca38dcd337b4de63f493f09
parent ec2ab990
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -588,8 +588,13 @@ struct eatt_impl {
    while (iter != eatt_dev->eatt_channels.end()) {
      uint16_t cid = iter->first;
      disconnect_channel(cid);
      iter++;
      /* When initiating disconnection, stack will not notify us that it is
       * done. We need to assume success
       */
      iter = eatt_dev->eatt_channels.erase(iter);
    }
    eatt_dev->eatt_tcb_->eatt = 0;
    eatt_dev->eatt_tcb_ = nullptr;
  }

  void connect(const RawAddress& bd_addr) {
+8 −5
Original line number Diff line number Diff line
@@ -100,14 +100,17 @@ class EattTest : public testing::Test {
    ASSERT_TRUE(test_tcb.eatt == num_of_accepted_connections);
  }

  void DisconnectEattByPeer(void) {
    for (uint16_t cid : connected_cids_)
      l2cap_app_info_.pL2CA_DisconnectInd_Cb(cid, true);
    ASSERT_TRUE(test_tcb.eatt == 0);
  }

  void DisconnectEattDevice(void) {
    EXPECT_CALL(l2cap_interface_, DisconnectRequest(_))
        .Times(connected_cids_.size());
    eatt_instance_->Disconnect(test_address);

    for (uint16_t cid : connected_cids_)
      l2cap_app_info_.pL2CA_DisconnectInd_Cb(cid, true);

    ASSERT_TRUE(test_tcb.eatt == 0);
  }

@@ -206,14 +209,14 @@ TEST_F(EattTest, ConnectFailedSlaveOnTheLink) {
}

TEST_F(EattTest, DisonnectByPeerSucceed) {
  ConnectDeviceEattSupported(1);
  ConnectDeviceEattSupported(2);

  uint16_t cid = connected_cids_[0];
  EattChannel* channel =
      eatt_instance_->FindEattChannelByCid(test_address, cid);
  ASSERT_TRUE(channel->state_ == EattChannelState::EATT_CHANNEL_OPENED);

  l2cap_app_info_.pL2CA_DisconnectInd_Cb(cid, true);
  DisconnectEattByPeer();

  channel = eatt_instance_->FindEattChannelByCid(test_address, cid);
  ASSERT_TRUE(channel == nullptr);