From: Hansong Zhang Date: Thu, 5 Nov 2020 23:35:45 +0000 (-0800) Subject: L2cap shim: Add role switch X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=505b823e81eb7079645ce604e9864f498f1274c5;p=android-x86%2Fsystem-bt.git L2cap shim: Add role switch Bug: 159815595 Tag: #refactor Test: compile & verify basic functions working Change-Id: I7fd643ca263e47a4d1f28ee87c72622774c61469 --- diff --git a/main/shim/l2c_api.cc b/main/shim/l2c_api.cc index 638cd7d5d..60191b9c5 100644 --- a/main/shim/l2c_api.cc +++ b/main/shim/l2c_api.cc @@ -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); +} diff --git a/main/shim/l2c_api.h b/main/shim/l2c_api.h index 6971e291d..a13854ebd 100644 --- a/main/shim/l2c_api.h +++ b/main/shim/l2c_api.h @@ -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 diff --git a/stack/acl/btm_acl.cc b/stack/acl/btm_acl.cc index 28ebf3f0f..bc1944a24 100644 --- a/stack/acl/btm_acl.cc +++ b/stack/acl/btm_acl.cc @@ -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;