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

Commit 9ad8350d authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap LE: Read remote version on connection

Needed by SMP

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I565b107b688788cc720b8531855dc4dd701ad188
parent faac56c1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ class MockLeAclConnection : public LeAclConnection {
  MOCK_METHOD(AddressWithType, GetRemoteAddress, (), (const, override));
  MOCK_METHOD(void, Disconnect, (DisconnectReason reason), (override));
  MOCK_METHOD(void, RegisterCallbacks, (LeConnectionManagementCallbacks * callbacks, os::Handler* handler), (override));
  MOCK_METHOD(bool, ReadRemoteVersionInformation, (), (override));

  QueueUpEnd* GetAclQueueEnd() const override {
    return acl_queue_.GetUpEnd();
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ void Link::OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_
void Link::OnReadRemoteVersionInformationComplete(
    uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
  LOG_INFO("lmp_version:%hhu manufacturer_name:%hu sub_version:%hu", lmp_version, manufacturer_name, sub_version);
  link_manager_->OnReadRemoteVersionInformationComplete(GetDevice(), lmp_version, manufacturer_name, sub_version);
}

void Link::OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) {}
@@ -269,6 +270,10 @@ void Link::SendLeCredit(Cid local_cid, uint16_t credit) {
  signalling_manager_.SendCredit(local_cid, credit);
}

void Link::ReadRemoteVersionInformation() {
  acl_connection_->ReadRemoteVersionInformation();
}

void Link::on_connection_update_complete(SignalId signal_id, hci::ErrorCode error_code) {
  if (!signal_id.IsValid()) {
    LOG_INFO("Invalid signal_id");
+2 −0
Original line number Diff line number Diff line
@@ -140,6 +140,8 @@ class Link : public l2cap::internal::ILink, public hci::acl_manager::LeConnectio
    return &link_options_;
  }

  void ReadRemoteVersionInformation();

 private:
  os::Handler* l2cap_handler_;
  l2cap::internal::FixedChannelAllocator<FixedChannelImpl, Link> fixed_channel_allocator_{this, l2cap_handler_};
+15 −0
Original line number Diff line number Diff line
@@ -138,6 +138,8 @@ void LinkManager::OnLeConnectSuccess(hci::AddressWithType connecting_address_wit

  // Remove device from pending links list, if any
  pending_links_.erase(connecting_address_with_type);

  link->ReadRemoteVersionInformation();
}

void LinkManager::OnLeConnectFail(hci::AddressWithType address_with_type, hci::ErrorCode reason) {
@@ -185,6 +187,19 @@ void LinkManager::RegisterLinkPropertyListener(os::Handler* handler, LinkPropert
  link_property_listener_ = listener;
}

void LinkManager::OnReadRemoteVersionInformationComplete(
    hci::AddressWithType address_with_type, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
  if (link_property_callback_handler_ != nullptr) {
    link_property_callback_handler_->CallOn(
        link_property_listener_,
        &LinkPropertyListener::OnReadRemoteVersionInformation,
        address_with_type,
        lmp_version,
        manufacturer_name,
        sub_version);
  }
}

}  // namespace internal
}  // namespace le
}  // namespace l2cap
+3 −0
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@ class LinkManager : public hci::acl_manager::LeConnectionCallbacks {

  void RegisterLinkPropertyListener(os::Handler* handler, LinkPropertyListener* listener);

  void OnReadRemoteVersionInformationComplete(
      hci::AddressWithType address_with_type, uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version);

 private:
  // Dependencies
  os::Handler* l2cap_handler_;
Loading