OSDN Git Service

L2cap: Route some functions to shim
authorHansong Zhang <hsz@google.com>
Wed, 28 Oct 2020 20:00:12 +0000 (13:00 -0700)
committerHansong Zhang <hsz@google.com>
Fri, 6 Nov 2020 19:07:58 +0000 (11:07 -0800)
Tag: #gd-refactor
Bug: 141555841
Test: cert/run --host
Test: Pair and connect with a headset
Change-Id: I6ce4c8a7f7e506f370b81e7919fd15f490068b56

stack/l2cap/l2c_api.cc
stack/l2cap/l2c_link.cc
stack/l2cap/l2c_utils.cc

index e627b4c..a7163ce 100644 (file)
@@ -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);
 }
 
index dd0f956..e3f7364 100644 (file)
@@ -28,6 +28,8 @@
 #include <cstdint>
 
 #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;
index 95b566e..74a1c6a 100644 (file)
@@ -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);