BlueZ: prefer powered on adapters when no address is specified


Many bluetooth classes allow to specify the address of the local
bluetooth adapter to use. However, if none is specified, the backend
chooses some adapter on its own. The pre-existing logic was that the
Linux BlueZ backend was always picking the first adapter in the list.
However, the first adapter might be disabled (via UI or using rfkill).

This patch changes the logic of choosing the adapter to pick the first
powered on adapter. If none of them are powered on, still the first one
is picked.
Conveniently, it is enough to only modify a single function in the
bluez helpers header, because that part of BlueZ DBus API is used in
both Linux backend implementations. The HciManager class, which will
be used when QT_BLUETOOTH_USE_KERNEL_PERIPHERAL is set, already
receives an actual bluetooth device address, so its logic can stay
unchanged.

Note that this patch does not affect the case when the user explicitly
provides an adapter address. In such cases the requested adapter is
selected even if it's powered off.

The patch was tested by using two USB Bluetooth adapters, and disabling
the first one using `rfkill block <id>`.

[ChangeLog][QtBluetooth][Linux][Platform Specific Changes] If the local
adapter address is not specified, the Linux backend now tries to pick
the first powered on adapter instead of simply picking the first in the
list.

Fixes: QTBUG-116664
Pick-to: 6.9 6.8
Change-Id: I6fe02307353753bc3e0acca72ec8e4b2b10b71f5
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commit82bd4aa003b358b801674623c7e544390e46be58
parent3c477ceccab8673b2d8f8abd5c397343c64cccdc
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeTue, 4 Feb 2025 10:03:10 +0100