summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Manton <cmanton@google.com> 2024-03-26 17:57:36 -0700
committer Chris Manton <cmanton@google.com> 2024-04-23 17:50:06 +0000
commitca89fff838b4bc5fc52d821187a6532084506751 (patch)
tree0bfc446eeb48f51169a9ca5c35d2312602186b75
parent65718a9e4e0c23c0b48e034d19f958f394bd0f3d (diff)
contextual_callback: Update API usage
Bug: 331499072 Test: m . Flag: EXEMPT, Mechanical Refactor Change-Id: Idc21c30c2970f309073a57e5483cf1671d3470ca
-rw-r--r--system/gd/common/contextual_callback.h2
-rw-r--r--system/gd/fuzz/helpers.h8
-rw-r--r--system/gd/hci/acl_manager/acl_scheduler.cc16
-rw-r--r--system/gd/hci/acl_manager/classic_impl_test.cc6
-rw-r--r--system/gd/hci/acl_manager/le_acl_connection_test.cc4
-rw-r--r--system/gd/hci/acl_manager/le_impl_test.cc2
-rw-r--r--system/gd/hci/acl_manager/round_robin_scheduler_test.cc2
-rw-r--r--system/gd/hci/acl_manager_test.cc2
-rw-r--r--system/gd/hci/controller.cc22
-rw-r--r--system/gd/hci/controller_test.cc2
-rw-r--r--system/gd/hci/fuzz/fuzz_hci_layer.cc8
-rw-r--r--system/gd/hci/hci_layer.cc20
-rw-r--r--system/gd/hci/hci_layer_fake.cc8
-rw-r--r--system/gd/hci/hci_layer_unittest.cc2
-rw-r--r--system/gd/hci/le_address_manager.cc30
-rw-r--r--system/gd/hci/le_advertising_manager.cc4
-rw-r--r--system/gd/hci/le_periodic_sync_manager_test.cc4
-rw-r--r--system/gd/hci/remote_name_request.cc10
-rw-r--r--system/gd/hci/vendor_specific_event_manager.cc2
-rw-r--r--system/gd/l2cap/classic/internal/dynamic_channel_service_impl.h4
-rw-r--r--system/gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.cc15
-rw-r--r--system/gd/l2cap/classic/internal/link.cc6
-rw-r--r--system/gd/l2cap/classic/internal/link_manager.cc2
-rw-r--r--system/gd/l2cap/classic/security_enforcement_interface.h4
-rw-r--r--system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager_impl.h4
-rw-r--r--system/gd/l2cap/internal/dynamic_channel_impl.cc4
-rw-r--r--system/gd/l2cap/le/l2cap_le_module.cc4
-rw-r--r--system/gd/security/internal/security_manager_impl.cc6
28 files changed, 101 insertions, 102 deletions
diff --git a/system/gd/common/contextual_callback.h b/system/gd/common/contextual_callback.h
index 12f9b47564..9fb5a5a213 100644
--- a/system/gd/common/contextual_callback.h
+++ b/system/gd/common/contextual_callback.h
@@ -83,7 +83,7 @@ class ContextualCallback<R(Args...)> {
ContextualCallback& operator=(ContextualCallback&&) noexcept = default;
void operator()(Args... args) {
- context_->Post(common::BindOnce(std::move(callback_), std::forward<Args>(args)...));
+ context_->Post(common::BindOnce(callback_, std::forward<Args>(args)...));
}
operator bool() const {
diff --git a/system/gd/fuzz/helpers.h b/system/gd/fuzz/helpers.h
index 77e9a38b33..f4ca162730 100644
--- a/system/gd/fuzz/helpers.h
+++ b/system/gd/fuzz/helpers.h
@@ -43,8 +43,8 @@ void InvokeIfValid(common::ContextualOnceCallback<void(TView)> callback, std::ve
if (!packet.IsValid()) {
return;
}
- if (!callback.IsEmpty()) {
- callback.Invoke(packet);
+ if (callback) {
+ callback(packet);
}
}
@@ -54,8 +54,8 @@ void InvokeIfValid(common::ContextualCallback<void(TView)> callback, std::vector
if (!packet.IsValid()) {
return;
}
- if (!callback.IsEmpty()) {
- callback.Invoke(packet);
+ if (callback) {
+ callback(packet);
}
}
diff --git a/system/gd/hci/acl_manager/acl_scheduler.cc b/system/gd/hci/acl_manager/acl_scheduler.cc
index f1190b9571..4f7afec916 100644
--- a/system/gd/hci/acl_manager/acl_scheduler.cc
+++ b/system/gd/hci/acl_manager/acl_scheduler.cc
@@ -61,7 +61,7 @@ struct AclScheduler::impl {
if (entry != nullptr && entry->address == address) {
// If so, clear the current entry and advance the queue
outgoing_entry_.reset();
- handle_outgoing_connection.Invoke();
+ handle_outgoing_connection();
try_dequeue_next_operation();
return;
}
@@ -70,9 +70,9 @@ struct AclScheduler::impl {
// Otherwise check if it's an incoming request and advance the queue if so
if (incoming_connecting_address_set_.find(address) != incoming_connecting_address_set_.end()) {
incoming_connecting_address_set_.erase(address);
- handle_incoming_connection.Invoke();
+ handle_incoming_connection();
} else {
- handle_unknown_connection.Invoke(set_of_incoming_connecting_addresses());
+ handle_unknown_connection(set_of_incoming_connecting_addresses());
}
try_dequeue_next_operation();
}
@@ -100,8 +100,8 @@ struct AclScheduler::impl {
auto entry_ptr = std::get_if<AclCreateConnectionQueueEntry>(&entry);
return entry_ptr != nullptr && entry_ptr->address == address;
},
- [&]() { cancel_connection.Invoke(); },
- [&](auto /* entry */) { cancel_connection_completed.Invoke(); });
+ [&]() { cancel_connection(); },
+ [&](auto /* entry */) { cancel_connection_completed(); });
if (!ok) {
log::error("Attempted to cancel connection to {} that does not exist", address);
}
@@ -147,8 +147,8 @@ struct AclScheduler::impl {
auto entry_ptr = std::get_if<RemoteNameRequestQueueEntry>(&entry);
return entry_ptr != nullptr && entry_ptr->address == address;
},
- [&]() { cancel_request.Invoke(); },
- [](auto entry) { std::get<RemoteNameRequestQueueEntry>(entry).callback_when_cancelled.Invoke(); });
+ [&]() { cancel_request(); },
+ [](auto entry) { std::get<RemoteNameRequestQueueEntry>(entry).callback_when_cancelled(); });
if (!ok) {
log::error("Attempted to cancel remote name request to {} that does not exist", address);
}
@@ -168,7 +168,7 @@ struct AclScheduler::impl {
log::info("Pending connections is not empty; so sending next connection");
auto entry = std::move(pending_outgoing_operations_.front());
pending_outgoing_operations_.pop_front();
- std::visit([](auto&& variant) { variant.callback.Invoke(); }, entry);
+ std::visit([](auto&& variant) { variant.callback(); }, entry);
outgoing_entry_ = std::move(entry);
}
}
diff --git a/system/gd/hci/acl_manager/classic_impl_test.cc b/system/gd/hci/acl_manager/classic_impl_test.cc
index 7dcef4be38..e59be364e0 100644
--- a/system/gd/hci/acl_manager/classic_impl_test.cc
+++ b/system/gd/hci/acl_manager/classic_impl_test.cc
@@ -129,14 +129,14 @@ class MockAclScheduler : public AclScheduler {
common::ContextualOnceCallback<void()> handle_incoming_connection,
common::ContextualOnceCallback<void(std::string)> handle_unknown_connection) override {
if (handle_outgoing_connection_) {
- handle_outgoing_connection.Invoke();
+ handle_outgoing_connection();
return;
}
if (handle_incoming_connection_) {
- handle_incoming_connection.Invoke();
+ handle_incoming_connection();
} else {
- handle_unknown_connection.Invoke("set_of_incoming_connecting_addresses()");
+ handle_unknown_connection("set_of_incoming_connecting_addresses()");
}
}
};
diff --git a/system/gd/hci/acl_manager/le_acl_connection_test.cc b/system/gd/hci/acl_manager/le_acl_connection_test.cc
index 2a128a535c..0a0a69990d 100644
--- a/system/gd/hci/acl_manager/le_acl_connection_test.cc
+++ b/system/gd/hci/acl_manager/le_acl_connection_test.cc
@@ -235,7 +235,7 @@ TEST_F(LeAclConnectionTest, LeSubrateRequest_success) {
hci::EventView event = hci::EventView::Create(GetPacketView(std::move(status_builder)));
hci::CommandStatusView command_status = hci::CommandStatusView::Create(event);
auto on_status = le_acl_connection_interface_.DequeueStatusCallback();
- on_status.Invoke(command_status);
+ on_status(command_status);
sync_handler();
}
@@ -256,7 +256,7 @@ TEST_F(LeAclConnectionTest, LeSubrateRequest_error) {
hci::EventView event = hci::EventView::Create(GetPacketView(std::move(status_builder)));
hci::CommandStatusView command_status = hci::CommandStatusView::Create(event);
auto on_status = le_acl_connection_interface_.DequeueStatusCallback();
- on_status.Invoke(std::move(command_status));
+ on_status(std::move(command_status));
sync_handler();
}
diff --git a/system/gd/hci/acl_manager/le_impl_test.cc b/system/gd/hci/acl_manager/le_impl_test.cc
index fd79fbbf90..092db3e011 100644
--- a/system/gd/hci/acl_manager/le_impl_test.cc
+++ b/system/gd/hci/acl_manager/le_impl_test.cc
@@ -196,7 +196,7 @@ class TestController : public Controller {
}
void SendCompletedAclPacketsCallback(uint16_t handle, uint16_t credits) {
- acl_credits_callback_.Invoke(handle, credits);
+ acl_credits_callback_(handle, credits);
}
void UnregisterCompletedAclPacketsCallback() {
diff --git a/system/gd/hci/acl_manager/round_robin_scheduler_test.cc b/system/gd/hci/acl_manager/round_robin_scheduler_test.cc
index 256e49180a..0683b46683 100644
--- a/system/gd/hci/acl_manager/round_robin_scheduler_test.cc
+++ b/system/gd/hci/acl_manager/round_robin_scheduler_test.cc
@@ -60,7 +60,7 @@ class TestController : public Controller {
}
void SendCompletedAclPacketsCallback(uint16_t handle, uint16_t credits) {
- acl_credits_callback_.Invoke(handle, credits);
+ acl_credits_callback_(handle, credits);
}
void UnregisterCompletedAclPacketsCallback() {
diff --git a/system/gd/hci/acl_manager_test.cc b/system/gd/hci/acl_manager_test.cc
index 1f3e11b729..ac6ebc0a2c 100644
--- a/system/gd/hci/acl_manager_test.cc
+++ b/system/gd/hci/acl_manager_test.cc
@@ -95,7 +95,7 @@ class TestController : public testing::MockController {
}
void CompletePackets(uint16_t handle, uint16_t packets) {
- acl_cb_.Invoke(handle, packets);
+ acl_cb_(handle, packets);
}
uint16_t acl_buffer_length_ = 1024;
diff --git a/system/gd/hci/controller.cc b/system/gd/hci/controller.cc
index 27e7f3e47c..b53b232119 100644
--- a/system/gd/hci/controller.cc
+++ b/system/gd/hci/controller.cc
@@ -229,7 +229,7 @@ struct Controller::impl {
}
void NumberOfCompletedPackets(EventView event) {
- if (acl_credits_callback_.IsEmpty()) {
+ if (!acl_credits_callback_) {
log::warn("Received event when AclManager is not listening");
return;
}
@@ -238,40 +238,40 @@ struct Controller::impl {
for (auto completed_packets : complete_view.GetCompletedPackets()) {
uint16_t handle = completed_packets.connection_handle_;
uint16_t credits = completed_packets.host_num_of_completed_packets_;
- acl_credits_callback_.Invoke(handle, credits);
- if (!acl_monitor_credits_callback_.IsEmpty()) {
- acl_monitor_credits_callback_.Invoke(handle, credits);
+ acl_credits_callback_(handle, credits);
+ if (acl_monitor_credits_callback_) {
+ acl_monitor_credits_callback_(handle, credits);
}
}
}
void register_completed_acl_packets_callback(CompletedAclPacketsCallback callback) {
- ASSERT(acl_credits_callback_.IsEmpty());
+ ASSERT(!acl_credits_callback_);
acl_credits_callback_ = callback;
}
void unregister_completed_acl_packets_callback() {
- ASSERT(!acl_credits_callback_.IsEmpty());
+ ASSERT(acl_credits_callback_);
acl_credits_callback_ = {};
}
void register_completed_monitor_acl_packets_callback(CompletedAclPacketsCallback callback) {
- ASSERT(acl_monitor_credits_callback_.IsEmpty());
+ ASSERT(!acl_monitor_credits_callback_);
acl_monitor_credits_callback_ = callback;
}
void unregister_completed_monitor_acl_packets_callback() {
- ASSERT(!acl_monitor_credits_callback_.IsEmpty());
+ ASSERT(acl_monitor_credits_callback_);
acl_monitor_credits_callback_ = {};
}
void register_monitor_completed_acl_packets_callback(CompletedAclPacketsCallback callback) {
- ASSERT(acl_monitor_credits_callback_.IsEmpty());
+ ASSERT(!acl_monitor_credits_callback_);
acl_monitor_credits_callback_ = callback;
}
void unregister_monitor_completed_acl_packets_callback() {
- ASSERT(!acl_monitor_credits_callback_.IsEmpty());
+ ASSERT(acl_monitor_credits_callback_);
acl_monitor_credits_callback_ = {};
}
@@ -770,7 +770,7 @@ struct Controller::impl {
auto status_view = LeRandCompleteView::Create(view);
ASSERT(status_view.IsValid());
ASSERT(status_view.GetStatus() == ErrorCode::SUCCESS);
- std::move(cb).Invoke(status_view.GetRandomNumber());
+ std::move(cb)(status_view.GetRandomNumber());
}
void set_event_filter(std::unique_ptr<SetEventFilterBuilder> packet) {
diff --git a/system/gd/hci/controller_test.cc b/system/gd/hci/controller_test.cc
index ca9cefa77c..e4a8075ff4 100644
--- a/system/gd/hci/controller_test.cc
+++ b/system/gd/hci/controller_test.cc
@@ -255,7 +255,7 @@ class HciLayerFakeForController : public HciLayerFake {
ASSERT_TRUE(event.IsValid());
CommandCompleteView command_complete = CommandCompleteView::Create(event);
ASSERT_TRUE(command_complete.IsValid());
- on_complete.Invoke(std::move(command_complete));
+ on_complete(std::move(command_complete));
}
void IncomingCredit() {
diff --git a/system/gd/hci/fuzz/fuzz_hci_layer.cc b/system/gd/hci/fuzz/fuzz_hci_layer.cc
index d2a3ddaacb..cb3862cc70 100644
--- a/system/gd/hci/fuzz/fuzz_hci_layer.cc
+++ b/system/gd/hci/fuzz/fuzz_hci_layer.cc
@@ -181,8 +181,8 @@ void FuzzHciLayer::injectAclEvent(std::vector<uint8_t> data) {
}
void FuzzHciLayer::injectAclDisconnect(FuzzedDataProvider& fdp) {
- if (!acl_on_disconnect_.IsEmpty()) {
- acl_on_disconnect_.Invoke(
+ if (acl_on_disconnect_) {
+ acl_on_disconnect_(
fdp.ConsumeIntegral<uint16_t>(),
static_cast<hci::ErrorCode>(fdp.ConsumeIntegral<uint8_t>()));
}
@@ -193,8 +193,8 @@ void FuzzHciLayer::injectLeAclEvent(std::vector<uint8_t> data) {
}
void FuzzHciLayer::injectLeAclDisconnect(FuzzedDataProvider& fdp) {
- if (!le_acl_on_disconnect_.IsEmpty()) {
- le_acl_on_disconnect_.Invoke(
+ if (le_acl_on_disconnect_) {
+ le_acl_on_disconnect_(
fdp.ConsumeIntegral<uint16_t>(),
static_cast<hci::ErrorCode>(fdp.ConsumeIntegral<uint8_t>()));
}
diff --git a/system/gd/hci/hci_layer.cc b/system/gd/hci/hci_layer.cc
index d6f326cb2c..f821afd6cd 100644
--- a/system/gd/hci/hci_layer.cc
+++ b/system/gd/hci/hci_layer.cc
@@ -236,7 +236,7 @@ struct HciLayer::impl {
OpCodeText(op_code),
logging_id);
- command_queue_.front().GetCallback<TResponse>()->Invoke(std::move(response_view));
+ (*command_queue_.front().GetCallback<TResponse>())(std::move(response_view));
}
#ifdef TARGET_FLOSS
@@ -329,7 +329,7 @@ struct HciLayer::impl {
"Can not register handler for {}",
EventCodeText(EventCode::LE_META_EVENT));
// Allow GD Cert tests to register for CONNECTION_REQUEST
- if (event == EventCode::CONNECTION_REQUEST && module_.on_acl_connection_request_.IsEmpty()) {
+ if (event == EventCode::CONNECTION_REQUEST && !module_.on_acl_connection_request_) {
log::info("Registering test for CONNECTION_REQUEST, since there's no ACL");
event_handlers_.erase(event);
}
@@ -444,7 +444,7 @@ struct HciLayer::impl {
if (event_handlers_.find(event_code) == event_handlers_.end()) {
log::warn("Unhandled event of type {}", EventCodeText(event_code));
} else {
- event_handlers_[event_code].Invoke(event);
+ event_handlers_[event_code](event);
}
}
}
@@ -471,7 +471,7 @@ struct HciLayer::impl {
log::warn("Unhandled le subevent of type {}", SubeventCodeText(subevent_code));
return;
}
- subevent_handlers_[subevent_code].Invoke(meta_event_view);
+ subevent_handlers_[subevent_code](meta_event_view);
}
hal::HciHal* hal_;
@@ -605,18 +605,18 @@ void HciLayer::on_connection_request(EventView event_view) {
ConnectionRequestLinkType link_type = view.GetLinkType();
switch (link_type) {
case ConnectionRequestLinkType::ACL:
- if (on_acl_connection_request_.IsEmpty()) {
+ if (!on_acl_connection_request_) {
log::warn("No callback registered for ACL connection requests.");
} else {
- on_acl_connection_request_.Invoke(address, cod);
+ on_acl_connection_request_(address, cod);
}
break;
case ConnectionRequestLinkType::SCO:
case ConnectionRequestLinkType::ESCO:
- if (on_sco_connection_request_.IsEmpty()) {
+ if (!on_sco_connection_request_) {
log::warn("No callback registered for SCO connection requests.");
} else {
- on_sco_connection_request_.Invoke(address, cod, link_type);
+ on_sco_connection_request_(address, cod, link_type);
}
break;
}
@@ -625,7 +625,7 @@ void HciLayer::on_connection_request(EventView event_view) {
void HciLayer::Disconnect(uint16_t handle, ErrorCode reason) {
std::unique_lock<std::mutex> lock(callback_handlers_guard_);
for (auto callback : disconnect_handlers_) {
- callback.Invoke(handle, reason);
+ callback(handle, reason);
}
}
@@ -649,7 +649,7 @@ void HciLayer::ReadRemoteVersion(
hci::ErrorCode hci_status, uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
std::unique_lock<std::mutex> lock(callback_handlers_guard_);
for (auto callback : read_remote_version_handlers_) {
- callback.Invoke(hci_status, handle, version, manufacturer_name, sub_version);
+ callback(hci_status, handle, version, manufacturer_name, sub_version);
}
}
diff --git a/system/gd/hci/hci_layer_fake.cc b/system/gd/hci/hci_layer_fake.cc
index a47ee4d387..ba3946a755 100644
--- a/system/gd/hci/hci_layer_fake.cc
+++ b/system/gd/hci/hci_layer_fake.cc
@@ -148,7 +148,7 @@ void HciLayerFake::IncomingEvent(std::unique_ptr<EventBuilder> event_builder) {
CommandStatusCallback(event);
} else {
ASSERT_NE(registered_events_.find(event_code), registered_events_.end()) << EventCodeText(event_code);
- registered_events_[event_code].Invoke(event);
+ registered_events_[event_code](event);
}
}
@@ -159,20 +159,20 @@ void HciLayerFake::IncomingLeMetaEvent(std::unique_ptr<LeMetaEventBuilder> event
ASSERT_TRUE(meta_event_view.IsValid());
SubeventCode subevent_code = meta_event_view.GetSubeventCode();
ASSERT_TRUE(registered_le_events_.find(subevent_code) != registered_le_events_.end());
- registered_le_events_[subevent_code].Invoke(meta_event_view);
+ registered_le_events_[subevent_code](meta_event_view);
}
void HciLayerFake::CommandCompleteCallback(EventView event) {
CommandCompleteView complete_view = CommandCompleteView::Create(event);
ASSERT_TRUE(complete_view.IsValid());
- std::move(command_complete_callbacks.front()).Invoke(complete_view);
+ std::move(command_complete_callbacks.front())(complete_view);
command_complete_callbacks.pop_front();
}
void HciLayerFake::CommandStatusCallback(EventView event) {
CommandStatusView status_view = CommandStatusView::Create(event);
ASSERT_TRUE(status_view.IsValid());
- std::move(command_status_callbacks.front()).Invoke(status_view);
+ std::move(command_status_callbacks.front())(status_view);
command_status_callbacks.pop_front();
}
diff --git a/system/gd/hci/hci_layer_unittest.cc b/system/gd/hci/hci_layer_unittest.cc
index 9e7100444e..8b2c15ba46 100644
--- a/system/gd/hci/hci_layer_unittest.cc
+++ b/system/gd/hci/hci_layer_unittest.cc
@@ -99,7 +99,7 @@ class HciLayerTest : public ::testing::Test {
}
void FailIfResetNotSent() {
- hci_handler_->BindOnceOn(this, &HciLayerTest::fail_if_reset_not_sent).Invoke();
+ (hci_handler_->BindOnceOn(this, &HciLayerTest::fail_if_reset_not_sent))();
sync_handler();
}
diff --git a/system/gd/hci/le_address_manager.cc b/system/gd/hci/le_address_manager.cc
index ed9141a94d..f06568f05e 100644
--- a/system/gd/hci/le_address_manager.cc
+++ b/system/gd/hci/le_address_manager.cc
@@ -116,7 +116,7 @@ void LeAddressManager::SetPrivacyPolicyForInitiatorAddress(
switch (address_policy_) {
case AddressPolicy::USE_PUBLIC_ADDRESS:
le_address_ = AddressWithType(public_address_, AddressType::PUBLIC_DEVICE_ADDRESS);
- handler_->BindOnceOn(this, &LeAddressManager::resume_registered_clients).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::resume_registered_clients)();
break;
case AddressPolicy::USE_STATIC_ADDRESS: {
auto addr = fixed_address.GetAddress();
@@ -208,7 +208,7 @@ bool LeAddressManager::RotatingAddress() {
address_policy_ == AddressPolicy::USE_NON_RESOLVABLE_ADDRESS;
}
LeAddressManager::AddressPolicy LeAddressManager::Register(LeAddressManagerCallback* callback) {
- handler_->BindOnceOn(this, &LeAddressManager::register_client, callback).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::register_client, callback)();
return address_policy_;
}
@@ -230,7 +230,7 @@ void LeAddressManager::register_client(LeAddressManagerCallback* callback) {
}
void LeAddressManager::Unregister(LeAddressManagerCallback* callback) {
- handler_->BindOnceOn(this, &LeAddressManager::unregister_client, callback).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::unregister_client, callback)();
}
void LeAddressManager::unregister_client(LeAddressManagerCallback* callback) {
@@ -250,7 +250,7 @@ void LeAddressManager::unregister_client(LeAddressManagerCallback* callback) {
}
bool LeAddressManager::UnregisterSync(LeAddressManagerCallback* callback, std::chrono::milliseconds timeout) {
- handler_->BindOnceOn(this, &LeAddressManager::unregister_client, callback).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::unregister_client, callback)();
std::promise<void> promise;
auto future = promise.get_future();
handler_->Post(common::BindOnce(&std::promise<void>::set_value, common::Unretained(&promise)));
@@ -258,11 +258,11 @@ bool LeAddressManager::UnregisterSync(LeAddressManagerCallback* callback, std::c
}
void LeAddressManager::AckPause(LeAddressManagerCallback* callback) {
- handler_->BindOnceOn(this, &LeAddressManager::ack_pause, callback).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::ack_pause, callback)();
}
void LeAddressManager::AckResume(LeAddressManagerCallback* callback) {
- handler_->BindOnceOn(this, &LeAddressManager::ack_resume, callback).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::ack_resume, callback)();
}
AddressWithType LeAddressManager::GetInitiatorAddress() {
@@ -528,7 +528,7 @@ void LeAddressManager::AddDeviceToFilterAcceptList(
FilterAcceptListAddressType accept_list_address_type, bluetooth::hci::Address address) {
auto packet_builder = hci::LeAddDeviceToFilterAcceptListBuilder::Create(accept_list_address_type, address);
Command command = {CommandType::ADD_DEVICE_TO_ACCEPT_LIST, HCICommand{std::move(packet_builder)}};
- handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command)).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command))();
}
void LeAddressManager::AddDeviceToResolvingList(
@@ -563,9 +563,9 @@ void LeAddressManager::AddDeviceToResolvingList(
cached_commands_.push(std::move(enable));
if (registered_clients_.empty()) {
- handler_->BindOnceOn(this, &LeAddressManager::handle_next_command).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::handle_next_command)();
} else {
- handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients)();
}
}
@@ -573,7 +573,7 @@ void LeAddressManager::RemoveDeviceFromFilterAcceptList(
FilterAcceptListAddressType accept_list_address_type, bluetooth::hci::Address address) {
auto packet_builder = hci::LeRemoveDeviceFromFilterAcceptListBuilder::Create(accept_list_address_type, address);
Command command = {CommandType::REMOVE_DEVICE_FROM_ACCEPT_LIST, HCICommand{std::move(packet_builder)}};
- handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command)).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command))();
}
void LeAddressManager::RemoveDeviceFromResolvingList(
@@ -598,16 +598,16 @@ void LeAddressManager::RemoveDeviceFromResolvingList(
cached_commands_.push(std::move(enable));
if (registered_clients_.empty()) {
- handler_->BindOnceOn(this, &LeAddressManager::handle_next_command).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::handle_next_command)();
} else {
- handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients)();
}
}
void LeAddressManager::ClearFilterAcceptList() {
auto packet_builder = hci::LeClearFilterAcceptListBuilder::Create();
Command command = {CommandType::CLEAR_ACCEPT_LIST, HCICommand{std::move(packet_builder)}};
- handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command)).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::push_command, std::move(command))();
}
void LeAddressManager::ClearResolvingList() {
@@ -629,7 +629,7 @@ void LeAddressManager::ClearResolvingList() {
Command enable = {CommandType::SET_ADDRESS_RESOLUTION_ENABLE, HCICommand{std::move(enable_builder)}};
cached_commands_.push(std::move(enable));
- handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::pause_registered_clients)();
}
template <class View>
@@ -720,7 +720,7 @@ void LeAddressManager::OnCommandComplete(bluetooth::hci::CommandCompleteView vie
break;
}
- handler_->BindOnceOn(this, &LeAddressManager::check_cached_commands).Invoke();
+ handler_->BindOnceOn(this, &LeAddressManager::check_cached_commands)();
}
void LeAddressManager::check_cached_commands() {
diff --git a/system/gd/hci/le_advertising_manager.cc b/system/gd/hci/le_advertising_manager.cc
index a054b7f778..8d6e70deca 100644
--- a/system/gd/hci/le_advertising_manager.cc
+++ b/system/gd/hci/le_advertising_manager.cc
@@ -776,9 +776,9 @@ struct LeAdvertisingManager::impl : public bluetooth::hci::LeAddressManagerCallb
common::ContextualOnceCallback<void(uint8_t /* inst_id */, uint8_t /* status */)> callback) {
AdvertiserId id = allocate_advertiser();
if (id == kInvalidId) {
- callback.Invoke(kInvalidId, AdvertisingCallback::AdvertisingStatus::TOO_MANY_ADVERTISERS);
+ callback(kInvalidId, AdvertisingCallback::AdvertisingStatus::TOO_MANY_ADVERTISERS);
} else {
- callback.Invoke(id, AdvertisingCallback::AdvertisingStatus::SUCCESS);
+ callback(id, AdvertisingCallback::AdvertisingStatus::SUCCESS);
}
}
diff --git a/system/gd/hci/le_periodic_sync_manager_test.cc b/system/gd/hci/le_periodic_sync_manager_test.cc
index 1d1fdce8c4..ecf3248bc1 100644
--- a/system/gd/hci/le_periodic_sync_manager_test.cc
+++ b/system/gd/hci/le_periodic_sync_manager_test.cc
@@ -113,7 +113,7 @@ class TestLeScanningInterface : public LeScanningInterface {
CommandCompleteView complete_view = CommandCompleteView::Create(event);
ASSERT_TRUE(complete_view.IsValid());
ASSERT_NE((uint16_t)command_complete_callbacks.size(), 0);
- std::move(command_complete_callbacks.front()).Invoke(complete_view);
+ std::move(command_complete_callbacks.front())(complete_view);
command_complete_callbacks.pop_front();
}
@@ -122,7 +122,7 @@ class TestLeScanningInterface : public LeScanningInterface {
CommandStatusView status_view = CommandStatusView::Create(event);
ASSERT_TRUE(status_view.IsValid());
ASSERT_NE((uint16_t)command_status_callbacks.size(), 0);
- std::move(command_status_callbacks.front()).Invoke(status_view);
+ std::move(command_status_callbacks.front())(status_view);
command_status_callbacks.pop_front();
}
diff --git a/system/gd/hci/remote_name_request.cc b/system/gd/hci/remote_name_request.cc
index fb32ace6d8..e35b928c67 100644
--- a/system/gd/hci/remote_name_request.cc
+++ b/system/gd/hci/remote_name_request.cc
@@ -80,7 +80,7 @@ struct RemoteNameRequestModule::impl {
log::info(
"Dequeued remote name request to {} since it was cancelled",
address.ToRedactedStringForLogging());
- on_remote_name_complete_ptr->Invoke(ErrorCode::PAGE_TIMEOUT, {});
+ (*on_remote_name_complete_ptr)(ErrorCode::PAGE_TIMEOUT, {});
},
address,
on_remote_name_complete_ptr));
@@ -99,7 +99,7 @@ struct RemoteNameRequestModule::impl {
"Received CONNECTION_COMPLETE (corresponding INCORRECTLY to an RNR cancellation) from {}",
address.ToRedactedStringForLogging());
pending_ = false;
- on_remote_name_complete_.Invoke(ErrorCode::UNKNOWN_CONNECTION, {});
+ on_remote_name_complete_(ErrorCode::UNKNOWN_CONNECTION, {});
acl_scheduler_->ReportRemoteNameRequestCompletion(address);
} else {
log::error(
@@ -146,7 +146,7 @@ struct RemoteNameRequestModule::impl {
"Started remote name request peer:{} status:{}",
address.ToRedactedStringForLogging(),
ErrorCodeText(status.GetStatus()));
- on_completion.Invoke(status.GetStatus());
+ on_completion(status.GetStatus());
if (status.GetStatus() != ErrorCode::SUCCESS /* pending */) {
pending_ = false;
acl_scheduler_->ReportRemoteNameRequestCompletion(address);
@@ -181,7 +181,7 @@ struct RemoteNameRequestModule::impl {
log::info(
"Received REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION from {}",
packet.GetBdAddr().ToRedactedStringForLogging());
- on_remote_host_supported_features_notification_.Invoke(packet.GetHostSupportedFeatures());
+ on_remote_host_supported_features_notification_(packet.GetHostSupportedFeatures());
// Remove the callback so that we won't call it again.
on_remote_host_supported_features_notification_ = RemoteHostSupportedFeaturesCallback();
} else if (!pending_) {
@@ -202,7 +202,7 @@ struct RemoteNameRequestModule::impl {
address.ToRedactedStringForLogging(),
ErrorCodeText(status));
pending_ = false;
- on_remote_name_complete_.Invoke(status, name);
+ on_remote_name_complete_(status, name);
acl_scheduler_->ReportRemoteNameRequestCompletion(address);
} else {
log::error(
diff --git a/system/gd/hci/vendor_specific_event_manager.cc b/system/gd/hci/vendor_specific_event_manager.cc
index 7baea6034b..b7810d9f75 100644
--- a/system/gd/hci/vendor_specific_event_manager.cc
+++ b/system/gd/hci/vendor_specific_event_manager.cc
@@ -89,7 +89,7 @@ struct VendorSpecificEventManager::impl {
log::warn("Unhandled vendor specific event of type 0x{:02x}", vse_subevent_code);
return;
}
- subevent_handlers_[vse_subevent_code].Invoke(vendor_specific_event_view);
+ subevent_handlers_[vse_subevent_code](vendor_specific_event_view);
}
Module* module_;
diff --git a/system/gd/l2cap/classic/internal/dynamic_channel_service_impl.h b/system/gd/l2cap/classic/internal/dynamic_channel_service_impl.h
index b444c7b15b..15aaff0583 100644
--- a/system/gd/l2cap/classic/internal/dynamic_channel_service_impl.h
+++ b/system/gd/l2cap/classic/internal/dynamic_channel_service_impl.h
@@ -16,8 +16,6 @@
#pragma once
-#include "common/bind.h"
-
#include "l2cap/classic/dynamic_channel.h"
#include "l2cap/classic/dynamic_channel_configuration_option.h"
#include "l2cap/classic/dynamic_channel_manager.h"
@@ -41,7 +39,7 @@ class DynamicChannelServiceImpl {
};
virtual void NotifyChannelCreation(std::unique_ptr<DynamicChannel> channel) {
- on_connection_open_callback_.Invoke(std::move(channel));
+ on_connection_open_callback_(std::move(channel));
}
virtual DynamicChannelConfigurationOption GetConfigOption() const {
diff --git a/system/gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.cc b/system/gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.cc
index 2197d349d2..3dfb0e185f 100644
--- a/system/gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.cc
+++ b/system/gd/l2cap/classic/internal/dynamic_channel_service_manager_impl.cc
@@ -18,7 +18,6 @@
#include <bluetooth/log.h>
-#include "common/bind.h"
#include "l2cap/classic/internal/dynamic_channel_service_impl.h"
#include "l2cap/psm.h"
#include "os/log.h"
@@ -32,12 +31,14 @@ void DynamicChannelServiceManagerImpl::Register(Psm psm,
DynamicChannelServiceImpl::PendingRegistration pending_registration) {
if (!IsPsmValid(psm)) {
std::unique_ptr<DynamicChannelService> invalid_service(new DynamicChannelService());
- pending_registration.on_registration_complete_callback_.Invoke(
- DynamicChannelManager::RegistrationResult::FAIL_INVALID_SERVICE, std::move(invalid_service));
+ pending_registration.on_registration_complete_callback_(
+ DynamicChannelManager::RegistrationResult::FAIL_INVALID_SERVICE,
+ std::move(invalid_service));
} else if (IsServiceRegistered(psm)) {
std::unique_ptr<DynamicChannelService> invalid_service(new DynamicChannelService());
- pending_registration.on_registration_complete_callback_.Invoke(
- DynamicChannelManager::RegistrationResult::FAIL_DUPLICATE_SERVICE, std::move(invalid_service));
+ pending_registration.on_registration_complete_callback_(
+ DynamicChannelManager::RegistrationResult::FAIL_DUPLICATE_SERVICE,
+ std::move(invalid_service));
} else {
service_map_.try_emplace(
psm,
@@ -46,7 +47,7 @@ void DynamicChannelServiceManagerImpl::Register(Psm psm,
std::move(pending_registration.on_connection_open_callback_),
pending_registration.configuration_));
std::unique_ptr<DynamicChannelService> user_service(new DynamicChannelService(psm, this, l2cap_layer_handler_));
- pending_registration.on_registration_complete_callback_.Invoke(
+ pending_registration.on_registration_complete_callback_(
DynamicChannelManager::RegistrationResult::SUCCESS, std::move(user_service));
}
}
@@ -54,7 +55,7 @@ void DynamicChannelServiceManagerImpl::Register(Psm psm,
void DynamicChannelServiceManagerImpl::Unregister(Psm psm, DynamicChannelService::OnUnregisteredCallback callback) {
if (IsServiceRegistered(psm)) {
service_map_.erase(psm);
- callback.Invoke();
+ callback();
} else {
log::error("service not registered psm:{}", psm);
}
diff --git a/system/gd/l2cap/classic/internal/link.cc b/system/gd/l2cap/classic/internal/link.cc
index cb79d077a5..0e0d48ab94 100644
--- a/system/gd/l2cap/classic/internal/link.cc
+++ b/system/gd/l2cap/classic/internal/link.cc
@@ -164,7 +164,7 @@ void Link::SendConnectionRequest(Psm psm, Cid local_cid,
ConnectionResult result{
.connection_result_code = ConnectionResultCode::FAIL_REMOTE_NOT_SUPPORT,
};
- pending_dynamic_channel_connection.on_fail_callback_.Invoke(result);
+ pending_dynamic_channel_connection.on_fail_callback_(result);
dynamic_channel_allocator_.FreeChannel(local_cid);
return;
} else {
@@ -286,7 +286,7 @@ void Link::NotifyChannelCreation(Cid cid, std::unique_ptr<DynamicChannel> user_c
"assert failed: local_cid_to_pending_dynamic_channel_connection_map_.find(cid) != "
"local_cid_to_pending_dynamic_channel_connection_map_.end()");
auto& pending_dynamic_channel_connection = local_cid_to_pending_dynamic_channel_connection_map_[cid];
- pending_dynamic_channel_connection.on_open_callback_.Invoke(std::move(user_channel));
+ pending_dynamic_channel_connection.on_open_callback_(std::move(user_channel));
local_cid_to_pending_dynamic_channel_connection_map_.erase(cid);
}
@@ -297,7 +297,7 @@ void Link::NotifyChannelFail(Cid cid, ConnectionResult result) {
"assert failed: local_cid_to_pending_dynamic_channel_connection_map_.find(cid) != "
"local_cid_to_pending_dynamic_channel_connection_map_.end()");
auto& pending_dynamic_channel_connection = local_cid_to_pending_dynamic_channel_connection_map_[cid];
- pending_dynamic_channel_connection.on_fail_callback_.Invoke(result);
+ pending_dynamic_channel_connection.on_fail_callback_(result);
local_cid_to_pending_dynamic_channel_connection_map_.erase(cid);
}
diff --git a/system/gd/l2cap/classic/internal/link_manager.cc b/system/gd/l2cap/classic/internal/link_manager.cc
index 50c170fa3d..6ce3188a71 100644
--- a/system/gd/l2cap/classic/internal/link_manager.cc
+++ b/system/gd/l2cap/classic/internal/link_manager.cc
@@ -303,7 +303,7 @@ void LinkManager::OnConnectFail(hci::Address device, hci::ErrorCode reason, bool
hci::ErrorCodeText(reason));
if (pending_dynamic_channels_callbacks_.find(device) != pending_dynamic_channels_callbacks_.end()) {
for (Link::PendingDynamicChannelConnection& callbacks : pending_dynamic_channels_callbacks_[device]) {
- callbacks.on_fail_callback_.Invoke(DynamicChannelManager::ConnectionResult{
+ callbacks.on_fail_callback_(DynamicChannelManager::ConnectionResult{
.hci_error = hci::ErrorCode::CONNECTION_TIMEOUT,
});
}
diff --git a/system/gd/l2cap/classic/security_enforcement_interface.h b/system/gd/l2cap/classic/security_enforcement_interface.h
index 5ea9df83ff..f951760b52 100644
--- a/system/gd/l2cap/classic/security_enforcement_interface.h
+++ b/system/gd/l2cap/classic/security_enforcement_interface.h
@@ -51,9 +51,9 @@ class SecurityEnforcementRejectAllImpl : public SecurityEnforcementInterface {
SecurityPolicy policy,
ResultCallback result_callback) override {
if (policy == SecurityPolicy::_SDP_ONLY_NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK) {
- result_callback.Invoke(true);
+ result_callback(true);
} else {
- result_callback.Invoke(false);
+ result_callback(false);
}
}
};
diff --git a/system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager_impl.h b/system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager_impl.h
index d8a8b3f35d..bf8adb7f02 100644
--- a/system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager_impl.h
+++ b/system/gd/l2cap/fuzz/fuzz_dynamic_channel_manager_impl.h
@@ -79,12 +79,12 @@ class FuzzDynamicChannelManagerImpl {
}
void SetConnectionOnFail(l2cap::classic::DynamicChannelManager::ConnectionResult result, std::promise<void> promise) {
- std::move(on_fail_callback_).Invoke(result);
+ std::move(on_fail_callback_)(result);
promise.set_value();
}
void SetConnectionOnOpen(std::unique_ptr<l2cap::DynamicChannel> channel, std::promise<void> promise) {
- std::move(on_open_callback_).Invoke(std::move(channel));
+ std::move(on_open_callback_)(std::move(channel));
promise.set_value();
}
diff --git a/system/gd/l2cap/internal/dynamic_channel_impl.cc b/system/gd/l2cap/internal/dynamic_channel_impl.cc
index 0f1b235b35..26139fd5a6 100644
--- a/system/gd/l2cap/internal/dynamic_channel_impl.cc
+++ b/system/gd/l2cap/internal/dynamic_channel_impl.cc
@@ -50,7 +50,7 @@ void DynamicChannelImpl::RegisterOnCloseCallback(DynamicChannel::OnCloseCallback
log::assert_that(on_close_callback_.IsEmpty(), "OnCloseCallback can only be registered once");
// If channel is already closed, call the callback immediately without saving it
if (closed_) {
- on_close_callback.Invoke(close_reason_);
+ on_close_callback(close_reason_);
return;
}
on_close_callback_ = std::move(on_close_callback);
@@ -76,7 +76,7 @@ void DynamicChannelImpl::OnClosed(hci::ErrorCode status) {
close_reason_ = status;
link_ = nullptr;
l2cap_handler_ = nullptr;
- on_close_callback_.Invoke(close_reason_);
+ on_close_callback_(close_reason_);
on_close_callback_ = {};
}
diff --git a/system/gd/l2cap/le/l2cap_le_module.cc b/system/gd/l2cap/le/l2cap_le_module.cc
index 182468d33e..f4f1daee56 100644
--- a/system/gd/l2cap/le/l2cap_le_module.cc
+++ b/system/gd/l2cap/le/l2cap_le_module.cc
@@ -44,9 +44,9 @@ class SecurityEnforcementRejectAllImpl : public SecurityEnforcementInterface {
SecurityPolicy policy,
ResultCallback result_callback) override {
if (policy == SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK) {
- result_callback.Invoke(true);
+ result_callback(true);
} else {
- result_callback.Invoke(false);
+ result_callback(false);
}
}
};
diff --git a/system/gd/security/internal/security_manager_impl.cc b/system/gd/security/internal/security_manager_impl.cc
index 453a152b1b..1f5a8a0483 100644
--- a/system/gd/security/internal/security_manager_impl.cc
+++ b/system/gd/security/internal/security_manager_impl.cc
@@ -815,7 +815,7 @@ void SecurityManagerImpl::InternalEnforceSecurityPolicy(
l2cap::classic::SecurityEnforcementInterface::ResultCallback result_callback) {
if (IsSecurityRequirementSatisfied(remote, policy)) {
// Notify client immediately if already satisfied
- std::move(result_callback).Invoke(true);
+ std::move(result_callback)(true);
return;
}
@@ -855,7 +855,7 @@ void SecurityManagerImpl::UpdateLinkSecurityCondition(hci::AddressWithType remot
log::error("No L2CAP security policy callback pending for {}", remote);
return;
}
- std::move(entry->second.callback_).Invoke(IsSecurityRequirementSatisfied(remote, entry->second.policy_));
+ std::move(entry->second.callback_)(IsSecurityRequirementSatisfied(remote, entry->second.policy_));
enforce_security_policy_callback_map_.erase(entry);
}
@@ -905,7 +905,7 @@ void SecurityManagerImpl::EnforceLeSecurityPolicy(
case l2cap::le::SecurityPolicy::_NOT_FOR_YOU__AUTHORIZATION:
break;
}
- result_callback.Invoke(result);
+ result_callback(result);
}
} // namespace internal
} // namespace security