hci_queue_end_->RegisterDequeue(
handler_, common::Bind(&impl::dequeue_and_route_acl_packet_to_connection, common::Unretained(this)));
classic_impl_ = new classic_impl(hci_layer_, controller_, handler_, round_robin_scheduler_);
- le_impl_ = new le_impl(hci_layer_, controller_, handler_, round_robin_scheduler_, classic_impl_);
+ le_impl_ = new le_impl(hci_layer_, controller_, handler_, round_robin_scheduler_);
}
void Stop() {
#include "common/bind.h"
#include "hci/acl_manager/assembler.h"
-#include "hci/acl_manager/disconnector_for_le.h"
#include "hci/acl_manager/event_checkers.h"
#include "hci/acl_manager/round_robin_scheduler.h"
#include "hci/controller.h"
ConnectionManagementCallbacks* connection_management_callbacks_ = nullptr;
};
-struct classic_impl : public DisconnectorForLe, public security::ISecurityManagerListener {
+struct classic_impl : public security::ISecurityManagerListener {
classic_impl(HciLayer* hci_layer, Controller* controller, os::Handler* handler,
RoundRobinScheduler* round_robin_scheduler)
: hci_layer_(hci_layer), controller_(controller), round_robin_scheduler_(round_robin_scheduler) {
+++ /dev/null
-/*
- * Copyright 2020 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 "hci/hci_packets.h"
-
-namespace bluetooth {
-namespace hci {
-namespace acl_manager {
-
-class DisconnectorForLe {
- public:
- DisconnectorForLe() = default;
- virtual ~DisconnectorForLe() = default;
- virtual void handle_disconnect(uint16_t handle, DisconnectReason reason) = 0;
-};
-
-} // namespace acl_manager
-} // namespace hci
-} // namespace bluetooth
class LeAclConnectionTracker : public LeConnectionManagementCallbacks {
public:
- LeAclConnectionTracker(LeAclConnectionInterface* le_acl_connection_interface,
- common::OnceCallback<void(DisconnectReason reason)> disconnect)
- : le_acl_connection_interface_(le_acl_connection_interface), do_disconnect_(std::move(disconnect)) {}
+ LeAclConnectionTracker(LeAclConnectionInterface* le_acl_connection_interface)
+ : le_acl_connection_interface_(le_acl_connection_interface) {}
~LeAclConnectionTracker() override {
ASSERT(queued_callbacks_.empty());
}
#undef SAVE_OR_CALL
LeAclConnectionInterface* le_acl_connection_interface_;
- common::OnceCallback<void(DisconnectReason)> do_disconnect_;
os::Handler* client_handler_ = nullptr;
LeConnectionManagementCallbacks* client_callbacks_ = nullptr;
std::list<common::OnceClosure> queued_callbacks_;
};
struct LeAclConnection::impl {
- impl(LeAclConnectionInterface* le_acl_connection_interface, std::shared_ptr<Queue> queue,
- common::OnceCallback<void(DisconnectReason)> disconnect)
- : queue_(std::move(queue)), tracker(le_acl_connection_interface, std::move(disconnect)) {}
+ impl(LeAclConnectionInterface* le_acl_connection_interface, std::shared_ptr<Queue> queue)
+ : queue_(std::move(queue)), tracker(le_acl_connection_interface) {}
LeConnectionManagementCallbacks* GetEventCallbacks() {
ASSERT(!callbacks_given_);
callbacks_given_ = true;
: AclConnection(), local_address_(Address::kEmpty, AddressType::PUBLIC_DEVICE_ADDRESS),
remote_address_(Address::kEmpty, AddressType::PUBLIC_DEVICE_ADDRESS) {}
-LeAclConnection::LeAclConnection(std::shared_ptr<Queue> queue, LeAclConnectionInterface* le_acl_connection_interface,
- common::OnceCallback<void(DisconnectReason)> disconnect, uint16_t handle,
- AddressWithType local_address, AddressWithType remote_address, Role role)
- : AclConnection(queue->GetUpEnd(), handle), local_address_(local_address), remote_address_(remote_address),
+LeAclConnection::LeAclConnection(
+ std::shared_ptr<Queue> queue,
+ LeAclConnectionInterface* le_acl_connection_interface,
+ uint16_t handle,
+ AddressWithType local_address,
+ AddressWithType remote_address,
+ Role role)
+ : AclConnection(queue->GetUpEnd(), handle),
+ local_address_(local_address),
+ remote_address_(remote_address),
role_(role) {
- pimpl_ = new LeAclConnection::impl(le_acl_connection_interface, std::move(queue), std::move(disconnect));
+ pimpl_ = new LeAclConnection::impl(le_acl_connection_interface, std::move(queue));
}
LeAclConnection::~LeAclConnection() {
}
void LeAclConnection::Disconnect(DisconnectReason reason) {
- common::BindOnce(std::move(pimpl_->tracker.do_disconnect_), reason).Run();
+ pimpl_->tracker.le_acl_connection_interface_->EnqueueCommand(
+ DisconnectBuilder::Create(handle_, reason),
+ pimpl_->tracker.client_handler_->BindOnce([](CommandStatusView status) {
+ ASSERT(status.IsValid());
+ ASSERT(status.GetCommandOpCode() == OpCode::DISCONNECT);
+ auto disconnect_status = DisconnectStatusView::Create(status);
+ ASSERT(disconnect_status.IsValid());
+ auto error_code = disconnect_status.GetStatus();
+ if (error_code != ErrorCode::SUCCESS) {
+ LOG_INFO("Disconnect status %s", ErrorCodeText(error_code).c_str());
+ }
+ }));
}
LeConnectionManagementCallbacks* LeAclConnection::GetEventCallbacks() {
class LeAclConnection : public AclConnection {
public:
LeAclConnection();
- LeAclConnection(std::shared_ptr<Queue> queue, LeAclConnectionInterface* le_acl_connection_interface,
- common::OnceCallback<void(DisconnectReason)> disconnect, uint16_t handle,
- AddressWithType local_address, AddressWithType remote_address, Role role);
+ LeAclConnection(
+ std::shared_ptr<Queue> queue,
+ LeAclConnectionInterface* le_acl_connection_interface,
+ uint16_t handle,
+ AddressWithType local_address,
+ AddressWithType remote_address,
+ Role role);
~LeAclConnection() override;
virtual AddressWithType GetLocalAddress() const {
#include "common/bind.h"
#include "crypto_toolbox/crypto_toolbox.h"
#include "hci/acl_manager/assembler.h"
-#include "hci/acl_manager/disconnector_for_le.h"
#include "hci/acl_manager/round_robin_scheduler.h"
#include "hci/le_address_manager.h"
#include "os/alarm.h"
};
struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
- le_impl(HciLayer* hci_layer, Controller* controller, os::Handler* handler, RoundRobinScheduler* round_robin_scheduler,
- DisconnectorForLe* disconnector)
- : hci_layer_(hci_layer), controller_(controller), round_robin_scheduler_(round_robin_scheduler),
- disconnector_(disconnector) {
+ le_impl(HciLayer* hci_layer, Controller* controller, os::Handler* handler, RoundRobinScheduler* round_robin_scheduler)
+ : hci_layer_(hci_layer), controller_(controller), round_robin_scheduler_(round_robin_scheduler) {
hci_layer_ = hci_layer;
controller_ = controller;
handler_ = handler;
le_acl_connections_.emplace(std::piecewise_construct, std::forward_as_tuple(handle),
std::forward_as_tuple(remote_address, queue->GetDownEnd(), handler_));
auto& connection_proxy = check_and_get_le_connection(handle);
- auto do_disconnect =
- common::BindOnce(&DisconnectorForLe::handle_disconnect, common::Unretained(disconnector_), handle);
round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::LE, handle, queue);
- std::unique_ptr<LeAclConnection> connection(new LeAclConnection(std::move(queue), le_acl_connection_interface_,
- std::move(do_disconnect), handle, local_address,
- remote_address, role));
+ std::unique_ptr<LeAclConnection> connection(new LeAclConnection(
+ std::move(queue), le_acl_connection_interface_, handle, local_address, remote_address, role));
connection_proxy.le_connection_management_callbacks_ = connection->GetEventCallbacks();
le_client_handler_->Post(common::BindOnce(&LeConnectionCallbacks::OnLeConnectSuccess,
common::Unretained(le_client_callbacks_), remote_address,
std::forward_as_tuple(remote_address, queue->GetDownEnd(), handler_));
auto& connection_proxy = check_and_get_le_connection(handle);
round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::LE, handle, queue);
- auto do_disconnect =
- common::BindOnce(&DisconnectorForLe::handle_disconnect, common::Unretained(disconnector_), handle);
- std::unique_ptr<LeAclConnection> connection(new LeAclConnection(std::move(queue), le_acl_connection_interface_,
- std::move(do_disconnect), handle, local_address,
- remote_address, role));
+ std::unique_ptr<LeAclConnection> connection(new LeAclConnection(
+ std::move(queue), le_acl_connection_interface_, handle, local_address, remote_address, role));
connection_proxy.le_connection_management_callbacks_ = connection->GetEventCallbacks();
le_client_handler_->Post(common::BindOnce(&LeConnectionCallbacks::OnLeConnectSuccess,
common::Unretained(le_client_callbacks_), remote_address,
std::map<uint16_t, le_acl_connection> le_acl_connections_;
std::set<AddressWithType> connecting_le_;
std::set<AddressWithType> canceled_connections_;
- DisconnectorForLe* disconnector_;
bool address_manager_registered = false;
bool ready_to_unregister = false;
bool pause_connection = false;