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

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

Merge "Implement GetRemoteCid for the l2cap shim"

parents 4f352c35 7c8751de
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -38,5 +38,9 @@ common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLitt
DynamicChannel::GetQueueUpEnd() const {
  return impl_->GetQueueUpEnd();
}

Cid DynamicChannel::HACK_GetRemoteCid() {
  return impl_->GetRemoteCid();
}
}  // namespace l2cap
}  // namespace bluetooth
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "common/bidi_queue.h"
#include "common/callback.h"
#include "hci/acl_manager.h"
#include "l2cap/cid.h"
#include "os/handler.h"
#include "packet/base_packet_builder.h"
#include "packet/packet_view.h"
@@ -69,6 +70,8 @@ class DynamicChannel {
   */
  common::BidiQueueEnd<packet::BasePacketBuilder, packet::PacketView<packet::kLittleEndian>>* GetQueueUpEnd() const;

  Cid HACK_GetRemoteCid();

 private:
  std::shared_ptr<l2cap::internal::DynamicChannelImpl> impl_;
  os::Handler* l2cap_handler_;
+16 −5
Original line number Diff line number Diff line
@@ -204,16 +204,25 @@ class ConnectionInterfaceManager {
    return cid_to_interface_map_.size();
  }

  void ConnectionOpened(ConnectionCompleteCallback on_complete, l2cap::Psm psm, ConnectionInterfaceDescriptor cid) {
  void ConnectionOpened(
      ConnectionCompleteCallback on_complete,
      l2cap::Psm psm,
      ConnectionInterfaceDescriptor cid,
      l2cap::Cid remote_cid) {
    hci::Address address = cid_to_interface_map_[cid]->GetRemoteAddress();
    LOG_DEBUG("Connection opened address:%s psm:%hd cid:%hd", address.ToString().c_str(), psm, cid);
    on_complete(address.ToString(), static_cast<uint16_t>(psm), static_cast<uint16_t>(cid), kConnectionOpened);
    on_complete(
        address.ToString(),
        static_cast<uint16_t>(psm),
        static_cast<uint16_t>(cid),
        static_cast<uint16_t>(remote_cid),
        kConnectionOpened);
  }

  void ConnectionFailed(
      ConnectionCompleteCallback on_complete, hci::Address address, l2cap::Psm psm, ConnectionInterfaceDescriptor cid) {
    LOG_DEBUG("Connection failed address:%s psm:%hd", address.ToString().c_str(), psm);
    on_complete(address.ToString(), static_cast<uint16_t>(psm), static_cast<uint16_t>(cid), kConnectionFailed);
    on_complete(address.ToString(), static_cast<uint16_t>(psm), static_cast<uint16_t>(cid), 0, kConnectionFailed);
  }

  ConnectionInterfaceManager(os::Handler* handler);
@@ -493,8 +502,9 @@ void L2cap::impl::RegisterService(
            LOG_DEBUG("Remote initiated connection is open from device:%s", channel->GetDevice().ToString().c_str());

            ConnectionInterfaceDescriptor cid = connection_interface_manager_->AllocateConnectionInterfaceDescriptor();
            uint16_t remote_cid = channel->HACK_GetRemoteCid();
            connection_interface_manager_->AddConnection(cid, std::move(channel));
            connection_interface_manager_->ConnectionOpened(on_complete, psm, cid);
            connection_interface_manager_->ConnectionOpened(on_complete, psm, cid, remote_cid);
            LOG_DEBUG("connection open");
          },
          psm,
@@ -522,9 +532,10 @@ void L2cap::impl::PendingConnectionOpen(
    PendingConnectionId id,
    std::unique_ptr<PendingConnection> connection,
    std::unique_ptr<l2cap::classic::DynamicChannel> channel) {
  uint16_t remote_cid = channel->HACK_GetRemoteCid();
  connection_interface_manager_.AddConnection(connection->cid_, std::move(channel));
  connection_interface_manager_.ConnectionOpened(
      std::move(connection->on_complete_), connection->psm_, connection->cid_);
      std::move(connection->on_complete_), connection->psm_, connection->cid_, remote_cid);
  pending_connection_map_.erase(id);
}

+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace shim {

using ConnectionClosedCallback = std::function<void(uint16_t cid, int error_code)>;
using ConnectionCompleteCallback =
    std::function<void(std::string string_address, uint16_t psm, uint16_t cid, bool is_connected)>;
    std::function<void(std::string string_address, uint16_t psm, uint16_t cid, uint16_t remote_cid, bool is_connected)>;
using ReadDataReadyCallback = std::function<void(uint16_t cid, std::vector<const uint8_t> data)>;

using RegisterServicePromise = std::promise<uint16_t>;
+1 −2
Original line number Diff line number Diff line
@@ -263,8 +263,7 @@ bool bluetooth::shim::L2CA_RemoveFixedChnl(uint16_t fixed_cid,
 * Channel hygiene APIs
 */
bool bluetooth::shim::L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
  LOG_INFO("UNIMPLEMENTED %s", __func__);
  return false;
  return shim_l2cap.GetRemoteCid(lcid, rcid);
}

bool bluetooth::shim::L2CA_SetIdleTimeout(uint16_t cid, uint16_t timeout,
Loading