BlueZ: avoid registering the same UUID twice
Certain applications, like the btchat example, need to act as both a
server and a client, using the same service-UUID.
In the server role, they need to advertise the service. To achieve that,
QBluetoothServiceInfo BlueZ implementation is registering a profile
for the UUID.
In the client role, the application needs to connect to a service with
the same service-UUID, as advertised by the server. In order to do it,
the QBluetoothSocketPrivateBluezDBus::connectToServiceHelper() method
was trying to register another profile for the same service-UUID.
Starting from some BlueZ version, this is causing an error:
Client profile registration failed: "UUID already registered"
However, reading the BlueZ docs, I noticed that the RegisterProfile()
method has a "Service" option, whose description tells:
string Service: The primary service class UUID (if different from
the actual profile UUID).
This option was already used in the code, but it was a no-op, because
it had the same service-UUID, as the one that we were trying to
register.
This patch tries to register a client profile with a random UUID, but
pass the correct UUID in the "Service" option (as before). My tests
show that this approach works.
With this patch I was able to start two btchat applications in my
Ubuntu VM, and use one of them as a server (with a macOS client),
and the other one - as a client connected to an Android server.
Task-number: QTBUG-123197
Pick-to: 6.10 6.8 6.5
Change-Id: I71bc231d49929ad54498e9a391d4668e51e6bc3b
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>