1 /*
2 * Copyright 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <cstdint>
18 #include <future>
19 #include <memory>
20 #include <optional>
21 #include <string>
22
23 #include "hci/acl_manager.h"
24 #include "hci/acl_manager/classic_acl_connection.h"
25 #include "hci/acl_manager/le_acl_connection.h"
26 #include "hci/address.h"
27 #include "hci/address_with_type.h"
28 #include "hci/class_of_device.h"
29 #include "main/shim/acl.h"
30 #include "main/shim/entry.h"
31 #include "os/handler.h"
32 #include "stack/acl/acl.h"
33 #include "test/common/mock_functions.h"
34 #include "types/raw_address.h"
35
36 // TODO(b/369381361) Enfore -Wmissing-prototypes
37 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
38
39 using namespace bluetooth;
40
DumpsysL2cap(int)41 void DumpsysL2cap(int /* fd */) { inc_func_call_count(__func__); }
42
DumpsysAcl(int)43 void DumpsysAcl(int /* fd */) { inc_func_call_count(__func__); }
44
DumpsysNeighbor(int)45 void DumpsysNeighbor(int /* fd */) { inc_func_call_count(__func__); }
46
Dump(int) const47 void shim::Acl::Dump(int /* fd */) const { inc_func_call_count(__func__); }
48
Acl(os::Handler *,const acl_interface_t & acl_interface,uint8_t,uint8_t)49 shim::Acl::Acl(os::Handler* /* handler */, const acl_interface_t& acl_interface,
50 uint8_t /* max_acceptlist_size */, uint8_t /* max_address_resolution_size */)
51 : acl_interface_(acl_interface) {
52 inc_func_call_count(__func__);
53 }
~Acl()54 shim::Acl::~Acl() { inc_func_call_count(__func__); }
55
CheckForOrphanedAclConnections() const56 bool shim::Acl::CheckForOrphanedAclConnections() const {
57 inc_func_call_count(__func__);
58 return false;
59 }
60
on_incoming_acl_credits(uint16_t,uint16_t)61 void shim::Acl::on_incoming_acl_credits(uint16_t /* handle */, uint16_t /* credits */) {
62 inc_func_call_count(__func__);
63 }
64
65 using HciHandle = uint16_t;
66
67 struct shim::Acl::impl {};
68
CreateClassicConnection(const hci::Address &)69 void shim::Acl::CreateClassicConnection(const hci::Address& /* address */) {
70 inc_func_call_count(__func__);
71 }
72
CancelClassicConnection(const hci::Address &)73 void shim::Acl::CancelClassicConnection(const hci::Address& /* address */) {
74 inc_func_call_count(__func__);
75 }
76
AcceptLeConnectionFrom(const hci::AddressWithType &,bool,std::promise<bool>)77 void shim::Acl::AcceptLeConnectionFrom(const hci::AddressWithType& /* address_with_type */,
78 bool /* is_direct */, std::promise<bool> /* promise */) {
79 inc_func_call_count(__func__);
80 }
81
IgnoreLeConnectionFrom(const hci::AddressWithType &)82 void shim::Acl::IgnoreLeConnectionFrom(const hci::AddressWithType& /* address_with_type */) {
83 inc_func_call_count(__func__);
84 }
85
OnClassicLinkDisconnected(HciHandle,hci::ErrorCode)86 void bluetooth::shim::Acl::OnClassicLinkDisconnected(HciHandle /* handle */,
87 hci::ErrorCode /* reason */) {
88 inc_func_call_count(__func__);
89 }
90
GetConnectionLocalAddress(uint16_t,bool,std::promise<bluetooth::hci::AddressWithType>)91 void shim::Acl::GetConnectionLocalAddress(
92 uint16_t /* handle */, bool /* ota_address */,
93 std::promise<bluetooth::hci::AddressWithType> /* promise */) {
94 inc_func_call_count(__func__);
95 }
96
GetConnectionPeerAddress(uint16_t,bool,std::promise<bluetooth::hci::AddressWithType>)97 void shim::Acl::GetConnectionPeerAddress(
98 uint16_t /* handle */, bool /* ota_address */,
99 std::promise<bluetooth::hci::AddressWithType> /* promise */) {
100 inc_func_call_count(__func__);
101 }
102
GetAdvertisingSetConnectedTo(const RawAddress &,std::promise<std::optional<uint8_t>>)103 void shim::Acl::GetAdvertisingSetConnectedTo(
104 const RawAddress& /* remote_bda */, std::promise<std::optional<uint8_t>> /* promise */) {
105 inc_func_call_count(__func__);
106 }
107
OnLeLinkDisconnected(HciHandle,hci::ErrorCode)108 void shim::Acl::OnLeLinkDisconnected(HciHandle /* handle */, hci::ErrorCode /* reason */) {
109 inc_func_call_count(__func__);
110 }
111
OnConnectSuccess(std::unique_ptr<hci::acl_manager::ClassicAclConnection>)112 void shim::Acl::OnConnectSuccess(
113 std::unique_ptr<hci::acl_manager::ClassicAclConnection> /* connection */) {
114 inc_func_call_count(__func__);
115 }
116
OnConnectRequest(hci::Address,hci::ClassOfDevice)117 void shim::Acl::OnConnectRequest(hci::Address /* address */, hci::ClassOfDevice /* cod */) {
118 inc_func_call_count(__func__);
119 }
OnConnectFail(hci::Address,hci::ErrorCode,bool)120 void shim::Acl::OnConnectFail(hci::Address /* address */, hci::ErrorCode /* reason */,
121 bool /* locally_initiated */) {
122 inc_func_call_count(__func__);
123 }
124
OnLeConnectSuccess(hci::AddressWithType,std::unique_ptr<hci::acl_manager::LeAclConnection>)125 void shim::Acl::OnLeConnectSuccess(
126 hci::AddressWithType /* address_with_type */,
127 std::unique_ptr<hci::acl_manager::LeAclConnection> /* connection */) {
128 inc_func_call_count(__func__);
129 }
130
OnLeConnectFail(hci::AddressWithType,hci::ErrorCode)131 void shim::Acl::OnLeConnectFail(hci::AddressWithType /* address_with_type */,
132 hci::ErrorCode /* reason */) {
133 inc_func_call_count(__func__);
134 }
135
DisconnectClassic(uint16_t,tHCI_STATUS,std::string)136 void shim::Acl::DisconnectClassic(uint16_t /* handle */, tHCI_STATUS /* reason */,
137 std::string /* comment */) {
138 inc_func_call_count(__func__);
139 }
140
DisconnectLe(uint16_t,tHCI_STATUS,std::string)141 void shim::Acl::DisconnectLe(uint16_t /* handle */, tHCI_STATUS /* reason */,
142 std::string /* comment */) {
143 inc_func_call_count(__func__);
144 }
145
LeSetDefaultSubrate(uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)146 void shim::Acl::LeSetDefaultSubrate(uint16_t /* subrate_min */, uint16_t /* subrate_max */,
147 uint16_t /* max_latency */, uint16_t /* cont_num */,
148 uint16_t /* sup_tout */) {
149 inc_func_call_count(__func__);
150 }
151
LeSubrateRequest(uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)152 void shim::Acl::LeSubrateRequest(uint16_t /* hci_handle */, uint16_t /* subrate_min */,
153 uint16_t /* subrate_max */, uint16_t /* max_latency */,
154 uint16_t /* cont_num */, uint16_t /* sup_tout */) {
155 inc_func_call_count(__func__);
156 }
157
DumpConnectionHistory(int) const158 void shim::Acl::DumpConnectionHistory(int /* fd */) const { inc_func_call_count(__func__); }
159
DisconnectAllForSuspend()160 void shim::Acl::DisconnectAllForSuspend() { inc_func_call_count(__func__); }
161
Shutdown()162 void shim::Acl::Shutdown() { inc_func_call_count(__func__); }
163
FinalShutdown()164 void shim::Acl::FinalShutdown() { inc_func_call_count(__func__); }
165
ClearFilterAcceptList()166 void shim::Acl::ClearFilterAcceptList() { inc_func_call_count(__func__); }
167
AddToAddressResolution(const hci::AddressWithType &,const std::array<uint8_t,16> &,const std::array<uint8_t,16> &)168 void shim::Acl::AddToAddressResolution(const hci::AddressWithType& /* address_with_type */,
169 const std::array<uint8_t, 16>& /* peer_irk */,
170 const std::array<uint8_t, 16>& /* local_irk */) {
171 inc_func_call_count(__func__);
172 }
173
RemoveFromAddressResolution(const hci::AddressWithType &)174 void shim::Acl::RemoveFromAddressResolution(const hci::AddressWithType& /* address_with_type */) {
175 inc_func_call_count(__func__);
176 }
177
ClearAddressResolution()178 void shim::Acl::ClearAddressResolution() { inc_func_call_count(__func__); }
179
SetSystemSuspendState(bool)180 void shim::Acl::SetSystemSuspendState(bool /* suspended */) { inc_func_call_count(__func__); }
181
UpdateConnectionParameters(uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)182 void shim::Acl::UpdateConnectionParameters(uint16_t /* handle */, uint16_t /* conn_int_min */,
183 uint16_t /* conn_int_max */, uint16_t /* conn_latency */,
184 uint16_t /* conn_timeout */, uint16_t /* min_ce_len */,
185 uint16_t /* max_ce_len */) {
186 inc_func_call_count(__func__);
187 }
188