From 40beb226dfe8c23f290d554d5449806e91227f7e Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 19 Jul 2018 17:37:40 +0200 Subject: Add QBluetoothSocketPrivate interface for Android Task-number: QTBUG-68550 Change-Id: Iac05cccd4f6e1b44a30568fb9b6c9171204b53fd Reviewed-by: Lubomir I. Ivanov Reviewed-by: Oliver Wolff --- src/bluetooth/android/inputstreamthread.cpp | 4 +- src/bluetooth/android/inputstreamthread_p.h | 6 +- src/bluetooth/bluetooth.pro | 4 +- src/bluetooth/qbluetoothserver_android.cpp | 2 +- src/bluetooth/qbluetoothsocket.cpp | 6 ++ src/bluetooth/qbluetoothsocket.h | 1 + src/bluetooth/qbluetoothsocket_android.cpp | 68 +++++++------- src/bluetooth/qbluetoothsocket_android_p.h | 138 ++++++++++++++++++++++++++++ src/bluetooth/qbluetoothsocket_p.h | 57 +----------- 9 files changed, 189 insertions(+), 97 deletions(-) create mode 100644 src/bluetooth/qbluetoothsocket_android_p.h diff --git a/src/bluetooth/android/inputstreamthread.cpp b/src/bluetooth/android/inputstreamthread.cpp index 982c477b..1cc353a3 100644 --- a/src/bluetooth/android/inputstreamthread.cpp +++ b/src/bluetooth/android/inputstreamthread.cpp @@ -42,13 +42,13 @@ #include #include "android/inputstreamthread_p.h" -#include "qbluetoothsocket_p.h" +#include "qbluetoothsocket_android_p.h" QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID) -InputStreamThread::InputStreamThread(QBluetoothSocketPrivate *socket) +InputStreamThread::InputStreamThread(QBluetoothSocketPrivateAndroid *socket) : QObject(), m_socket_p(socket), expectClosure(false) { } diff --git a/src/bluetooth/android/inputstreamthread_p.h b/src/bluetooth/android/inputstreamthread_p.h index a6ee0655..060b2acf 100644 --- a/src/bluetooth/android/inputstreamthread_p.h +++ b/src/bluetooth/android/inputstreamthread_p.h @@ -59,13 +59,13 @@ QT_BEGIN_NAMESPACE -class QBluetoothSocketPrivate; +class QBluetoothSocketPrivateAndroid; class InputStreamThread : public QObject { Q_OBJECT public: - explicit InputStreamThread(QBluetoothSocketPrivate *socket_p); + explicit InputStreamThread(QBluetoothSocketPrivateAndroid *socket_p); qint64 bytesAvailable() const; bool canReadLine() const; @@ -82,7 +82,7 @@ signals: void error(int errorCode); private: - QBluetoothSocketPrivate *m_socket_p; + QBluetoothSocketPrivateAndroid *m_socket_p; QAndroidJniObject javaInputStreamThread; mutable QMutex m_mutex; bool expectClosure; diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro index 65c46559..69883613 100644 --- a/src/bluetooth/bluetooth.pro +++ b/src/bluetooth/bluetooth.pro @@ -155,8 +155,10 @@ qtConfig(bluez) { qbluetoothserver_android.cpp \ qlowenergycontroller_android.cpp - PRIVATE_HEADERS += qlowenergycontroller_android_p.h + PRIVATE_HEADERS += qlowenergycontroller_android_p.h \ + qbluetoothsocket_android_p.h + PRIVATE_HEADERS -= qbluetoothsocket_p.h } else:osx { QT_PRIVATE = concurrent DEFINES += QT_OSX_BLUETOOTH diff --git a/src/bluetooth/qbluetoothserver_android.cpp b/src/bluetooth/qbluetoothserver_android.cpp index 7d3d3588..b001adb8 100644 --- a/src/bluetooth/qbluetoothserver_android.cpp +++ b/src/bluetooth/qbluetoothserver_android.cpp @@ -41,7 +41,7 @@ #include "qbluetoothserver.h" #include "qbluetoothserver_p.h" #include "qbluetoothsocket.h" -#include "qbluetoothsocket_p.h" +#include "qbluetoothsocket_android_p.h" #include "qbluetoothlocaldevice.h" #include "android/serveracceptancethread_p.h" diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 1b187f4f..d59b2adb 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -41,6 +41,8 @@ #include "qbluetoothsocket.h" #if QT_CONFIG(bluez) #include "qbluetoothsocket_bluez_p.h" +#elif defined(QT_ANDROID_BLUETOOTH) +#include "qbluetoothsocket_android_p.h" #else #include "qbluetoothsocket_p.h" #endif @@ -258,6 +260,8 @@ QBluetoothSocket::QBluetoothSocket(QBluetoothServiceInfo::Protocol socketType, Q { #if QT_CONFIG(bluez) d_ptr = new QBluetoothSocketPrivateBluez(); +#elif defined(QT_ANDROID_BLUETOOTH) + d_ptr = new QBluetoothSocketPrivateAndroid(); #else d_ptr = new QBluetoothSocketPrivate(); #endif @@ -277,6 +281,8 @@ QBluetoothSocket::QBluetoothSocket(QObject *parent) { #if QT_CONFIG(bluez) d_ptr = new QBluetoothSocketPrivateBluez(); +#elif defined(QT_ANDROID_BLUETOOTH) + d_ptr = new QBluetoothSocketPrivateAndroid(); #else d_ptr = new QBluetoothSocketPrivate(); #endif diff --git a/src/bluetooth/qbluetoothsocket.h b/src/bluetooth/qbluetoothsocket.h index 17e046ba..fc36b9ca 100644 --- a/src/bluetooth/qbluetoothsocket.h +++ b/src/bluetooth/qbluetoothsocket.h @@ -71,6 +71,7 @@ class Q_BLUETOOTH_EXPORT QBluetoothSocket : public QIODevice friend class QBluetoothServer; friend class QBluetoothServerPrivate; friend class QBluetoothSocketPrivate; + friend class QBluetoothSocketPrivateAndroid; friend class QBluetoothSocketPrivateBluez; friend class QBluetoothSocketPrivateBluezDBus; diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp index 9a81fc3a..42fe4ff4 100644 --- a/src/bluetooth/qbluetoothsocket_android.cpp +++ b/src/bluetooth/qbluetoothsocket_android.cpp @@ -39,7 +39,7 @@ ****************************************************************************/ #include "qbluetoothsocket.h" -#include "qbluetoothsocket_p.h" +#include "qbluetoothsocket_android_p.h" #include "qbluetoothaddress.h" #include #include @@ -148,8 +148,8 @@ public: { } - // Runs in same thread as QBluetoothSocketPrivate - void setupWorker(QBluetoothSocketPrivate* d_ptr, const QAndroidJniObject& socketObject, + // Runs in same thread as QBluetoothSocketPrivateAndroid + void setupWorker(QBluetoothSocketPrivateAndroid* d_ptr, const QAndroidJniObject& socketObject, const QAndroidJniObject& uuidObject, bool useFallback, const QBluetoothUuid& qtUuid = QBluetoothUuid()) { @@ -159,18 +159,18 @@ public: connect(this, &QThread::finished, worker, &QObject::deleteLater); connect(this, &QThread::finished, this, &QObject::deleteLater); - connect(d_ptr, &QBluetoothSocketPrivate::connectJavaSocket, + connect(d_ptr, &QBluetoothSocketPrivateAndroid::connectJavaSocket, worker, &SocketConnectWorker::connectSocket); - connect(d_ptr, &QBluetoothSocketPrivate::closeJavaSocket, + connect(d_ptr, &QBluetoothSocketPrivateAndroid::closeJavaSocket, worker, &SocketConnectWorker::closeSocket); connect(worker, &SocketConnectWorker::socketConnectDone, - d_ptr, &QBluetoothSocketPrivate::socketConnectSuccess); + d_ptr, &QBluetoothSocketPrivateAndroid::socketConnectSuccess); if (useFallback) { connect(worker, &SocketConnectWorker::socketConnectFailed, - d_ptr, &QBluetoothSocketPrivate::fallbackSocketConnectFailed); + d_ptr, &QBluetoothSocketPrivateAndroid::fallbackSocketConnectFailed); } else { connect(worker, &SocketConnectWorker::socketConnectFailed, - d_ptr, &QBluetoothSocketPrivate::defaultSocketConnectFailed); + d_ptr, &QBluetoothSocketPrivateAndroid::defaultSocketConnectFailed); } workerPointer = worker; @@ -204,7 +204,7 @@ static QBluetoothUuid reverseUuid(const QBluetoothUuid &serviceUuid) return QBluetoothUuid(reversed); } -QBluetoothSocketPrivate::QBluetoothSocketPrivate() +QBluetoothSocketPrivateAndroid::QBluetoothSocketPrivateAndroid() : inputThread(0) { @@ -216,13 +216,13 @@ QBluetoothSocketPrivate::QBluetoothSocketPrivate() qRegisterMetaType(); } -QBluetoothSocketPrivate::~QBluetoothSocketPrivate() +QBluetoothSocketPrivateAndroid::~QBluetoothSocketPrivateAndroid() { if (state != QBluetoothSocket::UnconnectedState) emit closeJavaSocket(); } -bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol type) +bool QBluetoothSocketPrivateAndroid::ensureNativeSocket(QBluetoothServiceInfo::Protocol type) { socketType = type; if (socketType == QBluetoothServiceInfo::RfcommProtocol) @@ -231,7 +231,7 @@ bool QBluetoothSocketPrivate::ensureNativeSocket(QBluetoothServiceInfo::Protocol return false; } -bool QBluetoothSocketPrivate::fallBackConnect(QAndroidJniObject uuid, int channel) +bool QBluetoothSocketPrivateAndroid::fallBackConnect(QAndroidJniObject uuid, int channel) { qCWarning(QT_BT_ANDROID) << "Falling back to getServiceChannel() workaround."; @@ -350,7 +350,7 @@ bool QBluetoothSocketPrivate::fallBackConnect(QAndroidJniObject uuid, int channe /* * Workaround for QTBUG-61392 */ -bool QBluetoothSocketPrivate::fallBackReversedConnect(const QBluetoothUuid &uuid) +bool QBluetoothSocketPrivateAndroid::fallBackReversedConnect(const QBluetoothUuid &uuid) { Q_Q(QBluetoothSocket); @@ -420,7 +420,7 @@ bool QBluetoothSocketPrivate::fallBackReversedConnect(const QBluetoothUuid &uuid * 8. if threaded connect on fallback channel fails call fallbackSocketConnectFailed() * -> complete failure of entire connectToService() * */ -void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, +void QBluetoothSocketPrivateAndroid::connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, QIODevice::OpenMode openMode) { @@ -503,7 +503,7 @@ void QBluetoothSocketPrivate::connectToService(const QBluetoothAddress &address, emit connectJavaSocket(); } -void QBluetoothSocketPrivate::socketConnectSuccess(const QAndroidJniObject &socket) +void QBluetoothSocketPrivateAndroid::socketConnectSuccess(const QAndroidJniObject &socket) { Q_Q(QBluetoothSocket); QAndroidJniEnvironment env; @@ -563,7 +563,7 @@ void QBluetoothSocketPrivate::socketConnectSuccess(const QAndroidJniObject &sock emit q->connected(); } -void QBluetoothSocketPrivate::defaultSocketConnectFailed( +void QBluetoothSocketPrivateAndroid::defaultSocketConnectFailed( const QAndroidJniObject &socket, const QAndroidJniObject &targetUuid, const QBluetoothUuid &qtTargetUuid) { @@ -592,7 +592,7 @@ void QBluetoothSocketPrivate::defaultSocketConnectFailed( } } -void QBluetoothSocketPrivate::fallbackSocketConnectFailed( +void QBluetoothSocketPrivateAndroid::fallbackSocketConnectFailed( const QAndroidJniObject &socket, const QAndroidJniObject &targetUuid) { Q_UNUSED(targetUuid); @@ -611,7 +611,7 @@ void QBluetoothSocketPrivate::fallbackSocketConnectFailed( q->setSocketState(QBluetoothSocket::UnconnectedState); } -void QBluetoothSocketPrivate::abort() +void QBluetoothSocketPrivateAndroid::abort() { if (state == QBluetoothSocket::UnconnectedState) return; @@ -624,7 +624,7 @@ void QBluetoothSocketPrivate::abort() * thread because inputStream.read() throws IOException * In turn the thread stops and throws an error which sets * new state, error and emits relevant signals. - * See QBluetoothSocketPrivate::inputThreadError() for details + * See QBluetoothSocketPrivateAndroid::inputThreadError() for details */ if (inputThread) @@ -653,7 +653,7 @@ void QBluetoothSocketPrivate::abort() } } -QString QBluetoothSocketPrivate::localName() const +QString QBluetoothSocketPrivateAndroid::localName() const { if (adapter.isValid()) return adapter.callObjectMethod("getName").toString(); @@ -661,7 +661,7 @@ QString QBluetoothSocketPrivate::localName() const return QString(); } -QBluetoothAddress QBluetoothSocketPrivate::localAddress() const +QBluetoothAddress QBluetoothSocketPrivateAndroid::localAddress() const { QString result; if (adapter.isValid()) @@ -670,13 +670,13 @@ QBluetoothAddress QBluetoothSocketPrivate::localAddress() const return QBluetoothAddress(result); } -quint16 QBluetoothSocketPrivate::localPort() const +quint16 QBluetoothSocketPrivateAndroid::localPort() const { // Impossible to get channel number with current Android API (Levels 5 to 19) return 0; } -QString QBluetoothSocketPrivate::peerName() const +QString QBluetoothSocketPrivateAndroid::peerName() const { if (!remoteDevice.isValid()) return QString(); @@ -684,7 +684,7 @@ QString QBluetoothSocketPrivate::peerName() const return remoteDevice.callObjectMethod("getName", "()Ljava/lang/String;").toString(); } -QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const +QBluetoothAddress QBluetoothSocketPrivateAndroid::peerAddress() const { if (!remoteDevice.isValid()) return QBluetoothAddress(); @@ -695,13 +695,13 @@ QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const return QBluetoothAddress(address); } -quint16 QBluetoothSocketPrivate::peerPort() const +quint16 QBluetoothSocketPrivateAndroid::peerPort() const { // Impossible to get channel number with current Android API (Levels 5 to 13) return 0; } -qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) +qint64 QBluetoothSocketPrivateAndroid::writeData(const char *data, qint64 maxSize) { //TODO implement buffered behavior (so far only unbuffered) Q_Q(QBluetoothSocket); @@ -731,7 +731,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) return maxSize; } -qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize) +qint64 QBluetoothSocketPrivateAndroid::readData(char *data, qint64 maxSize) { Q_Q(QBluetoothSocket); if (state != QBluetoothSocket::ConnectedState || !inputThread) { @@ -744,7 +744,7 @@ qint64 QBluetoothSocketPrivate::readData(char *data, qint64 maxSize) return inputThread->readData(data, maxSize); } -void QBluetoothSocketPrivate::inputThreadError(int errorCode) +void QBluetoothSocketPrivateAndroid::inputThreadError(int errorCode) { Q_Q(QBluetoothSocket); @@ -778,7 +778,7 @@ void QBluetoothSocketPrivate::inputThreadError(int errorCode) emit q->disconnected(); } -void QBluetoothSocketPrivate::close() +void QBluetoothSocketPrivateAndroid::close() { /* This function is called by QBluetoothSocket::close and softer version QBluetoothSocket::disconnectFromService() which difference I do not quite fully understand. @@ -787,7 +787,7 @@ void QBluetoothSocketPrivate::close() abort(); } -bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, +bool QBluetoothSocketPrivateAndroid::setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) { Q_UNUSED(socketDescriptor); @@ -798,7 +798,7 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(int socketDescriptor, QBluetoo return false; } -bool QBluetoothSocketPrivate::setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType_, +bool QBluetoothSocketPrivateAndroid::setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType_, QBluetoothSocket::SocketState socketState, QBluetoothSocket::OpenMode openMode) { Q_Q(QBluetoothSocket); @@ -866,7 +866,7 @@ bool QBluetoothSocketPrivate::setSocketDescriptor(const QAndroidJniObject &socke return true; } -qint64 QBluetoothSocketPrivate::bytesAvailable() const +qint64 QBluetoothSocketPrivateAndroid::bytesAvailable() const { //We cannot access buffer directly as it is part of different thread if (inputThread) @@ -875,12 +875,12 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const return 0; } -qint64 QBluetoothSocketPrivate::bytesToWrite() const +qint64 QBluetoothSocketPrivateAndroid::bytesToWrite() const { return 0; // nothing because always unbuffered } -bool QBluetoothSocketPrivate::canReadLine() const +bool QBluetoothSocketPrivateAndroid::canReadLine() const { // We cannot access buffer directly as it is part of different thread if (inputThread) diff --git a/src/bluetooth/qbluetoothsocket_android_p.h b/src/bluetooth/qbluetoothsocket_android_p.h new file mode 100644 index 00000000..34fd260a --- /dev/null +++ b/src/bluetooth/qbluetoothsocket_android_p.h @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtBluetooth module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +#ifndef QBLUETOOTHSOCKET_ANDROID_P_H +#define QBLUETOOTHSOCKET_ANDROID_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qbluetoothsocketbase_p.h" + +#include +#include +#include "android/inputstreamthread_p.h" +#include + +QT_BEGIN_NAMESPACE + +class QBluetoothSocketPrivateAndroid final : public QBluetoothSocketBasePrivate +{ + Q_OBJECT + friend class QBluetoothServerPrivate; + +public: + QBluetoothSocketPrivateAndroid(); + ~QBluetoothSocketPrivateAndroid(); + + //On Android we connect using the uuid not the port + void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, + QIODevice::OpenMode openMode); + + bool fallBackConnect(QAndroidJniObject uuid, int channel); + bool fallBackReversedConnect(const QBluetoothUuid &uuid); + + bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type); + + QString localName() const; + QBluetoothAddress localAddress() const; + quint16 localPort() const; + + QString peerName() const; + QBluetoothAddress peerAddress() const; + quint16 peerPort() const; + + void abort(); + void close(); + + qint64 writeData(const char *data, qint64 maxSize); + qint64 readData(char *data, qint64 maxSize); + + bool setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType, + QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState, + QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite); + + bool setSocketDescriptor(int socketDescriptor, QBluetoothServiceInfo::Protocol socketType, + QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState, + QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite); + + qint64 bytesAvailable() const; + bool canReadLine() const; + qint64 bytesToWrite() const; + + QAndroidJniObject adapter; + QAndroidJniObject socketObject; + QAndroidJniObject remoteDevice; + QAndroidJniObject inputStream; + QAndroidJniObject outputStream; + InputStreamThread *inputThread; + +public slots: + void socketConnectSuccess(const QAndroidJniObject &socket); + void defaultSocketConnectFailed(const QAndroidJniObject & socket, + const QAndroidJniObject &targetUuid, + const QBluetoothUuid &qtTargetUuid); + void fallbackSocketConnectFailed(const QAndroidJniObject &socket, + const QAndroidJniObject &targetUuid); + void inputThreadError(int errorCode); + +signals: + void connectJavaSocket(); + void closeJavaSocket(); + +}; + +// QTBUG-61392 related +// Private API to disable the silent behavior to reverse a remote service's +// UUID. In rare cases the workaround behavior might not be desirable as +// it may lead to connects to incorrect services. +extern bool useReverseUuidWorkAroundConnect; + +QT_END_NAMESPACE + +#endif // QBLUETOOTHSOCKET_ANDROID_P_H diff --git a/src/bluetooth/qbluetoothsocket_p.h b/src/bluetooth/qbluetoothsocket_p.h index 6c3bedf3..d4839fb0 100644 --- a/src/bluetooth/qbluetoothsocket_p.h +++ b/src/bluetooth/qbluetoothsocket_p.h @@ -55,13 +55,6 @@ #include "qbluetoothsocketbase_p.h" #include -#if defined(QT_ANDROID_BLUETOOTH) -#include -#include -#include "android/inputstreamthread_p.h" -#include -#endif // QT_ANDROID_BLUETOOTH - QT_FORWARD_DECLARE_CLASS(QSocketNotifier) #ifdef QT_WINRT_BLUETOOTH @@ -79,21 +72,9 @@ public: QBluetoothSocketPrivate(); ~QBluetoothSocketPrivate() override; -//On Android we connect using the uuid not the port -#if defined(QT_ANDROID_BLUETOOTH) - void connectToService(const QBluetoothAddress &address, const QBluetoothUuid &uuid, - QIODevice::OpenMode openMode) override; -#else void connectToService(const QBluetoothAddress &address, quint16 port, QIODevice::OpenMode openMode) override; -#endif -#ifdef QT_ANDROID_BLUETOOTH - bool fallBackConnect(QAndroidJniObject uuid, int channel); - bool fallBackReversedConnect(const QBluetoothUuid &uuid); -#endif - - bool ensureNativeSocket(QBluetoothServiceInfo::Protocol type) override; QString localName() const override; @@ -110,11 +91,7 @@ public: qint64 writeData(const char *data, qint64 maxSize) override; qint64 readData(char *data, qint64 maxSize) override; -#ifdef QT_ANDROID_BLUETOOTH - bool setSocketDescriptor(const QAndroidJniObject &socket, QBluetoothServiceInfo::Protocol socketType, - QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState, - QBluetoothSocket::OpenMode openMode = QBluetoothSocket::ReadWrite) override; -#elif defined(QT_WINRT_BLUETOOTH) +#if defined(QT_WINRT_BLUETOOTH) bool setSocketDescriptor(Microsoft::WRL::ComPtr socket, QBluetoothServiceInfo::Protocol socketType, QBluetoothSocket::SocketState socketState = QBluetoothSocket::ConnectedState, @@ -128,28 +105,6 @@ public: bool canReadLine() const override; qint64 bytesToWrite() const override; -#ifdef QT_ANDROID_BLUETOOTH - QAndroidJniObject adapter; - QAndroidJniObject socketObject; - QAndroidJniObject remoteDevice; - QAndroidJniObject inputStream; - QAndroidJniObject outputStream; - InputStreamThread *inputThread; - -public slots: - void socketConnectSuccess(const QAndroidJniObject &socket); - void defaultSocketConnectFailed(const QAndroidJniObject & socket, - const QAndroidJniObject &targetUuid, - const QBluetoothUuid &qtTargetUuid); - void fallbackSocketConnectFailed(const QAndroidJniObject &socket, - const QAndroidJniObject &targetUuid); - void inputThreadError(int errorCode); - -signals: - void connectJavaSocket(); - void closeJavaSocket(); -#endif - #ifdef QT_WINRT_BLUETOOTH SocketWorker *m_worker; @@ -176,16 +131,6 @@ private: #endif }; - -#ifdef Q_OS_ANDROID -// QTBUG-61392 related -// Private API to disable the silent behavior to reverse a remote service's -// UUID. In rare cases the workaround behavior might not be desirable as -// it may lead to connects to incorrect services. -extern bool useReverseUuidWorkAroundConnect; - -#endif - QT_END_NAMESPACE #endif -- cgit v1.2.3