ohos: add ohos SPP socket implementation
Implement QBluetoothSocketBasePrivate for OHOS in
QBluetoothSocketPrivateOhos, with QOhosBluetoothSocketProxy holding the
system JS interactions behind it. Select the UUID based
connectToServiceHelper() overload in QBluetoothSocketBasePrivate,
because OHOS connects to a service identified by its UUID and gives no
access to the RFCOMM channel number. Befriend
QBluetoothSocketPrivateOhos in QBluetoothSocket so that the backend can
report the socket state and error changes.
Take over the sockets created by the server through
setSocketDescriptor(), which picks up the descriptor handler that
QOhosBluetoothSocketProxy registered when OHOS reported the accepted
connection. Reject the take over when there is no such socket or when
the data channel for it cannot be obtained, so that a socket without
the system socket behind it is never reported as connected.
Support only RFCOMM connections identified by a service UUID: OHOS
exposes neither the local socket endpoint nor the RFCOMM channel
number, so connectToService() with a port reports
UnsupportedProtocolError and localAddress(), localPort() and
peerPort() stay empty.
Report the socket errors to the user. Map the OHOS error codes to the
QBluetoothSocket errors: the IO error to UnknownSocketError and the
failed operation to OperationError. Return -1 from writeData() when
writing to the system socket fails, and report the error from the call
that detected it.
Track the connect requests with their ids, so that closing the socket
cancels the connect which is still in progress. Close the system socket
reported for a cancelled request instead of taking it over, and keep no
peer device for a socket which is not connected.
Task-number: QTBUG-147192
Pick-to: 6.12
Change-Id: I9c44e978e37c620448684cad7a10224db847c0da
Reviewed-by: Zbigniew Chyla <zbigniew.chyla@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>