diff --git a/system/gd/hci/acl_manager/classic_acl_connection_test.cc b/system/gd/hci/acl_manager/classic_acl_connection_test.cc index 628a37a9370a30de834469c44962b35662cafd18..af062020a1ba24ee50a2c5b51cef52e4ed41cf13 100644 --- a/system/gd/hci/acl_manager/classic_acl_connection_test.cc +++ b/system/gd/hci/acl_manager/classic_acl_connection_test.cc @@ -124,8 +124,9 @@ class TestAclConnectionInterface : public hci::AclConnectionInterface { command_queue_.push(std::move(command)); command_status_callbacks.push_back(std::move(on_status)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -136,8 +137,9 @@ class TestAclConnectionInterface : public hci::AclConnectionInterface { command_queue_.push(std::move(command)); command_complete_callbacks.push_back(std::move(on_complete)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } 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 a210c2227b407c99f3a7502a02ffbc8435099e20..52d4c77fcad5ada6da24511d17ee0cd4afb2939f 100644 --- a/system/gd/hci/acl_manager/le_acl_connection_test.cc +++ b/system/gd/hci/acl_manager/le_acl_connection_test.cc @@ -102,8 +102,9 @@ class TestLeAclConnectionInterface : public hci::LeAclConnectionInterface { command_queue_.push(std::move(command)); command_status_callbacks.push_back(std::move(on_status)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -114,8 +115,9 @@ class TestLeAclConnectionInterface : public hci::LeAclConnectionInterface { command_queue_.push(std::move(command)); command_complete_callbacks.push_back(std::move(on_complete)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/hci/acl_manager/le_impl_test.cc b/system/gd/hci/acl_manager/le_impl_test.cc index d75f7ce16ee5810a61dba7e50da0302e3f54cd44..f2779d20a227033bf15adeed060de69e04b72d28 100644 --- a/system/gd/hci/acl_manager/le_impl_test.cc +++ b/system/gd/hci/acl_manager/le_impl_test.cc @@ -256,8 +256,9 @@ class TestHciLayer : public HciLayer { command_queue_.push(std::move(command)); command_status_callbacks.push_back(std::move(on_status)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -268,8 +269,9 @@ class TestHciLayer : public HciLayer { command_queue_.push(std::move(command)); command_complete_callbacks.push_back(std::move(on_complete)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/hci/acl_manager_unittest.cc b/system/gd/hci/acl_manager_unittest.cc index 79d083480cbd3eca9c65c0e07404b6f7a58fbf91..9b296669518f4ac58d8aba868144b85cc05c1da5 100644 --- a/system/gd/hci/acl_manager_unittest.cc +++ b/system/gd/hci/acl_manager_unittest.cc @@ -320,8 +320,9 @@ class TestHciLayer : public HciLayer { private: void Notify() { if (hci_command_promise_ != nullptr) { - hci_command_promise_->set_value(); - hci_command_promise_.reset(); + std::promise<void>* prom = hci_command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -372,8 +373,9 @@ class MockLeConnectionCallbacks : public LeConnectionCallbacks { void OnLeConnectSuccess(AddressWithType address_with_type, std::unique_ptr<LeAclConnection> connection) override { le_connections_.push_back(std::move(connection)); if (le_connection_promise_ != nullptr) { - le_connection_promise_->set_value(); - le_connection_promise_.reset(); + std::promise<void>* prom = le_connection_promise_.release(); + prom->set_value(); + delete prom; } } MOCK_METHOD(void, OnLeConnectFail, (AddressWithType, ErrorCode reason, bool locally_initiated), (override)); diff --git a/system/gd/hci/hci_layer_test.cc b/system/gd/hci/hci_layer_test.cc index ff7a729dbc1f2c0cba4c1d842ff6ddd99d8c7773..1d79e9bb114de3d105108daa57feb480b8bfca4a 100644 --- a/system/gd/hci/hci_layer_test.cc +++ b/system/gd/hci/hci_layer_test.cc @@ -84,18 +84,18 @@ class TestHciHal : public hal::HciHal { void sendHciCommand(hal::HciPacket command) override { outgoing_commands_.push_back(std::move(command)); if (sent_command_promise_ != nullptr) { - auto promise = std::move(sent_command_promise_); - sent_command_promise_.reset(); - promise->set_value(); + std::promise<void>* prom = sent_command_promise_.release(); + prom->set_value(); + delete prom; } } void sendAclData(hal::HciPacket data) override { outgoing_acl_.push_back(std::move(data)); if (sent_acl_promise_ != nullptr) { - auto promise = std::move(sent_acl_promise_); - sent_acl_promise_.reset(); - promise->set_value(); + std::promise<void>* prom = sent_acl_promise_.release(); + prom->set_value(); + delete prom; } } @@ -106,9 +106,9 @@ class TestHciHal : public hal::HciHal { void sendIsoData(hal::HciPacket data) override { outgoing_iso_.push_back(std::move(data)); if (sent_iso_promise_ != nullptr) { - auto promise = std::move(sent_iso_promise_); - sent_iso_promise_.reset(); - promise->set_value(); + std::promise<void>* prom = sent_iso_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/hci/le_address_manager_test.cc b/system/gd/hci/le_address_manager_test.cc index e2000cfeafa5e51b32a802283d8d1d4592f829d6..b1ede37b37dc6bc105d267d2651f2c8c9cbb0ec5 100644 --- a/system/gd/hci/le_address_manager_test.cc +++ b/system/gd/hci/le_address_manager_test.cc @@ -57,8 +57,9 @@ class TestHciLayer : public HciLayer { command_queue_.push(std::move(command)); command_complete_callbacks.push_back(std::move(on_complete)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -136,8 +137,9 @@ class RotatorClient : public LeAddressManagerCallback { paused = false; le_address_manager_->AckResume(this); if (resume_promise_ != nullptr) { - resume_promise_->set_value(); - resume_promise_.reset(); + std::promise<void>* prom = resume_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/hci/le_periodic_sync_manager_test.cc b/system/gd/hci/le_periodic_sync_manager_test.cc index 1d61a2649a99c66b517bcd49284000b64190f10c..2bd90382a4088f90894d53fab6b941595912a9ab 100644 --- a/system/gd/hci/le_periodic_sync_manager_test.cc +++ b/system/gd/hci/le_periodic_sync_manager_test.cc @@ -47,8 +47,9 @@ class TestLeScanningInterface : public LeScanningInterface { command_queue_.push(std::move(command)); command_complete_callbacks.push_back(std::move(on_complete)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -58,8 +59,9 @@ class TestLeScanningInterface : public LeScanningInterface { command_queue_.push(std::move(command)); command_status_callbacks.push_back(std::move(on_status)); if (command_promise_ != nullptr) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/hci/le_scanning_manager_test.cc b/system/gd/hci/le_scanning_manager_test.cc index 31d608d3017de07dd1f2ae020504916fa824eea1..8c2831938df832a67f6fe31806e2187cb6aa5dcc 100644 --- a/system/gd/hci/le_scanning_manager_test.cc +++ b/system/gd/hci/le_scanning_manager_test.cc @@ -146,8 +146,9 @@ class TestHciLayer : public HciLayer { command_status_callbacks.push_back(std::move(on_status)); command_count_--; if (command_promise_ != nullptr && command_count_ == 0) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } @@ -159,8 +160,9 @@ class TestHciLayer : public HciLayer { command_complete_callbacks.push_back(std::move(on_complete)); command_count_--; if (command_promise_ != nullptr && command_count_ == 0) { - command_promise_->set_value(); - command_promise_.reset(); + std::promise<void>* prom = command_promise_.release(); + prom->set_value(); + delete prom; } } diff --git a/system/gd/os/android/wakelock_native_test.cc b/system/gd/os/android/wakelock_native_test.cc index 66be72296368d9f012d887a2b652e14848233239..36f8af87d726b3a880425572494e23f0aa3b064d 100644 --- a/system/gd/os/android/wakelock_native_test.cc +++ b/system/gd/os/android/wakelock_native_test.cc @@ -53,8 +53,9 @@ class PromiseFutureContext { static void FulfilPromise(std::unique_ptr<std::promise<void>>& promise) { std::lock_guard<std::recursive_mutex> lock_guard(mutex); if (promise != nullptr) { - promise->set_value(); - promise = nullptr; + std::promise<void>* prom = promise.release(); + prom->set_value(); + delete prom; } }