" creation_time:%s teardown_time:%s disconnect_reason:%s",
GetPrivateRemoteAddress().c_str(), handle_,
logbool(is_locally_initiated_).c_str(),
- bluetooth::common::StringFormatTimeWithMilliseconds(
+ common::StringFormatTimeWithMilliseconds(
kConnectionDescriptorTimeFormat, creation_time_)
.c_str(),
- bluetooth::common::StringFormatTimeWithMilliseconds(
+ common::StringFormatTimeWithMilliseconds(
kConnectionDescriptorTimeFormat, teardown_time_)
.c_str(),
hci::ErrorCodeText(disconnect_reason_).c_str());
inline uint8_t LowByte(uint16_t val) { return val & 0xff; }
inline uint8_t HighByte(uint16_t val) { return val >> 8; }
-void ValidateAclInterface(
- const bluetooth::shim::legacy::acl_interface_t& acl_interface) {
+void ValidateAclInterface(const shim::legacy::acl_interface_t& acl_interface) {
ASSERT_LOG(acl_interface.on_send_data_upwards != nullptr,
"Must provide to receive data on acl links");
ASSERT_LOG(acl_interface.on_packets_completed != nullptr,
"Shim Acl was not properly disconnected handle:0x%04x", handle_);
}
- void EnqueuePacket(std::unique_ptr<bluetooth::packet::RawBuilder> packet) {
+ void EnqueuePacket(std::unique_ptr<packet::RawBuilder> packet) {
// TODO Handle queue size exceeds some threshold
queue_.push(std::move(packet));
RegisterEnqueue();
}
- std::unique_ptr<bluetooth::packet::BasePacketBuilder> handle_enqueue() {
+ std::unique_ptr<packet::BasePacketBuilder> handle_enqueue() {
auto packet = std::move(queue_.front());
queue_.pop();
if (queue_.empty()) {
SendDataUpwards send_data_upwards_;
hci::acl_manager::AclConnection::QueueUpEnd* queue_up_end_;
- std::queue<std::unique_ptr<bluetooth::packet::RawBuilder>> queue_;
+ std::queue<std::unique_ptr<packet::RawBuilder>> queue_;
bool is_enqueue_registered_{false};
bool is_disconnected_{false};
CreationTime creation_time_;
std::unique_ptr<hci::acl_manager::LeAclConnection> connection_;
};
-struct bluetooth::shim::legacy::Acl::impl {
+struct shim::legacy::Acl::impl {
std::map<HciHandle, std::unique_ptr<ClassicShimAclConnection>>
handle_to_classic_connection_map_;
std::map<HciHandle, std::unique_ptr<LeShimAclConnection>>
handle_to_classic_connection_map_.end();
}
- void EnqueueClassicPacket(
- HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) {
+ void EnqueueClassicPacket(HciHandle handle,
+ std::unique_ptr<packet::RawBuilder> packet) {
ASSERT_LOG(IsClassicAcl(handle), "handle %d is not a classic connection",
handle);
handle_to_classic_connection_map_[handle]->EnqueuePacket(std::move(packet));
}
void EnqueueLePacket(HciHandle handle,
- std::unique_ptr<bluetooth::packet::RawBuilder> packet) {
+ std::unique_ptr<packet::RawBuilder> packet) {
ASSERT_LOG(IsLeAcl(handle), "handle %d is not a LE connection", handle);
handle_to_le_connection_map_[handle]->EnqueuePacket(std::move(packet));
}
LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG);
- bluetooth::shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd);
+ shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd);
for (int i = 0; i < MAX_L2CAP_LINKS; i++) {
const tACL_CONN& acl_conn = acl_cb.acl_db[i];
}
#undef DUMPSYS_TAG
-using Record = bluetooth::common::TimestampedEntry<std::string>;
+using Record = common::TimestampedEntry<std::string>;
const std::string kTimeFormat("%Y-%m-%d %H:%M:%S");
#define DUMPSYS_TAG "shim::legacy::btm"
}
#undef DUMPSYS_TAG
-void bluetooth::shim::legacy::Acl::Dump(int fd) const {
+void shim::legacy::Acl::Dump(int fd) const {
DumpsysRecord(fd);
DumpsysAcl(fd);
DumpsysL2cap(fd);
DumpsysBtm(fd);
}
-bluetooth::shim::legacy::Acl::Acl(os::Handler* handler,
- const acl_interface_t& acl_interface)
+shim::legacy::Acl::Acl(os::Handler* handler,
+ const acl_interface_t& acl_interface)
: handler_(handler), acl_interface_(acl_interface) {
ValidateAclInterface(acl_interface_);
pimpl_ = std::make_unique<Acl::impl>();
GetAclManager()->RegisterLeCallbacks(this, handler_);
GetController()->RegisterCompletedMonitorAclPacketsCallback(
handler->BindOn(this, &Acl::on_incoming_acl_credits));
- bluetooth::shim::RegisterDumpsysFunction(static_cast<void*>(this),
- [this](int fd) { Dump(fd); });
+ shim::RegisterDumpsysFunction(static_cast<void*>(this),
+ [this](int fd) { Dump(fd); });
Stack::GetInstance()->GetBtm()->Register_HACK_SetScoDisconnectCallback(
[this](uint16_t handle, uint8_t reason) {
TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected,
});
}
-bluetooth::shim::legacy::Acl::~Acl() {
- bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this));
+shim::legacy::Acl::~Acl() {
+ shim::UnregisterDumpsysFunction(static_cast<void*>(this));
GetController()->UnregisterCompletedMonitorAclPacketsCallback();
if (CheckForOrphanedAclConnections()) {
}
}
-bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const {
+bool shim::legacy::Acl::CheckForOrphanedAclConnections() const {
bool orphaned_acl_connections = false;
if (!pimpl_->handle_to_classic_connection_map_.empty()) {
LOG_ERROR(" Orphaned classic ACL handle:0x%04x bd_addr:%s created:%s",
connection.second->Handle(),
PRIVATE_ADDRESS(connection.second->GetRemoteAddress()),
- bluetooth::common::StringFormatTimeWithMilliseconds(
+ common::StringFormatTimeWithMilliseconds(
kConnectionDescriptorTimeFormat,
connection.second->GetCreationTime())
.c_str());
LOG_ERROR(" Orphaned le ACL handle:0x%04x bd_addr:%s created:%s",
connection.second->Handle(),
PRIVATE_ADDRESS(connection.second->GetRemoteAddressWithType()),
- bluetooth::common::StringFormatTimeWithMilliseconds(
+ common::StringFormatTimeWithMilliseconds(
kConnectionDescriptorTimeFormat,
connection.second->GetCreationTime())
.c_str());
return orphaned_acl_connections;
}
-void bluetooth::shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle,
- uint16_t credits) {
+void shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle,
+ uint16_t credits) {
TRY_POSTING_ON_MAIN(acl_interface_.on_packets_completed, handle, credits);
}
-void bluetooth::shim::legacy::Acl::write_data_sync(
- HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) {
+void shim::legacy::Acl::write_data_sync(
+ HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) {
if (pimpl_->IsClassicAcl(handle)) {
pimpl_->EnqueueClassicPacket(handle, std::move(packet));
} else if (pimpl_->IsLeAcl(handle)) {
}
}
-void bluetooth::shim::legacy::Acl::WriteData(
- HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) {
+void shim::legacy::Acl::WriteData(HciHandle handle,
+ std::unique_ptr<packet::RawBuilder> packet) {
handler_->Post(common::BindOnce(&Acl::write_data_sync,
common::Unretained(this), handle,
std::move(packet)));
}
-void bluetooth::shim::legacy::Acl::CreateClassicConnection(
- const bluetooth::hci::Address& address) {
+void shim::legacy::Acl::CreateClassicConnection(const hci::Address& address) {
GetAclManager()->CreateConnection(address);
LOG_DEBUG("Connection initiated for classic to remote:%s",
PRIVATE_ADDRESS(address));
"classic");
}
-void bluetooth::shim::legacy::Acl::CreateLeConnection(
- const bluetooth::hci::AddressWithType& address_with_type) {
+void shim::legacy::Acl::CreateLeConnection(
+ const hci::AddressWithType& address_with_type) {
GetAclManager()->CreateLeConnection(address_with_type);
LOG_DEBUG("Connection initiated for le connection to remote:%s",
PRIVATE_ADDRESS(address_with_type));
"Initiated connection", "le");
}
-void bluetooth::shim::legacy::Acl::CancelLeConnection(
- const bluetooth::hci::AddressWithType& address_with_type) {
+void shim::legacy::Acl::CancelLeConnection(
+ const hci::AddressWithType& address_with_type) {
GetAclManager()->CancelLeConnect(address_with_type);
LOG_DEBUG("Cancelled le connection to remote:%s",
PRIVATE_ADDRESS(address_with_type));
"Cancelled connection", "le");
}
-void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected(
- HciHandle handle, hci::ErrorCode reason) {
- bluetooth::hci::Address remote_address =
+void shim::legacy::Acl::OnClassicLinkDisconnected(HciHandle handle,
+ hci::ErrorCode reason) {
+ hci::Address remote_address =
pimpl_->handle_to_classic_connection_map_[handle]->GetRemoteAddress();
CreationTime creation_time =
pimpl_->handle_to_classic_connection_map_[handle]->GetCreationTime();
is_locally_initiated, reason)));
}
-void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle,
- hci::ErrorCode reason) {
+void shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle,
+ hci::ErrorCode reason) {
hci::AddressWithType remote_address_with_type =
pimpl_->handle_to_le_connection_map_[handle]->GetRemoteAddressWithType();
CreationTime creation_time =
is_locally_initiated, reason)));
}
-void bluetooth::shim::legacy::Acl::OnConnectSuccess(
+void shim::legacy::Acl::OnConnectSuccess(
std::unique_ptr<hci::acl_manager::ClassicAclConnection> connection) {
ASSERT(connection != nullptr);
auto handle = connection->GetHandle();
(locally_initiated) ? "Local initiated" : "Remote initiated");
}
-void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address,
- hci::ErrorCode reason) {
+void shim::legacy::Acl::OnConnectFail(hci::Address address,
+ hci::ErrorCode reason) {
const RawAddress bd_addr = ToRawAddress(address);
TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_failed, bd_addr,
ToLegacyHciErrorCode(reason));
hci::ErrorCodeText(reason).c_str()));
}
-void bluetooth::shim::legacy::Acl::OnLeConnectSuccess(
+void shim::legacy::Acl::OnLeConnectSuccess(
hci::AddressWithType address_with_type,
std::unique_ptr<hci::acl_manager::LeAclConnection> connection) {
ASSERT(connection != nullptr);
auto handle = connection->GetHandle();
- bluetooth::hci::Role connection_role = connection->GetRole();
+ hci::Role connection_role = connection->GetRole();
bool locally_initiated = connection->locally_initiated_;
pimpl_->handle_to_le_connection_map_.emplace(
"Connection successful", "le");
}
-void bluetooth::shim::legacy::Acl::OnLeConnectFail(
- hci::AddressWithType address_with_type, hci::ErrorCode reason) {
+void shim::legacy::Acl::OnLeConnectFail(hci::AddressWithType address_with_type,
+ hci::ErrorCode reason) {
tBLE_BD_ADDR legacy_address_with_type =
ToLegacyAddressWithType(address_with_type);
base::StringPrintf("le reason:%s", hci::ErrorCodeText(reason).c_str()));
}
-void bluetooth::shim::legacy::Acl::ConfigureLePrivacy(
- bool is_le_privacy_enabled) {
+void shim::legacy::Acl::ConfigureLePrivacy(bool is_le_privacy_enabled) {
LOG_INFO("Configuring Le privacy:%s",
(is_le_privacy_enabled) ? "true" : "false");
ASSERT_LOG(is_le_privacy_enabled,
maximum_rotation_time);
}
-void bluetooth::shim::legacy::Acl::DisconnectClassic(uint16_t handle,
- tHCI_STATUS reason) {
+void shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) {
auto connection = pimpl_->handle_to_classic_connection_map_.find(handle);
if (connection != pimpl_->handle_to_classic_connection_map_.end()) {
auto remote_address = connection->second->GetRemoteAddress();
}
}
-void bluetooth::shim::legacy::Acl::DisconnectLe(uint16_t handle,
- tHCI_STATUS reason) {
+void shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) {
auto connection = pimpl_->handle_to_le_connection_map_.find(handle);
if (connection != pimpl_->handle_to_le_connection_map_.end()) {
auto remote_address_with_type =
handle);
}
}
-bool bluetooth::shim::legacy::Acl::HoldMode(uint16_t hci_handle,
- uint16_t max_interval,
- uint16_t min_interval) {
+bool shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval,
+ uint16_t min_interval) {
handler_->CallOn(pimpl_.get(), &Acl::impl::HoldMode, hci_handle, max_interval,
min_interval);
return false; // TODO void
}
-bool bluetooth::shim::legacy::Acl::SniffMode(uint16_t hci_handle,
- uint16_t max_interval,
- uint16_t min_interval,
- uint16_t attempt,
- uint16_t timeout) {
+bool shim::legacy::Acl::SniffMode(uint16_t hci_handle, uint16_t max_interval,
+ uint16_t min_interval, uint16_t attempt,
+ uint16_t timeout) {
handler_->CallOn(pimpl_.get(), &Acl::impl::SniffMode, hci_handle,
max_interval, min_interval, attempt, timeout);
return false;
}
-bool bluetooth::shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) {
+bool shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) {
handler_->CallOn(pimpl_.get(), &Acl::impl::ExitSniffMode, hci_handle);
return false;
}
-bool bluetooth::shim::legacy::Acl::SniffSubrating(
- uint16_t hci_handle, uint16_t maximum_latency,
- uint16_t minimum_remote_timeout, uint16_t minimum_local_timeout) {
+bool shim::legacy::Acl::SniffSubrating(uint16_t hci_handle,
+ uint16_t maximum_latency,
+ uint16_t minimum_remote_timeout,
+ uint16_t minimum_local_timeout) {
handler_->CallOn(pimpl_.get(), &Acl::impl::SniffSubrating, hci_handle,
maximum_latency, minimum_remote_timeout,
minimum_local_timeout);
return false;
}
-void bluetooth::shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle,
- uint8_t reason) {
+void shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle,
+ uint8_t reason) {
TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected, handle,
static_cast<tHCI_REASON>(reason));
}
-void bluetooth::shim::legacy::Acl::DumpConnectionHistory(int fd) const {
+void shim::legacy::Acl::DumpConnectionHistory(int fd) const {
pimpl_->DumpConnectionHistory(fd);
}
-void bluetooth::shim::legacy::Acl::Shutdown() {
+void shim::legacy::Acl::Shutdown() {
if (CheckForOrphanedAclConnections()) {
std::promise<void> shutdown_promise;
auto shutdown_future = shutdown_promise.get_future();