From 493a836e3db937afd2d5813709939ff4aa9ac7c4 Mon Sep 17 00:00:00 2001 From: Bartosz Cichocki Date: Thu, 8 Jul 2021 13:01:30 +0200 Subject: [PATCH] [EGD-7108] Fix disconnecting all devices during unpairing Due to wrong logic, all devices were disconnecing during unparing Now, the disconnecting is performed only when the unpaired devices is the connected one --- module-bluetooth/Bluetooth/CommandHandler.cpp | 4 +++- .../Bluetooth/interface/profiles/ProfileManager.cpp | 5 +++++ .../Bluetooth/interface/profiles/ProfileManager.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/module-bluetooth/Bluetooth/CommandHandler.cpp b/module-bluetooth/Bluetooth/CommandHandler.cpp index 680434052a647b3ce4c2394c5c2f9d6288007db2..03405fe2de8414012f60070a395defa9a7869d19 100644 --- a/module-bluetooth/Bluetooth/CommandHandler.cpp +++ b/module-bluetooth/Bluetooth/CommandHandler.cpp @@ -158,7 +158,9 @@ namespace bluetooth Error::Code CommandHandler::unpair(uint8_t *addr) { LOG_INFO("Unpairing..."); - profileManager->disconnect(); + if (profileManager->isAddressActuallyUsed(addr)) { + profileManager->disconnect(); + } return driver->unpair(addr) ? Error::Success : Error::LibraryError; } diff --git a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp index 1cf3501c7ca964f5f8ca78874118f247c6b347a4..8d7100c793dba6d280f1a41c770d021f1265d99a 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp +++ b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp @@ -123,4 +123,9 @@ namespace bluetooth profilesList[profileType]->setAudioDevice(device); return switchProfile(profileType); } + auto ProfileManager::isAddressActuallyUsed(bd_addr_t address) -> bool + { + return static_cast(bd_addr_cmp(address, remoteAddr)); + } + } // namespace bluetooth diff --git a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp index 3646f31a4b857c0b29dfaa759c30c89c62ecc65b..a28e57d4091193ca1af12e22e15264395f31baa3 100644 --- a/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp +++ b/module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp @@ -42,6 +42,7 @@ namespace bluetooth auto startRinging() -> Error::Code; auto stopRinging() -> Error::Code; auto initializeCall() -> Error::Code; + auto isAddressActuallyUsed(bd_addr_t address) -> bool; auto setAudioDevice(std::shared_ptr device) -> Error::Code;