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

Commit 42582a54 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap classic shim: Use new helper

Fixes to the new shim, including thread sync, shim redirection in ACL
shim, security level settings.

Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Test: Pair and connect with a headset
Change-Id: Ia66a968b545eed843552d1ee9953adf1f9f57c9d
parent b3ad9c1a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ void DynamicChannelAllocator::FreeChannel(Cid cid) {
  used_cid_.erase(cid);
  auto channel = FindChannelByCid(cid);
  if (channel == nullptr) {
    LOG_INFO("Channel is not in use: psm %d, device %s", cid, link_->GetDevice().ToString().c_str());
    LOG_INFO("Channel is not in use: cid %d, device %s", cid, link_->GetDevice().ToString().c_str());
    return;
  }
  used_remote_cid_.erase(channel->GetRemoteCid());
+201 −118

File changed.

Preview size limit exceeded, changes collapsed.

+6 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ namespace shim {
 ******************************************************************************/
uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
                       bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
                       uint16_t my_mtu, uint16_t required_remote_mtu);
                       uint16_t my_mtu, uint16_t required_remote_mtu,
                       uint16_t sec_level);

/*******************************************************************************
 *
@@ -508,5 +509,9 @@ void L2CA_SwitchRoleToCentral(const RawAddress& addr);
bool L2CA_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version,
                            uint16_t* manufacturer, uint16_t* lmp_sub_version);

void L2CA_DisconnectLink(const RawAddress& remote);

uint16_t L2CA_GetNumLinks();

}  // namespace shim
}  // namespace bluetooth
+18 −0
Original line number Diff line number Diff line
@@ -1126,11 +1126,19 @@ tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,

bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,
                           tBT_TRANSPORT transport) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_IsLinkEstablished(remote_bda, transport);
  }

  return internal_.btm_bda_to_acl(remote_bda, transport) != nullptr;
}

bool BTM_IsAclConnectionUpAndHandleValid(const RawAddress& remote_bda,
                                         tBT_TRANSPORT transport) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_IsLinkEstablished(remote_bda, transport);
  }

  tACL_CONN* p_acl = internal_.btm_bda_to_acl(remote_bda, transport);
  if (p_acl == nullptr) {
    LOG_WARN("Unable to find active acl");
@@ -1154,6 +1162,9 @@ bool BTM_IsAclConnectionUpFromHandle(uint16_t hci_handle) {
 *
 ******************************************************************************/
uint16_t BTM_GetNumAclLinks(void) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_GetNumLinks();
  }
  uint16_t num_acl = 0;

  for (uint16_t i = 0; i < MAX_L2CAP_LINKS; ++i) {
@@ -2081,6 +2092,13 @@ void btm_read_link_quality_complete(uint8_t* p) {
 *
 ******************************************************************************/
tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr, tBT_TRANSPORT transport) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    if (transport == BT_TRANSPORT_LE) {
      LOG(ERROR) << __func__ << ": Unsupported";
    }
    bluetooth::shim::L2CA_DisconnectLink(bd_addr);
    return BTM_SUCCESS;
  }
  uint16_t hci_handle = BTM_GetHCIConnHandle(bd_addr, transport);
  tBTM_STATUS status = BTM_SUCCESS;
  tACL_CONN* p_acl = internal_.btm_bda_to_acl(bd_addr, transport);
+2 −1
Original line number Diff line number Diff line
@@ -339,7 +339,8 @@ uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
 ******************************************************************************/
extern uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info,
                              bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info,
                              uint16_t my_mtu, uint16_t required_remote_mtu);
                              uint16_t my_mtu, uint16_t required_remote_mtu,
                              uint16_t sec_level);

/*******************************************************************************
 *
Loading