From 9747ba91a5d66262855663aa10847601a8688984 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Wed, 28 Oct 2020 13:00:12 -0700 Subject: [PATCH] L2cap: Route some functions to shim Tag: #gd-refactor Bug: 141555841 Test: cert/run --host Test: Pair and connect with a headset Change-Id: I6ce4c8a7f7e506f370b81e7919fd15f490068b56 --- stack/l2cap/l2c_api.cc | 11 ++++++++++- stack/l2cap/l2c_link.cc | 13 +++++++++++++ stack/l2cap/l2c_utils.cc | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/stack/l2cap/l2c_api.cc b/stack/l2cap/l2c_api.cc index e627b4cd6..a7163ceab 100644 --- a/stack/l2cap/l2c_api.cc +++ b/stack/l2cap/l2c_api.cc @@ -891,7 +891,12 @@ bool L2CA_DisconnectReq(uint16_t cid) { return (true); } -bool L2CA_DisconnectLECocReq(uint16_t cid) { return L2CA_DisconnectReq(cid); } +bool L2CA_DisconnectLECocReq(uint16_t cid) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + return bluetooth::shim::L2CA_DisconnectLECocReq(cid); + } + return L2CA_DisconnectReq(cid); +} bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { if (bluetooth::shim::is_gd_l2cap_enabled()) { @@ -1460,6 +1465,10 @@ uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { } uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + return bluetooth::shim::L2CA_LECocDataWrite(cid, p_data); + } + return L2CA_DataWrite(cid, p_data); } diff --git a/stack/l2cap/l2c_link.cc b/stack/l2cap/l2c_link.cc index dd0f95606..e3f736411 100644 --- a/stack/l2cap/l2c_link.cc +++ b/stack/l2cap/l2c_link.cc @@ -28,6 +28,8 @@ #include #include "device/include/controller.h" +#include "main/shim/l2c_api.h" +#include "main/shim/shim.h" #include "osi/include/log.h" #include "osi/include/osi.h" #include "stack/btm/btm_dev.h" @@ -124,6 +126,9 @@ void l2c_link_hci_conn_req(const RawAddress& bd_addr) { void l2c_link_hci_conn_comp(uint8_t status, uint16_t handle, const RawAddress& p_bda) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + return; + } tL2C_CONN_INFO ci; tL2C_LCB* p_lcb; tL2C_CCB* p_ccb; @@ -316,6 +321,11 @@ void l2c_link_sec_comp2(const RawAddress& p_bda, * ******************************************************************************/ bool l2c_link_hci_disc_comp(uint16_t handle, uint8_t reason) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + btm_acl_removed(handle); + return false; + } + tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle); tL2C_CCB* p_ccb; bool status = true; @@ -1137,6 +1147,9 @@ static void l2c_link_send_to_lower(tL2C_LCB* p_lcb, BT_HDR* p_buf) { * ******************************************************************************/ void l2c_link_process_num_completed_pkts(uint8_t* p, uint8_t evt_len) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + return; + } uint8_t num_handles, xx; uint16_t handle; uint16_t num_sent; diff --git a/stack/l2cap/l2c_utils.cc b/stack/l2cap/l2c_utils.cc index 95b566eae..74a1c6a0e 100644 --- a/stack/l2cap/l2c_utils.cc +++ b/stack/l2cap/l2c_utils.cc @@ -34,6 +34,7 @@ #include "hcidefs.h" #include "l2c_int.h" #include "l2cdefs.h" +#include "main/shim/l2c_api.h" #include "main/shim/shim.h" #include "osi/include/allocator.h" #include "osi/include/log.h" @@ -1476,6 +1477,10 @@ tL2C_CCB* l2cu_allocate_ccb(tL2C_LCB* p_lcb, uint16_t cid) { * ******************************************************************************/ bool l2cu_start_post_bond_timer(uint16_t handle) { + if (bluetooth::shim::is_gd_l2cap_enabled()) { + return true; + } + tL2C_LCB* p_lcb = l2cu_find_lcb_by_handle(handle); if (!p_lcb) return (true); -- 2.11.0