ohos: add ohos SPP server implementation
Implement QBluetoothServerPrivate and QBluetoothServer for OHOS, with
QOhosBluetoothServerProxy holding the system JS interactions behind
them. Ignore the local address and the port listen() is given, because
OHOS offers no control over the local device address and no way to
start listening on a desired port.
Reach the server context through makeServerProxyContext() and
tryGetServerProxyContext() over a file static map keyed by the
synthesized server port, so QBluetoothServiceInfo can find the server
it registers its service with. Keep that key below 256, because
QBluetoothServer::listen(const QBluetoothUuid &, const QString &)
narrows the port to quint8 when it builds the service record.
Queue the accepted client sockets in the server context until the user
takes them over with nextPendingConnection(). Limit the accepted
connections with the queue length, so that the clients exceeding
maxPendingConnections are closed right away.
Report the server errors to the user. The sppListen() and sppAccept()
calls throw their business errors, so catch them and map the error
codes to the QBluetoothServer errors: the not supported profile to
UnsupportedProtocolError and the failed operation to UnknownError.
Report PoweredOffError when bluetooth is turned off, which also stops
accepting the next connections.
Check the access bluetooth permission again before accepting a
connection. HarmonyOS documents neither a permission nor a 201 error
on sppAccept(), so a permission revoked after listen() would otherwise
leave the server accepting connections.
Task-number: QTBUG-147192
Pick-to: 6.12
Change-Id: I6a0adee67bf607330372d3932f47ae564573f56b
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Zbigniew Chyla <zbigniew.chyla@qt.io>