Merge changes I4d7bb31a,I82cd5b4c
* changes:
L2CAP: Rename classic facade and minor refactor
L2CAP: Add mocks for fixed channel manager and classic module
diff --git a/gd/cert/grpc_root_server.cc b/gd/cert/grpc_root_server.cc
index 7281867..48b2d5a 100644
--- a/gd/cert/grpc_root_server.cc
+++ b/gd/cert/grpc_root_server.cc
@@ -59,7 +59,7 @@
break;
case BluetoothModule::L2CAP:
modules.add<::bluetooth::cert::ReadOnlyPropertyServerModule>();
- modules.add<::bluetooth::l2cap::classic::cert::L2capModuleCertModule>();
+ modules.add<::bluetooth::l2cap::classic::cert::L2capClassicModuleCertModule>();
break;
default:
return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test");
diff --git a/gd/facade/grpc_root_server.cc b/gd/facade/grpc_root_server.cc
index 29ccc59..e802dfe 100644
--- a/gd/facade/grpc_root_server.cc
+++ b/gd/facade/grpc_root_server.cc
@@ -60,7 +60,7 @@
break;
case BluetoothModule::L2CAP:
modules.add<::bluetooth::facade::ReadOnlyPropertyServerModule>();
- modules.add<::bluetooth::l2cap::classic::L2capModuleFacadeModule>();
+ modules.add<::bluetooth::l2cap::classic::L2capClassicModuleFacadeModule>();
break;
default:
return ::grpc::Status(::grpc::StatusCode::INVALID_ARGUMENT, "invalid module under test");
diff --git a/gd/hci/acl_manager.h b/gd/hci/acl_manager.h
index 27c4fb3..3706aba 100644
--- a/gd/hci/acl_manager.h
+++ b/gd/hci/acl_manager.h
@@ -151,7 +151,7 @@
private:
friend AclManager;
AclConnection(const AclManager* manager, uint16_t handle, Address address)
- : manager_(manager), handle_(handle), address_(address) {}
+ : manager_(manager), handle_(handle), address_(address), address_type_(AddressType::PUBLIC_DEVICE_ADDRESS) {}
AclConnection(const AclManager* manager, uint16_t handle, Address address, AddressType address_type, Role role)
: manager_(manager), handle_(handle), address_(address), address_type_(address_type), role_(role) {}
const AclManager* manager_;
diff --git a/gd/l2cap/classic/cert/api.proto b/gd/l2cap/classic/cert/api.proto
index c7e68d5..687686f 100644
--- a/gd/l2cap/classic/cert/api.proto
+++ b/gd/l2cap/classic/cert/api.proto
@@ -5,7 +5,7 @@
import "google/protobuf/empty.proto";
import "facade/common.proto";
-service L2capModuleCert {
+service L2capClassicModuleCert {
rpc SendL2capPacket(L2capPacket) returns (google.protobuf.Empty) {}
rpc SetupLink(SetupLinkRequest) returns (SetupLinkResponse) {}
diff --git a/gd/l2cap/classic/cert/cert.cc b/gd/l2cap/classic/cert/cert.cc
index 63c8593..2de345c 100644
--- a/gd/l2cap/classic/cert/cert.cc
+++ b/gd/l2cap/classic/cert/cert.cc
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-#include "l2cap/classic/cert/cert.h"
-
#include <condition_variable>
#include <cstdint>
#include <memory>
@@ -29,6 +27,7 @@
#include "hci/cert/cert.h"
#include "hci/hci_packets.h"
#include "l2cap/classic/cert/api.grpc.pb.h"
+#include "l2cap/classic/cert/cert.h"
#include "l2cap/classic/l2cap_classic_module.h"
#include "l2cap/l2cap_packets.h"
#include "os/log.h"
@@ -52,9 +51,9 @@
constexpr auto kEventTimeout = std::chrono::seconds(1);
-class L2capModuleCertService : public L2capModuleCert::Service {
+class L2capClassicModuleCertService : public L2capClassicModuleCert::Service {
public:
- L2capModuleCertService(hci::AclManager* acl_manager, os::Handler* facade_handler)
+ L2capClassicModuleCertService(hci::AclManager* acl_manager, os::Handler* facade_handler)
: handler_(facade_handler), acl_manager_(acl_manager) {
ASSERT(handler_ != nullptr);
acl_manager_->RegisterCallbacks(&acl_callbacks, handler_);
@@ -323,7 +322,7 @@
void send_packet_from_queue() {
if (outgoing_packet_queue_.size() == 1) {
acl_connection_->GetAclQueueEnd()->RegisterEnqueue(
- handler_, common::Bind(&L2capModuleCertService::enqueue_packet_to_acl, common::Unretained(this)));
+ handler_, common::Bind(&L2capClassicModuleCertService::enqueue_packet_to_acl, common::Unretained(this)));
}
}
@@ -473,12 +472,13 @@
class AclCallbacks : public hci::ConnectionCallbacks {
public:
- AclCallbacks(L2capModuleCertService* module) : module_(module) {}
+ AclCallbacks(L2capClassicModuleCertService* module) : module_(module) {}
void OnConnectSuccess(std::unique_ptr<hci::AclConnection> connection) override {
module_->acl_connection_ = std::move(connection);
module_->acl_connection_->RegisterDisconnectCallback(common::BindOnce([](hci::ErrorCode) {}), module_->handler_);
module_->acl_connection_->GetAclQueueEnd()->RegisterDequeue(
- module_->handler_, common::Bind(&L2capModuleCertService::on_incoming_packet, common::Unretained(module_)));
+ module_->handler_,
+ common::Bind(&L2capClassicModuleCertService::on_incoming_packet, common::Unretained(module_)));
dequeue_registered_ = true;
FetchL2capLogResponse response;
response.mutable_link_up()->mutable_remote()->set_address(module_->acl_connection_->GetAddress().ToString());
@@ -494,36 +494,36 @@
bool dequeue_registered_ = false;
- L2capModuleCertService* module_;
+ L2capClassicModuleCertService* module_;
} acl_callbacks{this};
std::mutex mutex_;
};
-void L2capModuleCertModule::ListDependencies(ModuleList* list) {
+void L2capClassicModuleCertModule::ListDependencies(ModuleList* list) {
::bluetooth::grpc::GrpcFacadeModule::ListDependencies(list);
list->add<hci::AclManager>();
list->add<hci::HciLayer>();
}
-void L2capModuleCertModule::Start() {
+void L2capClassicModuleCertModule::Start() {
::bluetooth::grpc::GrpcFacadeModule::Start();
GetDependency<hci::HciLayer>()->EnqueueCommand(hci::WriteScanEnableBuilder::Create(hci::ScanEnable::PAGE_SCAN_ONLY),
common::BindOnce([](hci::CommandCompleteView) {}), GetHandler());
- service_ = new L2capModuleCertService(GetDependency<hci::AclManager>(), GetHandler());
+ service_ = new L2capClassicModuleCertService(GetDependency<hci::AclManager>(), GetHandler());
}
-void L2capModuleCertModule::Stop() {
+void L2capClassicModuleCertModule::Stop() {
delete service_;
::bluetooth::grpc::GrpcFacadeModule::Stop();
}
-::grpc::Service* L2capModuleCertModule::GetService() const {
+::grpc::Service* L2capClassicModuleCertModule::GetService() const {
return service_;
}
-const ModuleFactory L2capModuleCertModule::Factory =
- ::bluetooth::ModuleFactory([]() { return new L2capModuleCertModule(); });
+const ModuleFactory L2capClassicModuleCertModule::Factory =
+ ::bluetooth::ModuleFactory([]() { return new L2capClassicModuleCertModule(); });
} // namespace cert
} // namespace classic
diff --git a/gd/l2cap/classic/cert/cert.h b/gd/l2cap/classic/cert/cert.h
index c8015d6..d3108cd 100644
--- a/gd/l2cap/classic/cert/cert.h
+++ b/gd/l2cap/classic/cert/cert.h
@@ -9,9 +9,9 @@
namespace classic {
namespace cert {
-class L2capModuleCertService;
+class L2capClassicModuleCertService;
-class L2capModuleCertModule : public ::bluetooth::grpc::GrpcFacadeModule {
+class L2capClassicModuleCertModule : public ::bluetooth::grpc::GrpcFacadeModule {
public:
static const ModuleFactory Factory;
@@ -22,7 +22,7 @@
::grpc::Service* GetService() const override;
private:
- L2capModuleCertService* service_;
+ L2capClassicModuleCertService* service_;
};
} // namespace cert
diff --git a/gd/l2cap/classic/facade.cc b/gd/l2cap/classic/facade.cc
index 9613c75..64f3810 100644
--- a/gd/l2cap/classic/facade.cc
+++ b/gd/l2cap/classic/facade.cc
@@ -39,9 +39,9 @@
namespace l2cap {
namespace classic {
-class L2capModuleFacadeService : public L2capModuleFacade::Service {
+class L2capClassicModuleFacadeService : public L2capClassicModuleFacade::Service {
public:
- L2capModuleFacadeService(L2capClassicModule* l2cap_layer, os::Handler* facade_handler)
+ L2capClassicModuleFacadeService(L2capClassicModule* l2cap_layer, os::Handler* facade_handler)
: l2cap_layer_(l2cap_layer), facade_handler_(facade_handler) {
ASSERT(l2cap_layer_ != nullptr);
ASSERT(facade_handler_ != nullptr);
@@ -126,8 +126,8 @@
class L2capFixedChannelHelper {
public:
- L2capFixedChannelHelper(L2capModuleFacadeService* service, L2capClassicModule* l2cap_layer, os::Handler* handler,
- Cid cid)
+ L2capFixedChannelHelper(L2capClassicModuleFacadeService* service, L2capClassicModule* l2cap_layer,
+ os::Handler* handler, Cid cid)
: facade_service_(service), l2cap_layer_(l2cap_layer), handler_(handler), cid_(cid) {
fixed_channel_manager_ = l2cap_layer_->GetFixedChannelManager();
fixed_channel_manager_->RegisterService(
@@ -173,7 +173,7 @@
return packet_one;
};
- L2capModuleFacadeService* facade_service_;
+ L2capClassicModuleFacadeService* facade_service_;
L2capClassicModule* l2cap_layer_;
os::Handler* handler_;
std::unique_ptr<FixedChannelManager> fixed_channel_manager_;
@@ -192,8 +192,8 @@
class L2capDynamicChannelHelper {
public:
- L2capDynamicChannelHelper(L2capModuleFacadeService* service, L2capClassicModule* l2cap_layer, os::Handler* handler,
- Psm psm, RetransmissionFlowControlMode mode)
+ L2capDynamicChannelHelper(L2capClassicModuleFacadeService* service, L2capClassicModule* l2cap_layer,
+ os::Handler* handler, Psm psm, RetransmissionFlowControlMode mode)
: facade_service_(service), l2cap_layer_(l2cap_layer), handler_(handler), psm_(psm) {
dynamic_channel_manager_ = l2cap_layer_->GetDynamicChannelManager();
DynamicChannelConfigurationOption configuration_option;
@@ -255,7 +255,7 @@
return packet_one;
};
- L2capModuleFacadeService* facade_service_;
+ L2capClassicModuleFacadeService* facade_service_;
L2capClassicModule* l2cap_layer_;
os::Handler* handler_;
std::unique_ptr<DynamicChannelManager> dynamic_channel_manager_;
@@ -271,7 +271,7 @@
class L2capStreamCallback : public ::bluetooth::grpc::GrpcEventStreamCallback<L2capPacket, L2capPacket> {
public:
- L2capStreamCallback(L2capModuleFacadeService* service) : service_(service) {}
+ L2capStreamCallback(L2capClassicModuleFacadeService* service) : service_(service) {}
~L2capStreamCallback() {
for (const auto& connection : service_->fixed_channel_helper_map_) {
@@ -329,7 +329,7 @@
response->CopyFrom(event);
}
- L2capModuleFacadeService* service_;
+ L2capClassicModuleFacadeService* service_;
std::map<Cid, bool> subscribed_fixed_channel_;
std::map<Psm, bool> subscribed_dynamic_channel_;
@@ -339,30 +339,30 @@
std::mutex mutex_;
};
-void L2capModuleFacadeModule::ListDependencies(ModuleList* list) {
+void L2capClassicModuleFacadeModule::ListDependencies(ModuleList* list) {
::bluetooth::grpc::GrpcFacadeModule::ListDependencies(list);
list->add<l2cap::classic::L2capClassicModule>();
list->add<hci::HciLayer>();
}
-void L2capModuleFacadeModule::Start() {
+void L2capClassicModuleFacadeModule::Start() {
::bluetooth::grpc::GrpcFacadeModule::Start();
GetDependency<hci::HciLayer>()->EnqueueCommand(hci::WriteScanEnableBuilder::Create(hci::ScanEnable::PAGE_SCAN_ONLY),
common::BindOnce([](hci::CommandCompleteView) {}), GetHandler());
- service_ = new L2capModuleFacadeService(GetDependency<l2cap::classic::L2capClassicModule>(), GetHandler());
+ service_ = new L2capClassicModuleFacadeService(GetDependency<l2cap::classic::L2capClassicModule>(), GetHandler());
}
-void L2capModuleFacadeModule::Stop() {
+void L2capClassicModuleFacadeModule::Stop() {
delete service_;
::bluetooth::grpc::GrpcFacadeModule::Stop();
}
-::grpc::Service* L2capModuleFacadeModule::GetService() const {
+::grpc::Service* L2capClassicModuleFacadeModule::GetService() const {
return service_;
}
-const ModuleFactory L2capModuleFacadeModule::Factory =
- ::bluetooth::ModuleFactory([]() { return new L2capModuleFacadeModule(); });
+const ModuleFactory L2capClassicModuleFacadeModule::Factory =
+ ::bluetooth::ModuleFactory([]() { return new L2capClassicModuleFacadeModule(); });
} // namespace classic
} // namespace l2cap
diff --git a/gd/l2cap/classic/facade.h b/gd/l2cap/classic/facade.h
index 425940a..ebaee0d 100644
--- a/gd/l2cap/classic/facade.h
+++ b/gd/l2cap/classic/facade.h
@@ -16,15 +16,16 @@
#pragma once
#include <grpc++/grpc++.h>
+
#include "grpc/grpc_module.h"
namespace bluetooth {
namespace l2cap {
namespace classic {
-class L2capModuleFacadeService;
+class L2capClassicModuleFacadeService;
-class L2capModuleFacadeModule : public ::bluetooth::grpc::GrpcFacadeModule {
+class L2capClassicModuleFacadeModule : public ::bluetooth::grpc::GrpcFacadeModule {
public:
static const ModuleFactory Factory;
@@ -35,7 +36,7 @@
::grpc::Service* GetService() const override;
private:
- L2capModuleFacadeService* service_;
+ L2capClassicModuleFacadeService* service_;
};
} // namespace classic
diff --git a/gd/l2cap/classic/facade.proto b/gd/l2cap/classic/facade.proto
index 7eb780d..ab2a911 100644
--- a/gd/l2cap/classic/facade.proto
+++ b/gd/l2cap/classic/facade.proto
@@ -5,7 +5,7 @@
import "google/protobuf/empty.proto";
import "facade/common.proto";
-service L2capModuleFacade {
+service L2capClassicModuleFacade {
rpc RegisterChannel(RegisterChannelRequest) returns (google.protobuf.Empty) {
// Testing Android Bluetooth stack only. Optional for other stack.
}
diff --git a/gd/l2cap/classic/fixed_channel_manager.h b/gd/l2cap/classic/fixed_channel_manager.h
index 69812df..5e8f6ab 100644
--- a/gd/l2cap/classic/fixed_channel_manager.h
+++ b/gd/l2cap/classic/fixed_channel_manager.h
@@ -31,6 +31,10 @@
class L2capClassicModule;
+namespace testing {
+class MockFixedChannelManager;
+}
+
namespace internal {
class LinkManager;
class FixedChannelServiceManagerImpl;
@@ -102,7 +106,7 @@
*
* Returns: true if connection was able to be initiated, false otherwise.
*/
- bool ConnectServices(hci::Address device, OnConnectionFailureCallback on_fail_callback, os::Handler* handler);
+ virtual bool ConnectServices(hci::Address device, OnConnectionFailureCallback on_fail_callback, os::Handler* handler);
/**
* Register a service to receive incoming connections bound to a specific channel.
@@ -124,11 +128,14 @@
* @param on_open_callback: A callback to indicate success of a connection initiated from a remote device.
* @param handler: The handler context in which to execute the @callback parameter.
*/
- bool RegisterService(Cid cid, const SecurityPolicy& security_policy,
- OnRegistrationCompleteCallback on_registration_complete,
- OnConnectionOpenCallback on_connection_open, os::Handler* handler);
+ virtual bool RegisterService(Cid cid, const SecurityPolicy& security_policy,
+ OnRegistrationCompleteCallback on_registration_complete,
+ OnConnectionOpenCallback on_connection_open, os::Handler* handler);
+
+ virtual ~FixedChannelManager() = default;
friend class L2capClassicModule;
+ friend class testing::MockFixedChannelManager;
private:
// The constructor is not to be used by user code
diff --git a/gd/l2cap/classic/fixed_channel_manager_mock.h b/gd/l2cap/classic/fixed_channel_manager_mock.h
new file mode 100644
index 0000000..5ead957
--- /dev/null
+++ b/gd/l2cap/classic/fixed_channel_manager_mock.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2019 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.
+ */
+#pragma once
+
+#include "l2cap/classic/fixed_channel_manager.h"
+
+#include <gmock/gmock.h>
+
+// Unit test interfaces
+namespace bluetooth {
+namespace l2cap {
+namespace classic {
+namespace testing {
+
+class MockFixedChannelManager : public FixedChannelManager {
+ public:
+ MockFixedChannelManager() : FixedChannelManager(nullptr, nullptr, nullptr){};
+ MOCK_METHOD(bool, ConnectServices,
+ (hci::Address device, OnConnectionFailureCallback on_fail_callback, os::Handler* handler), (override));
+ MOCK_METHOD(bool, RegisterService,
+ (Cid cid, const SecurityPolicy& security_policy, OnRegistrationCompleteCallback on_registration_complete,
+ OnConnectionOpenCallback on_connection_open, os::Handler* handler),
+ (override));
+};
+
+} // namespace testing
+} // namespace classic
+} // namespace l2cap
+} // namespace bluetooth
diff --git a/gd/l2cap/classic/internal/link.h b/gd/l2cap/classic/internal/link.h
index 2c6c1b8..09d7eb9 100644
--- a/gd/l2cap/classic/internal/link.h
+++ b/gd/l2cap/classic/internal/link.h
@@ -99,7 +99,7 @@
virtual void NotifyChannelCreation(Cid cid, std::unique_ptr<DynamicChannel> channel);
virtual void NotifyChannelFail(Cid cid);
- // Information received from signalling channel
+ // Information received from signaling channel
virtual void SetRemoteConnectionlessMtu(Mtu mtu);
virtual Mtu GetRemoteConnectionlessMtu() const;
virtual void SetRemoteSupportsErtm(bool supported);
@@ -107,6 +107,10 @@
virtual void SetRemoteSupportsFcs(bool supported);
virtual bool GetRemoteSupportsFcs() const;
+ virtual std::string ToString() {
+ return GetDevice().ToString();
+ }
+
private:
os::Handler* l2cap_handler_;
l2cap::internal::FixedChannelAllocator<FixedChannelImpl, Link> fixed_channel_allocator_{this, l2cap_handler_};
diff --git a/gd/l2cap/classic/l2cap_classic_module.cc b/gd/l2cap/classic/l2cap_classic_module.cc
index bc30c86..ca5a0d5 100644
--- a/gd/l2cap/classic/l2cap_classic_module.cc
+++ b/gd/l2cap/classic/l2cap_classic_module.cc
@@ -50,6 +50,10 @@
&dynamic_channel_service_manager_impl_, ¶meter_provider_};
};
+L2capClassicModule::L2capClassicModule() {}
+
+L2capClassicModule::~L2capClassicModule() {}
+
void L2capClassicModule::ListDependencies(ModuleList* list) {
list->add<hci::AclManager>();
}
@@ -78,4 +82,4 @@
} // namespace classic
} // namespace l2cap
-} // namespace bluetooth
\ No newline at end of file
+} // namespace bluetooth
diff --git a/gd/l2cap/classic/l2cap_classic_module.h b/gd/l2cap/classic/l2cap_classic_module.h
index 7255bc3..388cae2 100644
--- a/gd/l2cap/classic/l2cap_classic_module.h
+++ b/gd/l2cap/classic/l2cap_classic_module.h
@@ -27,18 +27,18 @@
class L2capClassicModule : public bluetooth::Module {
public:
- L2capClassicModule() = default;
- ~L2capClassicModule() = default;
+ L2capClassicModule();
+ virtual ~L2capClassicModule();
/**
* Get the api to the classic fixed channel l2cap module
*/
- std::unique_ptr<FixedChannelManager> GetFixedChannelManager();
+ virtual std::unique_ptr<FixedChannelManager> GetFixedChannelManager();
/**
* Get the api to the classic dynamic channel l2cap module
*/
- std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager();
+ virtual std::unique_ptr<DynamicChannelManager> GetDynamicChannelManager();
static const ModuleFactory Factory;
@@ -59,4 +59,4 @@
} // namespace classic
} // namespace l2cap
-} // namespace bluetooth
\ No newline at end of file
+} // namespace bluetooth
diff --git a/gd/l2cap/classic/l2cap_classic_module_mock.h b/gd/l2cap/classic/l2cap_classic_module_mock.h
new file mode 100644
index 0000000..1252854
--- /dev/null
+++ b/gd/l2cap/classic/l2cap_classic_module_mock.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2019 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.
+ */
+#pragma once
+
+#include "l2cap/classic/l2cap_classic_module.h"
+
+#include <gmock/gmock.h>
+
+// Unit test interfaces
+namespace bluetooth {
+namespace l2cap {
+namespace classic {
+namespace testing {
+
+class MockL2capClassicModule : public L2capClassicModule {
+ public:
+ MOCK_METHOD(std::unique_ptr<FixedChannelManager>, GetFixedChannelManager, (), (override));
+ MOCK_METHOD(std::unique_ptr<DynamicChannelManager>, GetDynamicChannelManager, (), (override));
+};
+
+} // namespace testing
+} // namespace classic
+} // namespace l2cap
+} // namespace bluetooth
diff --git a/gd/l2cap/internal/fixed_channel_allocator.h b/gd/l2cap/internal/fixed_channel_allocator.h
index a421c91..b821cb1 100644
--- a/gd/l2cap/internal/fixed_channel_allocator.h
+++ b/gd/l2cap/internal/fixed_channel_allocator.h
@@ -44,20 +44,17 @@
// Allocates a channel. If cid is used, return nullptr. NOTE: The returned BaseFixedChannelImpl object is still
// owned by the channel allocator, NOT the client.
virtual std::shared_ptr<FixedChannelImplType> AllocateChannel(Cid cid, SecurityPolicy security_policy) {
- ASSERT_LOG(!IsChannelAllocated((cid)), "Cid 0x%x for device %s is already in use", cid,
- link_->GetDevice().ToString().c_str());
+ ASSERT_LOG(!IsChannelAllocated((cid)), "Cid 0x%x for link %s is already in use", cid, link_->ToString().c_str());
ASSERT_LOG(cid >= kFirstFixedChannel && cid <= kLastFixedChannel, "Cid %d out of bound", cid);
auto elem = channels_.try_emplace(cid, std::make_shared<FixedChannelImplType>(cid, link_, l2cap_handler_));
- ASSERT_LOG(elem.second, "Failed to create channel for cid 0x%x device %s", cid,
- link_->GetDevice().ToString().c_str());
+ ASSERT_LOG(elem.second, "Failed to create channel for cid 0x%x link %s", cid, link_->ToString().c_str());
ASSERT(elem.first->second != nullptr);
return elem.first->second;
}
// Frees a channel. If cid doesn't exist, it will crash
virtual void FreeChannel(Cid cid) {
- ASSERT_LOG(IsChannelAllocated(cid), "Channel is not in use: cid %d, device %s", cid,
- link_->GetDevice().ToString().c_str());
+ ASSERT_LOG(IsChannelAllocated(cid), "Channel is not in use: cid %d, link %s", cid, link_->ToString().c_str());
channels_.erase(cid);
}
@@ -66,8 +63,7 @@
}
virtual std::shared_ptr<FixedChannelImplType> FindChannel(Cid cid) {
- ASSERT_LOG(IsChannelAllocated(cid), "Channel is not in use: cid %d, device %s", cid,
- link_->GetDevice().ToString().c_str());
+ ASSERT_LOG(IsChannelAllocated(cid), "Channel is not in use: cid %d, link %s", cid, link_->ToString().c_str());
return channels_.find(cid)->second;
}
diff --git a/gd/l2cap/le/fixed_channel.cc b/gd/l2cap/le/fixed_channel.cc
index 1e6a163..d02dad6 100644
--- a/gd/l2cap/le/fixed_channel.cc
+++ b/gd/l2cap/le/fixed_channel.cc
@@ -49,4 +49,4 @@
}
} // namespace le
} // namespace l2cap
-} // namespace bluetooth
\ No newline at end of file
+} // namespace bluetooth
diff --git a/gd/l2cap/le/fixed_channel_manager.h b/gd/l2cap/le/fixed_channel_manager.h
index ea1a346..4583310 100644
--- a/gd/l2cap/le/fixed_channel_manager.h
+++ b/gd/l2cap/le/fixed_channel_manager.h
@@ -50,9 +50,9 @@
hci::ErrorCode hci_error = hci::ErrorCode::SUCCESS;
};
/**
- * OnConnectionFailureCallback(std::string failure_reason);
+ * OnConnectionFailureCallback(ConnectionResult failure_reason);
*/
- using OnConnectionFailureCallback = common::OnceCallback<void(ConnectionResult result)>;
+ using OnConnectionFailureCallback = common::OnceCallback<void(ConnectionResult)>;
/**
* OnConnectionOpenCallback(FixedChannel channel);
diff --git a/gd/l2cap/le/internal/fixed_channel_impl_test.cc b/gd/l2cap/le/internal/fixed_channel_impl_test.cc
index 9874936..a4270b4 100644
--- a/gd/l2cap/le/internal/fixed_channel_impl_test.cc
+++ b/gd/l2cap/le/internal/fixed_channel_impl_test.cc
@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include "l2cap/le/internal/fixed_channel_impl.h"
-
#include "common/testing/bind_test_util.h"
+#include "hci/address_with_type.h"
#include "l2cap/cid.h"
#include "l2cap/internal/parameter_provider_mock.h"
#include "l2cap/le/internal/link_mock.h"
diff --git a/gd/l2cap/le/internal/link.h b/gd/l2cap/le/internal/link.h
index 5dc8ae4..783e03b 100644
--- a/gd/l2cap/le/internal/link.h
+++ b/gd/l2cap/le/internal/link.h
@@ -90,6 +90,10 @@
}
}
+ virtual std::string ToString() {
+ return GetDevice().ToString();
+ }
+
private:
os::Handler* l2cap_handler_;
l2cap::internal::FixedChannelAllocator<FixedChannelImpl, Link> fixed_channel_allocator_{this, l2cap_handler_};
diff --git a/gd/l2cap/le/internal/link_mock.h b/gd/l2cap/le/internal/link_mock.h
index 3411c95..08ea629 100644
--- a/gd/l2cap/le/internal/link_mock.h
+++ b/gd/l2cap/le/internal/link_mock.h
@@ -16,7 +16,7 @@
#pragma once
#include "hci/acl_manager_mock.h"
-#include "hci/address.h"
+#include "hci/address_with_type.h"
#include "l2cap/internal/scheduler_mock.h"
#include "l2cap/le/internal/link.h"
@@ -50,4 +50,4 @@
} // namespace internal
} // namespace le
} // namespace l2cap
-} // namespace bluetooth
\ No newline at end of file
+} // namespace bluetooth