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 using namespace bluetooth;
37
DumpsysAcl(int)38 void DumpsysAcl(int /* fd */) { inc_func_call_count(__func__); }
39
DumpsysNeighbor(int)40 void DumpsysNeighbor(int /* fd */) { inc_func_call_count(__func__); }
41
Dump(int) const42 void shim::Acl::Dump(int /* fd */) const { inc_func_call_count(__func__); }
43
Acl(os::Handler *,const acl_interface_t & acl_interface,uint8_t)44 shim::Acl::Acl(os::Handler* /* handler */, const acl_interface_t& acl_interface,
45 uint8_t /* max_address_resolution_size */)
46 : acl_interface_(acl_interface) {
47 inc_func_call_count(__func__);
48 }
~Acl()49 shim::Acl::~Acl() { inc_func_call_count(__func__); }
50
CheckForOrphanedAclConnections() const51 bool shim::Acl::CheckForOrphanedAclConnections() const {
52 inc_func_call_count(__func__);
53 return false;
54 }
55
on_incoming_acl_credits(uint16_t,uint16_t)56 void shim::Acl::on_incoming_acl_credits(uint16_t /* handle */, uint16_t /* credits */) {
57 inc_func_call_count(__func__);
58 }
59
60 using HciHandle = uint16_t;
61
62 struct shim::Acl::impl {};
63
CreateClassicConnection(const hci::Address &)64 void shim::Acl::CreateClassicConnection(const hci::Address& /* address */) {
65 inc_func_call_count(__func__);
66 }
67
CancelClassicConnection(const hci::Address &)68 void shim::Acl::CancelClassicConnection(const hci::Address& /* address */) {
69 inc_func_call_count(__func__);
70 }
71
OnClassicLinkDisconnected(HciHandle,hci::ErrorCode)72 void bluetooth::shim::Acl::OnClassicLinkDisconnected(HciHandle /* handle */,
73 hci::ErrorCode /* reason */) {
74 inc_func_call_count(__func__);
75 }
76
GetConnectionLocalAddress(uint16_t,bool,std::promise<bluetooth::hci::AddressWithType>)77 void shim::Acl::GetConnectionLocalAddress(
78 uint16_t /* handle */, bool /* ota_address */,
79 std::promise<bluetooth::hci::AddressWithType> /* promise */) {
80 inc_func_call_count(__func__);
81 }
82
GetConnectionPeerAddress(uint16_t,bool,std::promise<bluetooth::hci::AddressWithType>)83 void shim::Acl::GetConnectionPeerAddress(
84 uint16_t /* handle */, bool /* ota_address */,
85 std::promise<bluetooth::hci::AddressWithType> /* promise */) {
86 inc_func_call_count(__func__);
87 }
88
GetAdvertisingSetConnectedTo(const RawAddress &,std::promise<std::optional<uint8_t>>)89 void shim::Acl::GetAdvertisingSetConnectedTo(
90 const RawAddress& /* remote_bda */, std::promise<std::optional<uint8_t>> /* promise */) {
91 inc_func_call_count(__func__);
92 }
93
OnLeLinkDisconnected(HciHandle,hci::ErrorCode)94 void shim::Acl::OnLeLinkDisconnected(HciHandle /* handle */, hci::ErrorCode /* reason */) {
95 inc_func_call_count(__func__);
96 }
97
OnConnectSuccess(std::unique_ptr<hci::acl_manager::ClassicAclConnection>)98 void shim::Acl::OnConnectSuccess(
99 std::unique_ptr<hci::acl_manager::ClassicAclConnection> /* connection */) {
100 inc_func_call_count(__func__);
101 }
102
OnConnectRequest(hci::Address,hci::ClassOfDevice)103 void shim::Acl::OnConnectRequest(hci::Address /* address */, hci::ClassOfDevice /* cod */) {
104 inc_func_call_count(__func__);
105 }
OnConnectFail(hci::Address,hci::ErrorCode,bool)106 void shim::Acl::OnConnectFail(hci::Address /* address */, hci::ErrorCode /* reason */,
107 bool /* locally_initiated */) {
108 inc_func_call_count(__func__);
109 }
110
OnLeConnectSuccess(hci::AddressWithType,std::unique_ptr<hci::acl_manager::LeAclConnection>)111 void shim::Acl::OnLeConnectSuccess(
112 hci::AddressWithType /* address_with_type */,
113 std::unique_ptr<hci::acl_manager::LeAclConnection> /* connection */) {
114 inc_func_call_count(__func__);
115 }
116
OnLeConnectFail(hci::AddressWithType,hci::ErrorCode)117 void shim::Acl::OnLeConnectFail(hci::AddressWithType /* address_with_type */,
118 hci::ErrorCode /* reason */) {
119 inc_func_call_count(__func__);
120 }
121
DisconnectClassic(uint16_t,tHCI_STATUS,std::string)122 void shim::Acl::DisconnectClassic(uint16_t /* handle */, tHCI_STATUS /* reason */,
123 std::string /* comment */) {
124 inc_func_call_count(__func__);
125 }
126
DisconnectLe(uint16_t,tHCI_STATUS,std::string)127 void shim::Acl::DisconnectLe(uint16_t /* handle */, tHCI_STATUS /* reason */,
128 std::string /* comment */) {
129 inc_func_call_count(__func__);
130 }
131
LeSubrateRequest(uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)132 void shim::Acl::LeSubrateRequest(uint16_t /* hci_handle */, uint16_t /* subrate_min */,
133 uint16_t /* subrate_max */, uint16_t /* max_latency */,
134 uint16_t /* cont_num */, uint16_t /* sup_tout */) {
135 inc_func_call_count(__func__);
136 }
137
DumpConnectionHistory(int) const138 void shim::Acl::DumpConnectionHistory(int /* fd */) const { inc_func_call_count(__func__); }
139
DisconnectAllForSuspend()140 void shim::Acl::DisconnectAllForSuspend() { inc_func_call_count(__func__); }
141
Shutdown()142 void shim::Acl::Shutdown() { inc_func_call_count(__func__); }
143
FinalShutdown()144 void shim::Acl::FinalShutdown() { inc_func_call_count(__func__); }
145
ClearFilterAcceptList()146 void shim::Acl::ClearFilterAcceptList() { inc_func_call_count(__func__); }
147
AddToAddressResolution(const hci::AddressWithType &,const std::array<uint8_t,16> &,const std::array<uint8_t,16> &)148 void shim::Acl::AddToAddressResolution(const hci::AddressWithType& /* address_with_type */,
149 const std::array<uint8_t, 16>& /* peer_irk */,
150 const std::array<uint8_t, 16>& /* local_irk */) {
151 inc_func_call_count(__func__);
152 }
153
RemoveFromAddressResolution(const hci::AddressWithType &)154 void shim::Acl::RemoveFromAddressResolution(const hci::AddressWithType& /* address_with_type */) {
155 inc_func_call_count(__func__);
156 }
157
ClearAddressResolution()158 void shim::Acl::ClearAddressResolution() { inc_func_call_count(__func__); }
159
SetSystemSuspendState(bool)160 void shim::Acl::SetSystemSuspendState(bool /* suspended */) { inc_func_call_count(__func__); }
161
UpdateConnectionParameters(uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t,uint16_t)162 void shim::Acl::UpdateConnectionParameters(uint16_t /* handle */, uint16_t /* conn_int_min */,
163 uint16_t /* conn_int_max */, uint16_t /* conn_latency */,
164 uint16_t /* conn_timeout */, uint16_t /* min_ce_len */,
165 uint16_t /* max_ce_len */) {
166 inc_func_call_count(__func__);
167 }
168