• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2018 The Android Open Source Project
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 #include "mock_l2cap_layer.h"
19 
20 static bluetooth::l2cap::MockL2capInterface* l2cap_interface = nullptr;
21 
SetMockInterface(MockL2capInterface * mock_l2cap_interface)22 void bluetooth::l2cap::SetMockInterface(
23     MockL2capInterface* mock_l2cap_interface) {
24   l2cap_interface = mock_l2cap_interface;
25 }
26 
L2CA_Register(uint16_t psm,tL2CAP_APPL_INFO * p_cb_info,bool enable_snoop)27 uint16_t L2CA_Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
28                        bool enable_snoop) {
29   VLOG(1) << __func__ << ": psm=" << psm << ", p_cb_info=" << p_cb_info
30           << ", enable_snoop=" << enable_snoop;
31   return l2cap_interface->Register(psm, p_cb_info, enable_snoop);
32 }
33 
L2CA_ConnectReq(uint16_t psm,const RawAddress & bd_addr)34 uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& bd_addr) {
35   return l2cap_interface->ConnectRequest(psm, bd_addr);
36 }
37 
L2CA_ConnectRsp(const RawAddress & bd_addr,uint8_t id,uint16_t lcid,uint16_t result,uint16_t status)38 bool L2CA_ConnectRsp(const RawAddress& bd_addr, uint8_t id, uint16_t lcid,
39                      uint16_t result, uint16_t status) {
40   return l2cap_interface->ConnectResponse(bd_addr, id, lcid, result, status);
41 }
42 
L2CA_DisconnectReq(uint16_t cid)43 bool L2CA_DisconnectReq(uint16_t cid) {
44   return l2cap_interface->DisconnectRequest(cid);
45 }
46 
L2CA_DisconnectRsp(uint16_t cid)47 bool L2CA_DisconnectRsp(uint16_t cid) {
48   return l2cap_interface->DisconnectResponse(cid);
49 }
50 
L2CA_ConfigReq(uint16_t cid,tL2CAP_CFG_INFO * p_cfg)51 bool L2CA_ConfigReq(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) {
52   return l2cap_interface->ConfigRequest(cid, p_cfg);
53 }
54 
L2CA_ConfigRsp(uint16_t cid,tL2CAP_CFG_INFO * p_cfg)55 bool L2CA_ConfigRsp(uint16_t cid, tL2CAP_CFG_INFO* p_cfg) {
56   return l2cap_interface->ConfigResponse(cid, p_cfg);
57 }
58 
L2CA_DataWrite(uint16_t cid,BT_HDR * p_data)59 uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) {
60   return l2cap_interface->DataWrite(cid, p_data);
61 }
62