ohos: integrate bluetooth device discovery agent
Provide a QBluetoothDeviceDiscoveryAgentPrivate implementation for the
OHOS system.
Place the platform-related backend in the ohos subdirectory as a new
qohosbluetoothdevicediscovery module that drives the device discovery
process: start and stop it and notify about a found device, a confirmed
discovery stop, a failure to stop within the expected time or the local
adapter being powered off. Carry the found device address, name, class
and signal strength (RSSI) so the agent can build a
QBluetoothDeviceInfo.
Base the implementation on the following assumptions:
- there is only one local Bluetooth adapter,
- the OHOS device discovery is process wide - one discovery and one
discoveryResult event stream per process - so keep the backend proxy as
a single instance shared by every agent, created on first use and
destroyed with the last agent; stopping a discovery therefore ends it
for every agent,
- leave the discovery duration to the system and detect its end by
polling the discovery state, because the system offers no discovery
state callback,
- report an error when a requested discovery stop is not confirmed
within 30 s: observed on device, the system can take tens of seconds
to confirm a stop, and a 5 s budget reported a spurious error about
half the time,
- support only the Bluetooth Classic discovery method (BLE is not
considered),
- report QBluetoothDeviceDiscoveryAgent::PoweredOffError instead of
finishing the discovery when the local adapter is turned off while a
discovery is ongoing, observing the adapter state through the ohos
bluetooth access proxy,
- report QBluetoothDeviceDiscoveryAgent::MissingPermissionsError through
errorOccurred() when the ACCESS_BLUETOOTH permission is not granted:
check the permission inside the qohosbluetoothdevicediscovery proxy,
which emits a missingPermission() signal, and connect it to
errorOccurred() in the agent, keeping the backend free of Qt error
types,
- defer registering the discoveryResult consumer until the
ACCESS_BLUETOOTH permission is granted, because the registration
requires it, and retry it on every discovery start until it succeeds.
Task-number: QTBUG-147192
Pick-to: 6.12
Change-Id: I07212f4d5053413f08a8dee92e67bb5b9597cd90
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Zbigniew Chyla <zbigniew.chyla@qt.io>