From d6c80b565b48aebb10bcf32e7e4226f8474c2ba3 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Wed, 28 Apr 2021 12:15:51 -0700 Subject: [PATCH] Fix for hid disconnect with unknown channel Also introduce net_test_stack_hid And update mocks to allow functional replacement Bug: 181199209 Test: gd/cert/run Tag: #refactor BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines Change-Id: Iab4ac55477d2d98d52d7b77aee19b4172c63e4eb --- stack/Android.bp | 48 ++++ stack/hid/hidh_conn.cc | 6 + stack/test/hid/stack_hid_test.cc | 77 +++++++ test/Android.bp | 19 ++ test/mock/mock_l2cap_l2c_api.cc | 177 --------------- test/mock/mock_stack_l2cap_api.cc | 258 ++++++++++++++------- test/mock/mock_stack_l2cap_api.h | 458 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 784 insertions(+), 259 deletions(-) create mode 100644 stack/test/hid/stack_hid_test.cc delete mode 100644 test/mock/mock_l2cap_l2c_api.cc create mode 100644 test/mock/mock_stack_l2cap_api.h diff --git a/stack/Android.bp b/stack/Android.bp index b1e20ab35..664043597 100644 --- a/stack/Android.bp +++ b/stack/Android.bp @@ -805,3 +805,51 @@ cc_test { }, }, } + +cc_test { + name: "net_test_stack_hid", + test_suites: ["device-tests"], + host_supported: true, + defaults: ["fluoride_defaults"], + local_include_dirs: [ + "include", + "test/common", + ], + include_dirs: [ + "system/bt", + ], + srcs: crypto_toolbox_srcs + [ + ":TestStackL2cap", + ":TestStackSdp", + ":TestStackBtm", + ":TestStubLegacyTrace", + "hid/hidd_api.cc", + "hid/hidd_conn.cc", + "hid/hidh_api.cc", + "hid/hidh_conn.cc", + "test/hid/stack_hid_test.cc", + ], + static_libs: [ + "libbt-common", + "libbt-protos-lite", + "libbtdevice", + "libbte", + "libgmock", + "liblog", + "libosi", + ], + shared_libs: [ + "libcrypto", + "libprotobuf-cpp-lite", + ], + sanitize: { + address: true, + all_undefined: true, + cfi: true, + integer_overflow: true, + scs: true, + diag: { + undefined : true + }, + }, +} diff --git a/stack/hid/hidh_conn.cc b/stack/hid/hidh_conn.cc index e6b94a452..5c4f2abe2 100644 --- a/stack/hid/hidh_conn.cc +++ b/stack/hid/hidh_conn.cc @@ -270,6 +270,12 @@ static void hidh_try_repage(uint8_t dhandle) { static void hidh_on_l2cap_error(uint16_t l2cap_cid, uint16_t result) { auto dhandle = find_conn_by_cid(l2cap_cid); + if (dhandle == kHID_HOST_MAX_DEVICES) { + LOG_WARN("Received error for unknown device cid:0x%04x reason:%s", + l2cap_cid, + hci_reason_code_text(to_hci_reason_code(result)).c_str()); + return; + } hidh_conn_disconnect(dhandle); diff --git a/stack/test/hid/stack_hid_test.cc b/stack/test/hid/stack_hid_test.cc new file mode 100644 index 000000000..3a955d348 --- /dev/null +++ b/stack/test/hid/stack_hid_test.cc @@ -0,0 +1,77 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "common/message_loop_thread.h" +#include "osi/include/log.h" +#include "stack/hid/hidh_int.h" +#include "stack/include/hci_error_code.h" +#include "test/mock/mock_stack_l2cap_api.h" +#include "types/bt_transport.h" +#include "types/raw_address.h" + +std::map mock_function_count_map; + +bluetooth::common::MessageLoopThread* get_main_thread() { return nullptr; } +tHCI_REASON btm_get_acl_disc_reason_code(void) { return HCI_SUCCESS; } + +bool BTM_IsAclConnectionUp(const RawAddress& remote_bda, + tBT_TRANSPORT transport) { + return true; +} +namespace { + +using testing::_; +using testing::DoAll; +using testing::NotNull; +using testing::Pointee; +using testing::Return; +using testing::SaveArg; +using testing::SaveArgPointee; +using testing::StrEq; +using testing::StrictMock; +using testing::Test; + +class StackHidTest : public Test { + public: + protected: + void SetUp() override { mock_function_count_map.clear(); } + void TearDown() override {} +}; + +TEST_F(StackHidTest, disconnect_bad_cid) { + tL2CAP_APPL_INFO l2cap_callbacks; + + test::mock::stack_l2cap_api::L2CA_Register2.body = + [&l2cap_callbacks](uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, + uint16_t my_mtu, uint16_t required_remote_mtu, + uint16_t sec_level) { + l2cap_callbacks = p_cb_info; + return psm; + }; + + tHID_STATUS status = hidh_conn_reg(); + ASSERT_EQ(HID_SUCCESS, status); + + l2cap_callbacks.pL2CA_Error_Cb(123, 456); +} + +} // namespace diff --git a/test/Android.bp b/test/Android.bp index a391c3ea1..0e7579632 100644 --- a/test/Android.bp +++ b/test/Android.bp @@ -117,4 +117,23 @@ filegroup { ], } +filegroup { + name: "TestStackSdp", + srcs: [ + "mock/mock_stack_sdp*.cc", + ], +} +filegroup { + name: "TestStackBtm", + srcs: [ + "mock/mock_stack_btm*.cc", + ], +} + +filegroup { + name: "TestStubLegacyTrace", + srcs: [ + "stub/legacy_trace.cc", + ], +} diff --git a/test/mock/mock_l2cap_l2c_api.cc b/test/mock/mock_l2cap_l2c_api.cc deleted file mode 100644 index 85f2f4faf..000000000 --- a/test/mock/mock_l2cap_l2c_api.cc +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Generated mock file from original source file - * Functions generated:33 - */ - -#include -#include - -extern std::map mock_function_count_map; - -#include -#include "stack/include/l2c_api.h" -#include "types/raw_address.h" - -#ifndef UNUSED_ATTR -#define UNUSED_ATTR -#endif - -bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id, - std::vector& accepted_lcids, - uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_DisconnectLECocReq(uint16_t cid) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_DisconnectReq(uint16_t cid) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat, - uint8_t* p_chnl_mask) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_IsLinkEstablished(const RawAddress& bd_addr, - tBT_TRANSPORT transport) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda, - std::vector& lcids, - tL2CAP_LE_CFG_INFO* p_cfg) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_RegisterFixedChannel(uint16_t fixed_cid, - tL2CAP_FIXED_CHNL_REG* p_freg) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout, - tBT_TRANSPORT transport) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { - mock_function_count_map[__func__]++; - return false; -} -std::vector L2CA_ConnectCreditBasedReq(uint16_t psm, - const RawAddress& p_bd_addr, - tL2CAP_LE_CFG_INFO* p_cfg) { - mock_function_count_map[__func__]++; - std::vector v; - return v; -} -tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_AllocateLePSM(void) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, - tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr, - uint16_t sec_level) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, - uint16_t my_mtu, uint16_t required_remote_mtu) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, - uint16_t my_mtu, uint16_t required_remote_mtu, - uint16_t sec_level) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { - mock_function_count_map[__func__]++; - return 0; -} -uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda, - BT_HDR* p_buf) { - mock_function_count_map[__func__]++; - return 0; -} -uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { - mock_function_count_map[__func__]++; - return 0; -} -uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { - mock_function_count_map[__func__]++; - return 0; -} -uint8_t L2CA_SetTraceLevel(uint8_t new_level) { - mock_function_count_map[__func__]++; - return 0; -} -void L2CA_Deregister(uint16_t psm) { mock_function_count_map[__func__]++; } -void L2CA_DeregisterLECoc(uint16_t psm) { mock_function_count_map[__func__]++; } -void L2CA_FreeLePSM(uint16_t psm) { mock_function_count_map[__func__]++; } diff --git a/test/mock/mock_stack_l2cap_api.cc b/test/mock/mock_stack_l2cap_api.cc index 85f2f4faf..1c00c2bf3 100644 --- a/test/mock/mock_stack_l2cap_api.cc +++ b/test/mock/mock_stack_l2cap_api.cc @@ -17,6 +17,8 @@ /* * Generated mock file from original source file * Functions generated:33 + * + * mockcify.pl ver 0.2 */ #include @@ -24,154 +26,246 @@ extern std::map mock_function_count_map; +// Original included files, if any +// NOTE: Since this is a mock file with mock definitions some number of +// include files may not be required. The include-what-you-use +// still applies, but crafting proper inclusion is out of scope +// for this effort. This compilation unit may compile as-is, or +// may need attention to prune the inclusion set. +#include +#include #include +#include +#include "device/include/controller.h" +#include "main/shim/l2c_api.h" +#include "main/shim/shim.h" +#include "osi/include/log.h" +#include "stack/btm/btm_sec.h" #include "stack/include/l2c_api.h" -#include "types/raw_address.h" +#include "stack/l2cap/l2c_int.h" +// Mock include file to share data between tests and mock +#include "test/mock/mock_stack_l2cap_api.h" + +// Mocked compile conditionals, if any #ifndef UNUSED_ATTR #define UNUSED_ATTR #endif -bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id, - std::vector& accepted_lcids, - uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) { - mock_function_count_map[__func__]++; - return false; -} -bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { +// Mocked internal structures, if any + +namespace test { +namespace mock { +namespace stack_l2cap_api { + +// Function state capture and return values, if needed +struct l2c_get_transport_from_fixed_cid l2c_get_transport_from_fixed_cid; +struct L2CA_Register2 L2CA_Register2; +struct L2CA_Register L2CA_Register; +struct L2CA_Deregister L2CA_Deregister; +struct L2CA_AllocateLePSM L2CA_AllocateLePSM; +struct L2CA_FreeLePSM L2CA_FreeLePSM; +struct L2CA_ConnectReq2 L2CA_ConnectReq2; +struct L2CA_ConnectReq L2CA_ConnectReq; +struct L2CA_RegisterLECoc L2CA_RegisterLECoc; +struct L2CA_DeregisterLECoc L2CA_DeregisterLECoc; +struct L2CA_ConnectLECocReq L2CA_ConnectLECocReq; +struct L2CA_GetPeerLECocConfig L2CA_GetPeerLECocConfig; +struct L2CA_ConnectCreditBasedRsp L2CA_ConnectCreditBasedRsp; +struct L2CA_ConnectCreditBasedReq L2CA_ConnectCreditBasedReq; +struct L2CA_ReconfigCreditBasedConnsReq L2CA_ReconfigCreditBasedConnsReq; +struct L2CA_DisconnectReq L2CA_DisconnectReq; +struct L2CA_DisconnectLECocReq L2CA_DisconnectLECocReq; +struct L2CA_GetRemoteCid L2CA_GetRemoteCid; +struct L2CA_SetIdleTimeoutByBdAddr L2CA_SetIdleTimeoutByBdAddr; +struct L2CA_SetTraceLevel L2CA_SetTraceLevel; +struct L2CA_SetAclPriority L2CA_SetAclPriority; +struct L2CA_SetTxPriority L2CA_SetTxPriority; +struct L2CA_GetPeerFeatures L2CA_GetPeerFeatures; +struct L2CA_RegisterFixedChannel L2CA_RegisterFixedChannel; +struct L2CA_ConnectFixedChnl L2CA_ConnectFixedChnl; +struct L2CA_SendFixedChnlData L2CA_SendFixedChnlData; +struct L2CA_RemoveFixedChnl L2CA_RemoveFixedChnl; +struct L2CA_SetLeGattTimeout L2CA_SetLeGattTimeout; +struct L2CA_DataWrite L2CA_DataWrite; +struct L2CA_LECocDataWrite L2CA_LECocDataWrite; +struct L2CA_SetChnlFlushability L2CA_SetChnlFlushability; +struct L2CA_FlushChannel L2CA_FlushChannel; +struct L2CA_IsLinkEstablished L2CA_IsLinkEstablished; + +} // namespace stack_l2cap_api +} // namespace mock +} // namespace test + +// Mocked functions, if any +tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::l2c_get_transport_from_fixed_cid( + fixed_cid); } -bool L2CA_DisconnectLECocReq(uint16_t cid) { +uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, + uint16_t my_mtu, uint16_t required_remote_mtu, + uint16_t sec_level) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_Register2( + psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, required_remote_mtu, + sec_level); } -bool L2CA_DisconnectReq(uint16_t cid) { +uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, + uint16_t my_mtu, uint16_t required_remote_mtu, + uint16_t sec_level) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_Register( + psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, required_remote_mtu, + sec_level); } -bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat, - uint8_t* p_chnl_mask) { +void L2CA_Deregister(uint16_t psm) { mock_function_count_map[__func__]++; - return false; + test::mock::stack_l2cap_api::L2CA_Deregister(psm); } -bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { +uint16_t L2CA_AllocateLePSM(void) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_AllocateLePSM(); } -bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { +void L2CA_FreeLePSM(uint16_t psm) { mock_function_count_map[__func__]++; - return false; + test::mock::stack_l2cap_api::L2CA_FreeLePSM(psm); } -bool L2CA_IsLinkEstablished(const RawAddress& bd_addr, - tBT_TRANSPORT transport) { +uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr, + uint16_t sec_level) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ConnectReq2(psm, p_bd_addr, + sec_level); } -bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda, - std::vector& lcids, - tL2CAP_LE_CFG_INFO* p_cfg) { +uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ConnectReq(psm, p_bd_addr); } -bool L2CA_RegisterFixedChannel(uint16_t fixed_cid, - tL2CAP_FIXED_CHNL_REG* p_freg) { +uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_RegisterLECoc(psm, p_cb_info, + sec_level, cfg); } -bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { +void L2CA_DeregisterLECoc(uint16_t psm) { mock_function_count_map[__func__]++; - return false; + test::mock::stack_l2cap_api::L2CA_DeregisterLECoc(psm); } -bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { +uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ConnectLECocReq(psm, p_bd_addr, + p_cfg, sec_level); } -bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) { +bool L2CA_GetPeerLECocConfig(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_GetPeerLECocConfig(lcid, peer_cfg); } -bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) { +bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id, + std::vector& accepted_lcids, + uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ConnectCreditBasedRsp( + p_bd_addr, id, accepted_lcids, result, p_cfg); } -bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout, - tBT_TRANSPORT transport) { +std::vector L2CA_ConnectCreditBasedReq(uint16_t psm, + const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ConnectCreditBasedReq(psm, p_bd_addr, + p_cfg); } -bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { +bool L2CA_ReconfigCreditBasedConnsReq(const RawAddress& bda, + std::vector& lcids, + tL2CAP_LE_CFG_INFO* p_cfg) { mock_function_count_map[__func__]++; - return false; + return test::mock::stack_l2cap_api::L2CA_ReconfigCreditBasedConnsReq( + bda, lcids, p_cfg); } -std::vector L2CA_ConnectCreditBasedReq(uint16_t psm, - const RawAddress& p_bd_addr, - tL2CAP_LE_CFG_INFO* p_cfg) { +bool L2CA_DisconnectReq(uint16_t cid) { mock_function_count_map[__func__]++; - std::vector v; - return v; + return test::mock::stack_l2cap_api::L2CA_DisconnectReq(cid); } -tBT_TRANSPORT l2c_get_transport_from_fixed_cid(uint16_t fixed_cid) { +bool L2CA_DisconnectLECocReq(uint16_t cid) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_DisconnectLECocReq(cid); } -uint16_t L2CA_AllocateLePSM(void) { +bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_GetRemoteCid(lcid, rcid); } -uint16_t L2CA_ConnectLECocReq(uint16_t psm, const RawAddress& p_bd_addr, - tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { +bool L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr, uint16_t timeout, + tBT_TRANSPORT transport) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SetIdleTimeoutByBdAddr( + bd_addr, timeout, transport); } -uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& p_bd_addr) { +uint8_t L2CA_SetTraceLevel(uint8_t new_level) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SetTraceLevel(new_level); } -uint16_t L2CA_ConnectReq2(uint16_t psm, const RawAddress& p_bd_addr, - uint16_t sec_level) { +bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SetAclPriority(bd_addr, priority); } -uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { +bool L2CA_SetTxPriority(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SetTxPriority(cid, priority); } -uint16_t L2CA_Register(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, - uint16_t my_mtu, uint16_t required_remote_mtu) { +bool L2CA_GetPeerFeatures(const RawAddress& bd_addr, uint32_t* p_ext_feat, + uint8_t* p_chnl_mask) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_GetPeerFeatures(bd_addr, p_ext_feat, + p_chnl_mask); } -uint16_t L2CA_Register2(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, - uint16_t my_mtu, uint16_t required_remote_mtu, - uint16_t sec_level) { +bool L2CA_RegisterFixedChannel(uint16_t fixed_cid, + tL2CAP_FIXED_CHNL_REG* p_freg) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_RegisterFixedChannel(fixed_cid, + p_freg); } -uint16_t L2CA_RegisterLECoc(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, - uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { +bool L2CA_ConnectFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_ConnectFixedChnl(fixed_cid, rem_bda); } uint16_t L2CA_SendFixedChnlData(uint16_t fixed_cid, const RawAddress& rem_bda, BT_HDR* p_buf) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SendFixedChnlData(fixed_cid, rem_bda, + p_buf); +} +bool L2CA_RemoveFixedChnl(uint16_t fixed_cid, const RawAddress& rem_bda) { + mock_function_count_map[__func__]++; + return test::mock::stack_l2cap_api::L2CA_RemoveFixedChnl(fixed_cid, rem_bda); +} +bool L2CA_SetLeGattTimeout(const RawAddress& rem_bda, uint16_t idle_tout) { + mock_function_count_map[__func__]++; + return test::mock::stack_l2cap_api::L2CA_SetLeGattTimeout(rem_bda, idle_tout); } uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_DataWrite(cid, p_data); } uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_LECocDataWrite(cid, p_data); } -uint8_t L2CA_SetTraceLevel(uint8_t new_level) { +bool L2CA_SetChnlFlushability(uint16_t cid, bool is_flushable) { mock_function_count_map[__func__]++; - return 0; + return test::mock::stack_l2cap_api::L2CA_SetChnlFlushability(cid, + is_flushable); } -void L2CA_Deregister(uint16_t psm) { mock_function_count_map[__func__]++; } -void L2CA_DeregisterLECoc(uint16_t psm) { mock_function_count_map[__func__]++; } -void L2CA_FreeLePSM(uint16_t psm) { mock_function_count_map[__func__]++; } +uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush) { + mock_function_count_map[__func__]++; + return test::mock::stack_l2cap_api::L2CA_FlushChannel(lcid, num_to_flush); +} +bool L2CA_IsLinkEstablished(const RawAddress& bd_addr, + tBT_TRANSPORT transport) { + mock_function_count_map[__func__]++; + return test::mock::stack_l2cap_api::L2CA_IsLinkEstablished(bd_addr, + transport); +} + +// END mockcify generation diff --git a/test/mock/mock_stack_l2cap_api.h b/test/mock/mock_stack_l2cap_api.h new file mode 100644 index 000000000..0c363f971 --- /dev/null +++ b/test/mock/mock_stack_l2cap_api.h @@ -0,0 +1,458 @@ +/* + * Copyright 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * Generated mock file from original source file + * Functions generated:33 + * + * mockcify.pl ver 0.2 + */ + +#include +#include +#include +#include + +extern std::map mock_function_count_map; + +// Original included files, if any +// NOTE: Since this is a mock file with mock definitions some number of +// include files may not be required. The include-what-you-use +// still applies, but crafting proper inclusion is out of scope +// for this effort. This compilation unit may compile as-is, or +// may need attention to prune the inclusion set. +#include +#include +#include +#include +#include "device/include/controller.h" +#include "main/shim/l2c_api.h" +#include "main/shim/shim.h" +#include "osi/include/log.h" +#include "stack/btm/btm_sec.h" +#include "stack/include/l2c_api.h" +#include "stack/l2cap/l2c_int.h" + +// Mocked compile conditionals, if any +#ifndef UNUSED_ATTR +#define UNUSED_ATTR +#endif + +namespace test { +namespace mock { +namespace stack_l2cap_api { + +// Shared state between mocked functions and tests +// Name: l2c_get_transport_from_fixed_cid +// Params: uint16_t fixed_cid +// Returns: tBT_TRANSPORT +struct l2c_get_transport_from_fixed_cid { + std::function body{ + [](uint16_t fixed_cid) { return 0; }}; + tBT_TRANSPORT operator()(uint16_t fixed_cid) { return body(fixed_cid); }; +}; +extern struct l2c_get_transport_from_fixed_cid l2c_get_transport_from_fixed_cid; +// Name: L2CA_Register2 +// Params: uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, bool enable_snoop, +// tL2CAP_ERTM_INFO* p_ertm_info, uint16_t my_mtu, uint16_t required_remote_mtu, +// uint16_t sec_level Returns: uint16_t +struct L2CA_Register2 { + std::function + body{[](uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, uint16_t my_mtu, + uint16_t required_remote_mtu, uint16_t sec_level) { return 0; }}; + uint16_t operator()(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, + uint16_t my_mtu, uint16_t required_remote_mtu, + uint16_t sec_level) { + return body(psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, + required_remote_mtu, sec_level); + }; +}; +extern struct L2CA_Register2 L2CA_Register2; +// Name: L2CA_Register +// Params: uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, bool enable_snoop, +// tL2CAP_ERTM_INFO* p_ertm_info, uint16_t my_mtu, uint16_t required_remote_mtu, +// uint16_t sec_level Returns: uint16_t +struct L2CA_Register { + std::function + body{[](uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, uint16_t my_mtu, + uint16_t required_remote_mtu, uint16_t sec_level) { return 0; }}; + uint16_t operator()(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info, + uint16_t my_mtu, uint16_t required_remote_mtu, + uint16_t sec_level) { + return body(psm, p_cb_info, enable_snoop, p_ertm_info, my_mtu, + required_remote_mtu, sec_level); + }; +}; +extern struct L2CA_Register L2CA_Register; +// Name: L2CA_Deregister +// Params: uint16_t psm +// Returns: void +struct L2CA_Deregister { + std::function body{[](uint16_t psm) {}}; + void operator()(uint16_t psm) { body(psm); }; +}; +extern struct L2CA_Deregister L2CA_Deregister; +// Name: L2CA_AllocateLePSM +// Params: void +// Returns: uint16_t +struct L2CA_AllocateLePSM { + std::function body{[](void) { return 0; }}; + uint16_t operator()(void) { return body(); }; +}; +extern struct L2CA_AllocateLePSM L2CA_AllocateLePSM; +// Name: L2CA_FreeLePSM +// Params: uint16_t psm +// Returns: void +struct L2CA_FreeLePSM { + std::function body{[](uint16_t psm) {}}; + void operator()(uint16_t psm) { body(psm); }; +}; +extern struct L2CA_FreeLePSM L2CA_FreeLePSM; +// Name: L2CA_ConnectReq2 +// Params: uint16_t psm, const RawAddress& p_bd_addr, uint16_t sec_level +// Returns: uint16_t +struct L2CA_ConnectReq2 { + std::function + body{[](uint16_t psm, const RawAddress& p_bd_addr, uint16_t sec_level) { + return 0; + }}; + uint16_t operator()(uint16_t psm, const RawAddress& p_bd_addr, + uint16_t sec_level) { + return body(psm, p_bd_addr, sec_level); + }; +}; +extern struct L2CA_ConnectReq2 L2CA_ConnectReq2; +// Name: L2CA_ConnectReq +// Params: uint16_t psm, const RawAddress& p_bd_addr +// Returns: uint16_t +struct L2CA_ConnectReq { + std::function body{ + [](uint16_t psm, const RawAddress& p_bd_addr) { return 0; }}; + uint16_t operator()(uint16_t psm, const RawAddress& p_bd_addr) { + return body(psm, p_bd_addr); + }; +}; +extern struct L2CA_ConnectReq L2CA_ConnectReq; +// Name: L2CA_RegisterLECoc +// Params: uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, uint16_t sec_level, +// tL2CAP_LE_CFG_INFO cfg Returns: uint16_t +struct L2CA_RegisterLECoc { + std::function + body{[](uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { return 0; }}; + uint16_t operator()(uint16_t psm, const tL2CAP_APPL_INFO& p_cb_info, + uint16_t sec_level, tL2CAP_LE_CFG_INFO cfg) { + return body(psm, p_cb_info, sec_level, cfg); + }; +}; +extern struct L2CA_RegisterLECoc L2CA_RegisterLECoc; +// Name: L2CA_DeregisterLECoc +// Params: uint16_t psm +// Returns: void +struct L2CA_DeregisterLECoc { + std::function body{[](uint16_t psm) {}}; + void operator()(uint16_t psm) { body(psm); }; +}; +extern struct L2CA_DeregisterLECoc L2CA_DeregisterLECoc; +// Name: L2CA_ConnectLECocReq +// Params: uint16_t psm, const RawAddress& p_bd_addr, tL2CAP_LE_CFG_INFO* p_cfg, +// uint16_t sec_level Returns: uint16_t +struct L2CA_ConnectLECocReq { + std::function + body{[](uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { return 0; }}; + uint16_t operator()(uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg, uint16_t sec_level) { + return body(psm, p_bd_addr, p_cfg, sec_level); + }; +}; +extern struct L2CA_ConnectLECocReq L2CA_ConnectLECocReq; +// Name: L2CA_GetPeerLECocConfig +// Params: uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg +// Returns: bool +struct L2CA_GetPeerLECocConfig { + std::function body{ + [](uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { return false; }}; + bool operator()(uint16_t lcid, tL2CAP_LE_CFG_INFO* peer_cfg) { + return body(lcid, peer_cfg); + }; +}; +extern struct L2CA_GetPeerLECocConfig L2CA_GetPeerLECocConfig; +// Name: L2CA_ConnectCreditBasedRsp +// Params: const RawAddress& p_bd_addr, uint8_t id, std::vector& +// accepted_lcids, uint16_t result, tL2CAP_LE_CFG_INFO* p_cfg Returns: bool +struct L2CA_ConnectCreditBasedRsp { + std::function& accepted_lcids, uint16_t result, + tL2CAP_LE_CFG_INFO* p_cfg)> + body{[](const RawAddress& p_bd_addr, uint8_t id, + std::vector& accepted_lcids, uint16_t result, + tL2CAP_LE_CFG_INFO* p_cfg) { return false; }}; + bool operator()(const RawAddress& p_bd_addr, uint8_t id, + std::vector& accepted_lcids, uint16_t result, + tL2CAP_LE_CFG_INFO* p_cfg) { + return body(p_bd_addr, id, accepted_lcids, result, p_cfg); + }; +}; +extern struct L2CA_ConnectCreditBasedRsp L2CA_ConnectCreditBasedRsp; +// Name: L2CA_ConnectCreditBasedReq +// Params: uint16_t psm, const RawAddress& p_bd_addr, tL2CAP_LE_CFG_INFO* p_cfg +// Returns: std::vector +struct L2CA_ConnectCreditBasedReq { + std::vector cids; + std::function(uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg)> + body{[this](uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg) { return cids; }}; + std::vector operator()(uint16_t psm, const RawAddress& p_bd_addr, + tL2CAP_LE_CFG_INFO* p_cfg) { + return body(psm, p_bd_addr, p_cfg); + }; +}; +extern struct L2CA_ConnectCreditBasedReq L2CA_ConnectCreditBasedReq; +// Name: L2CA_ReconfigCreditBasedConnsReq +// Params: const RawAddress& bda, std::vector& lcids, +// tL2CAP_LE_CFG_INFO* p_cfg Returns: bool +struct L2CA_ReconfigCreditBasedConnsReq { + std::function& lcids, + tL2CAP_LE_CFG_INFO* p_cfg)> + body{[](const RawAddress& bda, std::vector& lcids, + tL2CAP_LE_CFG_INFO* p_cfg) { return false; }}; + bool operator()(const RawAddress& bda, std::vector& lcids, + tL2CAP_LE_CFG_INFO* p_cfg) { + return body(bda, lcids, p_cfg); + }; +}; +extern struct L2CA_ReconfigCreditBasedConnsReq L2CA_ReconfigCreditBasedConnsReq; +// Name: L2CA_DisconnectReq +// Params: uint16_t cid +// Returns: bool +struct L2CA_DisconnectReq { + std::function body{[](uint16_t cid) { return false; }}; + bool operator()(uint16_t cid) { return body(cid); }; +}; +extern struct L2CA_DisconnectReq L2CA_DisconnectReq; +// Name: L2CA_DisconnectLECocReq +// Params: uint16_t cid +// Returns: bool +struct L2CA_DisconnectLECocReq { + std::function body{[](uint16_t cid) { return false; }}; + bool operator()(uint16_t cid) { return body(cid); }; +}; +extern struct L2CA_DisconnectLECocReq L2CA_DisconnectLECocReq; +// Name: L2CA_GetRemoteCid +// Params: uint16_t lcid, uint16_t* rcid +// Returns: bool +struct L2CA_GetRemoteCid { + std::function body{ + [](uint16_t lcid, uint16_t* rcid) { return false; }}; + bool operator()(uint16_t lcid, uint16_t* rcid) { return body(lcid, rcid); }; +}; +extern struct L2CA_GetRemoteCid L2CA_GetRemoteCid; +// Name: L2CA_SetIdleTimeoutByBdAddr +// Params: const RawAddress& bd_addr, uint16_t timeout, tBT_TRANSPORT transport +// Returns: bool +struct L2CA_SetIdleTimeoutByBdAddr { + std::function + body{[](const RawAddress& bd_addr, uint16_t timeout, + tBT_TRANSPORT transport) { return false; }}; + bool operator()(const RawAddress& bd_addr, uint16_t timeout, + tBT_TRANSPORT transport) { + return body(bd_addr, timeout, transport); + }; +}; +extern struct L2CA_SetIdleTimeoutByBdAddr L2CA_SetIdleTimeoutByBdAddr; +// Name: L2CA_SetTraceLevel +// Params: uint8_t new_level +// Returns: uint8_t +struct L2CA_SetTraceLevel { + std::function body{ + [](uint8_t new_level) { return 0; }}; + uint8_t operator()(uint8_t new_level) { return body(new_level); }; +}; +extern struct L2CA_SetTraceLevel L2CA_SetTraceLevel; +// Name: L2CA_SetAclPriority +// Params: const RawAddress& bd_addr, tL2CAP_PRIORITY priority +// Returns: bool +struct L2CA_SetAclPriority { + std::function body{ + [](const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { + return false; + }}; + bool operator()(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) { + return body(bd_addr, priority); + }; +}; +extern struct L2CA_SetAclPriority L2CA_SetAclPriority; +// Name: L2CA_SetTxPriority +// Params: uint16_t cid, tL2CAP_CHNL_PRIORITY priority +// Returns: bool +struct L2CA_SetTxPriority { + std::function body{ + [](uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { return false; }}; + bool operator()(uint16_t cid, tL2CAP_CHNL_PRIORITY priority) { + return body(cid, priority); + }; +}; +extern struct L2CA_SetTxPriority L2CA_SetTxPriority; +// Name: L2CA_GetPeerFeatures +// Params: const RawAddress& bd_addr, uint32_t* p_ext_feat, uint8_t* p_chnl_mask +// Returns: bool +struct L2CA_GetPeerFeatures { + std::function + body{[](const RawAddress& bd_addr, uint32_t* p_ext_feat, + uint8_t* p_chnl_mask) { return false; }}; + bool operator()(const RawAddress& bd_addr, uint32_t* p_ext_feat, + uint8_t* p_chnl_mask) { + return body(bd_addr, p_ext_feat, p_chnl_mask); + }; +}; +extern struct L2CA_GetPeerFeatures L2CA_GetPeerFeatures; +// Name: L2CA_RegisterFixedChannel +// Params: uint16_t fixed_cid, tL2CAP_FIXED_CHNL_REG* p_freg +// Returns: bool +struct L2CA_RegisterFixedChannel { + std::function body{ + [](uint16_t fixed_cid, tL2CAP_FIXED_CHNL_REG* p_freg) { return false; }}; + bool operator()(uint16_t fixed_cid, tL2CAP_FIXED_CHNL_REG* p_freg) { + return body(fixed_cid, p_freg); + }; +}; +extern struct L2CA_RegisterFixedChannel L2CA_RegisterFixedChannel; +// Name: L2CA_ConnectFixedChnl +// Params: uint16_t fixed_cid, const RawAddress& rem_bda +// Returns: bool +struct L2CA_ConnectFixedChnl { + std::function body{ + [](uint16_t fixed_cid, const RawAddress& rem_bda) { return false; }}; + bool operator()(uint16_t fixed_cid, const RawAddress& rem_bda) { + return body(fixed_cid, rem_bda); + }; +}; +extern struct L2CA_ConnectFixedChnl L2CA_ConnectFixedChnl; +// Name: L2CA_SendFixedChnlData +// Params: uint16_t fixed_cid, const RawAddress& rem_bda, BT_HDR* p_buf +// Returns: uint16_t +struct L2CA_SendFixedChnlData { + std::function + body{[](uint16_t fixed_cid, const RawAddress& rem_bda, BT_HDR* p_buf) { + return 0; + }}; + uint16_t operator()(uint16_t fixed_cid, const RawAddress& rem_bda, + BT_HDR* p_buf) { + return body(fixed_cid, rem_bda, p_buf); + }; +}; +extern struct L2CA_SendFixedChnlData L2CA_SendFixedChnlData; +// Name: L2CA_RemoveFixedChnl +// Params: uint16_t fixed_cid, const RawAddress& rem_bda +// Returns: bool +struct L2CA_RemoveFixedChnl { + std::function body{ + [](uint16_t fixed_cid, const RawAddress& rem_bda) { return false; }}; + bool operator()(uint16_t fixed_cid, const RawAddress& rem_bda) { + return body(fixed_cid, rem_bda); + }; +}; +extern struct L2CA_RemoveFixedChnl L2CA_RemoveFixedChnl; +// Name: L2CA_SetLeGattTimeout +// Params: const RawAddress& rem_bda, uint16_t idle_tout +// Returns: bool +struct L2CA_SetLeGattTimeout { + std::function body{ + [](const RawAddress& rem_bda, uint16_t idle_tout) { return false; }}; + bool operator()(const RawAddress& rem_bda, uint16_t idle_tout) { + return body(rem_bda, idle_tout); + }; +}; +extern struct L2CA_SetLeGattTimeout L2CA_SetLeGattTimeout; +// Name: L2CA_DataWrite +// Params: uint16_t cid, BT_HDR* p_data +// Returns: uint8_t +struct L2CA_DataWrite { + std::function body{ + [](uint16_t cid, BT_HDR* p_data) { return 0; }}; + uint8_t operator()(uint16_t cid, BT_HDR* p_data) { + return body(cid, p_data); + }; +}; +extern struct L2CA_DataWrite L2CA_DataWrite; +// Name: L2CA_LECocDataWrite +// Params: uint16_t cid, BT_HDR* p_data +// Returns: uint8_t +struct L2CA_LECocDataWrite { + std::function body{ + [](uint16_t cid, BT_HDR* p_data) { return 0; }}; + uint8_t operator()(uint16_t cid, BT_HDR* p_data) { + return body(cid, p_data); + }; +}; +extern struct L2CA_LECocDataWrite L2CA_LECocDataWrite; +// Name: L2CA_SetChnlFlushability +// Params: uint16_t cid, bool is_flushable +// Returns: bool +struct L2CA_SetChnlFlushability { + std::function body{ + [](uint16_t cid, bool is_flushable) { return false; }}; + bool operator()(uint16_t cid, bool is_flushable) { + return body(cid, is_flushable); + }; +}; +extern struct L2CA_SetChnlFlushability L2CA_SetChnlFlushability; +// Name: L2CA_FlushChannel +// Params: uint16_t lcid, uint16_t num_to_flush +// Returns: uint16_t +struct L2CA_FlushChannel { + std::function body{ + [](uint16_t lcid, uint16_t num_to_flush) { return 0; }}; + uint16_t operator()(uint16_t lcid, uint16_t num_to_flush) { + return body(lcid, num_to_flush); + }; +}; +extern struct L2CA_FlushChannel L2CA_FlushChannel; +// Name: L2CA_IsLinkEstablished +// Params: const RawAddress& bd_addr, tBT_TRANSPORT transport +// Returns: bool +struct L2CA_IsLinkEstablished { + std::function body{ + [](const RawAddress& bd_addr, tBT_TRANSPORT transport) { return false; }}; + bool operator()(const RawAddress& bd_addr, tBT_TRANSPORT transport) { + return body(bd_addr, transport); + }; +}; +extern struct L2CA_IsLinkEstablished L2CA_IsLinkEstablished; + +} // namespace stack_l2cap_api +} // namespace mock +} // namespace test + +// END mockcify generation -- 2.11.0