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 
19 #include "mock_btm_layer.h"
20 #include "stack/include/btm_client_interface.h"
21 #include "stack/include/rfcdefs.h"
22 
23 static bluetooth::manager::MockBtmSecurityInternalInterface*
24     btm_security_internal_interface = nullptr;
25 
SetMockSecurityInternalInterface(MockBtmSecurityInternalInterface * mock_btm_security_internal_interface)26 void bluetooth::manager::SetMockSecurityInternalInterface(
27     MockBtmSecurityInternalInterface* mock_btm_security_internal_interface) {
28   btm_security_internal_interface = mock_btm_security_internal_interface;
29 }
30 
btm_sec_abort_access_req(const RawAddress & bd_addr)31 void btm_sec_abort_access_req(const RawAddress& bd_addr) {
32   btm_security_internal_interface->AbortAccessRequest(bd_addr);
33 }
34 
btm_sec_mx_access_request(const RawAddress & bd_addr,bool is_originator,uint16_t requirement,tBTM_SEC_CALLBACK * p_callback,void * p_ref_data)35 tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
36                                       bool is_originator, uint16_t requirement,
37                                       tBTM_SEC_CALLBACK* p_callback,
38                                       void* p_ref_data) {
39   return btm_security_internal_interface->MultiplexingProtocolAccessRequest(
40       bd_addr, BT_PSM_RFCOMM, is_originator, BTM_SEC_PROTO_RFCOMM, 0,
41       p_callback, p_ref_data);
42 }
43 
BTM_SetSecurityLevel(bool is_originator,const char * p_name,uint8_t service_id,uint16_t sec_level,uint16_t psm,uint32_t mx_proto_id,uint32_t mx_chan_id)44 bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
45                           uint8_t service_id, uint16_t sec_level, uint16_t psm,
46                           uint32_t mx_proto_id, uint32_t mx_chan_id) {
47   return true;
48 }
49 
BTM_GetMaxPacketSize(const RawAddress & addr)50 uint16_t BTM_GetMaxPacketSize(const RawAddress& addr) {
51   return RFCOMM_DEFAULT_MTU;
52 }
53 
54 struct btm_client_interface_s btm_client_interface = {
55     .peer =
56         {
57             .BTM_GetMaxPacketSize = BTM_GetMaxPacketSize,
58         },
59 };
60 
get_btm_client_interface()61 struct btm_client_interface_s& get_btm_client_interface() {
62   return btm_client_interface;
63 }
64