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

Commit 069082cb authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap shim: Add role switch

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I7fd643ca263e47a4d1f28ee87c72622774c61469
parent ce0c4f7a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -837,3 +837,8 @@ uint8_t bluetooth::shim::L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) {
             MakeUniquePacket(data, len)) *
         len;
}

void bluetooth::shim::L2CA_SwitchRoleToCentral(const RawAddress& addr) {
  bluetooth::shim::GetAclManager()->SwitchRole(ToGdAddress(addr),
                                               bluetooth::hci::Role::CENTRAL);
}
+1 −0
Original line number Diff line number Diff line
@@ -515,5 +515,6 @@ void L2CA_SetBondingState(const RawAddress& p_bd_addr, bool is_bonding);
// Indicated by shim stack manager that GD L2cap is enabled but Security is not
void L2CA_UseLegacySecurityModule();

void L2CA_SwitchRoleToCentral(const RawAddress& addr);
}  // namespace shim
}  // namespace bluetooth
+5 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include "include/l2cap_hci_link_interface.h"
#include "main/shim/acl_api.h"
#include "main/shim/btm_api.h"
#include "main/shim/l2c_api.h"
#include "main/shim/shim.h"
#include "osi/include/log.h"
#include "stack/acl/acl.h"
@@ -468,6 +469,10 @@ tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, uint8_t* p_role) {
 *
 ******************************************************************************/
tBTM_STATUS BTM_SwitchRoleToCentral(const RawAddress& remote_bd_addr) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    bluetooth::shim::L2CA_SwitchRoleToCentral(remote_bd_addr);
    return BTM_SUCCESS;
  }
  if (!controller_get_interface()->supports_central_peripheral_role_switch()) {
    LOG_INFO("Local controller does not support role switching");
    return BTM_MODE_UNSUPPORTED;