diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-02-10 15:37:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-13 09:47:27 +0100 |
commit | 173d16efb54ccc152f19afb9b1c2a87915fb414b (patch) | |
tree | f07ce85ba2cb973e3c08f3ed84252d92ee1c16de /src/bluetooth/qbluetoothserver.cpp | |
parent | dd75b1f776695006ca96fd43f995c3ba0549b968 (diff) |
Port QtBluetooth to Android
This is a feature merge to dev targeting Qt 5.3.
Known issues:
-QTBUG-36754: QBluetoothServer::close() crashes
-QTBUG-36763: QBluetothTransferManager port to Android not possible
-QTBUG-36764: Improve QBluetoothLocalDevice::connectedDevices()
-QTBUG-36810: Remove direct use of Android action strings
The above issues and some other minor TODO's will be addressed
until final release time.
Task-number: QTBUG-33792
[ChangeLog][QtBluetooth][Android] QtBluetooth has been ported to
Android.
Change-Id: I31ba83e3b7d6aa68e7258b7e43235de7d1a6e68a
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/bluetooth/qbluetoothserver.cpp')
-rw-r--r-- | src/bluetooth/qbluetoothserver.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/bluetooth/qbluetoothserver.cpp b/src/bluetooth/qbluetoothserver.cpp index e70ec1db..670b522f 100644 --- a/src/bluetooth/qbluetoothserver.cpp +++ b/src/bluetooth/qbluetoothserver.cpp @@ -90,7 +90,8 @@ QT_BEGIN_NAMESPACE /*! \fn void QBluetoothServer::close() - Closes and resets the listening socket. + Closes and resets the listening socket. Any already established \l QBluetoothSocket + continues to operate and must be separately \l {QBluetoothSocket::close()}{closed}. */ /*! @@ -110,7 +111,11 @@ QT_BEGIN_NAMESPACE /*! \fn bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port) - Start listening for incoming connections to \a address on \a port. + Start listening for incoming connections to \a address on \a port. \a address + must be a local Bluetooth adapter address and \a port must be larger than zero + and not be taken already by another Bluetooth server object. It is recommended + to avoid setting a port number to enable the system to automatically choose + a port. Returns \c true if the operation succeeded and the server is listening for incoming connections, otherwise returns \c false. @@ -124,7 +129,8 @@ QT_BEGIN_NAMESPACE /*! \fn void QBluetoothServer::setMaxPendingConnections(int numConnections) - Sets the maximum number of pending connections to \a numConnections. + Sets the maximum number of pending connections to \a numConnections. If + the number of pending sockets exceeds this limit new sockets will be rejected. \sa maxPendingConnections() */ @@ -207,10 +213,13 @@ QBluetoothServiceInfo QBluetoothServer::listen(const QBluetoothUuid &uuid, const QBluetoothServiceInfo::Sequence classId; classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort)); - serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); serviceInfo.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, classId); + //Android requires custom uuid to be set as service class and not as service uuid + classId.prepend(QVariant::fromValue(uuid)); + serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId); + serviceInfo.setServiceUuid(uuid); QBluetoothServiceInfo::Sequence protocolDescriptorList; @@ -248,6 +257,8 @@ bool QBluetoothServer::isListening() const #ifdef QT_QNX_BLUETOOTH if (!d->socket) return false; +#elif defined(QT_ANDROID_BLUETOOTH) + return d->isListening(); #endif return d->socket->state() == QBluetoothSocket::ListeningState; @@ -268,6 +279,13 @@ int QBluetoothServer::maxPendingConnections() const /*! \fn QBluetoothServer::setSecurityFlags(QBluetooth::SecurityFlags security) Sets the Bluetooth security flags to \a security. This function must be called before calling listen(). + The Bluetooth link will always be encrypted when using Bluetooth 2.1 devices as encryption is + mandatory. + + Android only supports two levels of security (secure and non-secure). If this flag is set to + \l QBluetooth::NoSecurity the server object will not employ any authentication or encryption. + Any other security flag combination will trigger a secure Bluetooth connection. + On BlackBerry, security flags are not supported and will be ignored. */ |