~aleteoryx/muditaos

493a836e3db937afd2d5813709939ff4aa9ac7c4 — Bartosz Cichocki 4 years ago 88a9380
[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
M module-bluetooth/Bluetooth/CommandHandler.cpp => module-bluetooth/Bluetooth/CommandHandler.cpp +3 -1
@@ 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;
    }


M module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp => module-bluetooth/Bluetooth/interface/profiles/ProfileManager.cpp +5 -0
@@ 123,4 123,9 @@ namespace bluetooth
        profilesList[profileType]->setAudioDevice(device);
        return switchProfile(profileType);
    }
    auto ProfileManager::isAddressActuallyUsed(bd_addr_t address) -> bool
    {
        return static_cast<bool>(bd_addr_cmp(address, remoteAddr));
    }

} // namespace bluetooth

M module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp => module-bluetooth/Bluetooth/interface/profiles/ProfileManager.hpp +1 -0
@@ 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<BluetoothAudioDevice> device) -> Error::Code;