diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-02 10:19:15 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-02 10:19:15 +0200 |
commit | 907c43f83768bf1b7fea89960ff5b60a714007d6 (patch) | |
tree | 1649df9d1cd7281aba9fb4d79060d31cc7be037a /src | |
parent | 79f94af0f2e6a1098918bd89241f72403bd5acc6 (diff) | |
parent | 60d1ebac9e81619a24e66fc6defc3e0299491a9d (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
.qmake.conf
Change-Id: I72d250d21eeed0e7ba30d6c64ef88a797e94a35b
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/android/jni_android.cpp | 5 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdeviceinfo.cpp | 7 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothdeviceinfo.h | 2 | ||||
-rw-r--r-- | src/bluetooth/qbluetoothsocket_bluez.cpp | 50 | ||||
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 7 | ||||
-rw-r--r-- | src/nfc/android/androidjninfc.cpp | 5 | ||||
-rw-r--r-- | src/nfc/qllcpserver_android_p.cpp | 4 | ||||
-rw-r--r-- | src/nfc/qllcpserver_android_p.h | 1 |
8 files changed, 66 insertions, 15 deletions
diff --git a/src/bluetooth/android/jni_android.cpp b/src/bluetooth/android/jni_android.cpp index b48cd21f..95011c6c 100644 --- a/src/bluetooth/android/jni_android.cpp +++ b/src/bluetooth/android/jni_android.cpp @@ -284,6 +284,11 @@ static bool registerNatives(JNIEnv *env) Q_BLUETOOTH_EXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* /*reserved*/) { + static bool initialized = false; + if (initialized) + return JNI_VERSION_1_6; + initialized = true; + typedef union { JNIEnv *nativeEnvironment; void *venv; diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp index 6f1ab4ae..41f77153 100644 --- a/src/bluetooth/qbluetoothdeviceinfo.cpp +++ b/src/bluetooth/qbluetoothdeviceinfo.cpp @@ -504,7 +504,12 @@ QBluetoothDeviceInfo::MajorDeviceClass QBluetoothDeviceInfo::majorDeviceClass() } /*! - Returns the minor device class of the device. + Returns the minor device class of the device. The actual information + is context dependent on the value of \l majorDeviceClass(). + + \sa MinorAudioVideoClass, MinorComputerClass, MinorHealthClass, MinorImagingClass, + MinorMiscellaneousClass, MinorNetworkClass, MinorPeripheralClass, MinorPhoneClass, + MinorToyClass, MinorWearableClass */ quint8 QBluetoothDeviceInfo::minorDeviceClass() const { diff --git a/src/bluetooth/qbluetoothdeviceinfo.h b/src/bluetooth/qbluetoothdeviceinfo.h index 2cf26a21..751c8384 100644 --- a/src/bluetooth/qbluetoothdeviceinfo.h +++ b/src/bluetooth/qbluetoothdeviceinfo.h @@ -58,7 +58,7 @@ public: MiscellaneousDevice = 0, ComputerDevice = 1, PhoneDevice = 2, - LANAccessDevice = 3, + LANAccessDevice = 3, // TODO Qt 6 rename to NetworkDevice -> inconsistency with MinorNetworkClass AudioVideoDevice = 4, PeripheralDevice = 5, ImagingDevice = 6, diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index cfcba8af..803df6df 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -48,6 +48,7 @@ #include "bluez/bluez_data_p.h" #include <qplatformdefs.h> +#include <QtCore/private/qcore_unix_p.h> #include <QtCore/QLoggingCategory> @@ -241,13 +242,28 @@ void QBluetoothSocketPrivate::_q_writeNotify() char buf[1024]; int size = txBuffer.read(buf, 1024); - - if (::write(socket, buf, size) != size) { - errorString = QBluetoothSocket::tr("Network Error"); - q->setSocketError(QBluetoothSocket::NetworkError); - } - else { - emit q->bytesWritten(size); + int writtenBytes = qt_safe_write(socket, buf, size); + if (writtenBytes < 0) { + switch (errno) { + case EAGAIN: + writtenBytes = 0; + txBuffer.ungetBlock(buf, size); + break; + default: + // every other case returns error + errorString = QBluetoothSocket::tr("Network Error: %1"); + errorString.arg(qt_error_string(errno)); + q->setSocketError(QBluetoothSocket::NetworkError); + break; + } + } else { + if (writtenBytes < size) { + // add remainder back to buffer + char* remainder = buf + writtenBytes; + txBuffer.ungetBlock(remainder, size - writtenBytes); + } + if (writtenBytes > 0) + emit q->bytesWritten(writtenBytes); } if (txBuffer.size()) { @@ -484,15 +500,23 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) } if (q->openMode() & QIODevice::Unbuffered) { - if (::write(socket, data, maxSize) != maxSize) { - errorString = QBluetoothSocket::tr("Network Error"); - q->setSocketError(QBluetoothSocket::NetworkError); - return -1; + int sz = ::qt_safe_write(socket, data, maxSize); + if (sz < 0) { + switch (errno) { + case EAGAIN: + sz = 0; + break; + default: + errorString = QBluetoothSocket::tr("Network Error: %1"); + errorString.arg(qt_error_string(errno)); + q->setSocketError(QBluetoothSocket::NetworkError); + } } - emit q->bytesWritten(maxSize); + if (sz > 0) + emit q->bytesWritten(sz); - return maxSize; + return sz; } else { diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index d4fe0232..e85fcb34 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -688,12 +688,19 @@ void QLowEnergyControllerPrivate::sendPacket(const QByteArray &packet) { qint64 result = l2cpSocket->write(packet.constData(), packet.size()); + // We ignore result == 0 which is likely to be caused by EAGAIN. + // This packet is effectively discarded but the controller can still recover + if (result == -1) { qCDebug(QT_BT_BLUEZ) << "Cannot write L2CP packet:" << hex << packet.toHex() << l2cpSocket->errorString(); setError(QLowEnergyController::NetworkError); + } else if (result < packet.size()) { + qCWarning(QT_BT_BLUEZ) << "L2CP write request incomplete:" + << result << "of" << packet.size(); } + } void QLowEnergyControllerPrivate::sendNextPendingRequest() diff --git a/src/nfc/android/androidjninfc.cpp b/src/nfc/android/androidjninfc.cpp index 671811c3..4adb6f21 100644 --- a/src/nfc/android/androidjninfc.cpp +++ b/src/nfc/android/androidjninfc.cpp @@ -96,6 +96,11 @@ QT_END_ANDROIDNFC_NAMESPACE Q_DECL_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void * /*reserved*/) { + static bool initialized = false; + if (initialized) + return JNI_VERSION_1_6; + initialized = true; + JNIEnv* env; if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) { return -1; diff --git a/src/nfc/qllcpserver_android_p.cpp b/src/nfc/qllcpserver_android_p.cpp index 8055782b..eb0306a0 100644 --- a/src/nfc/qllcpserver_android_p.cpp +++ b/src/nfc/qllcpserver_android_p.cpp @@ -47,6 +47,10 @@ QLlcpServerPrivate::QLlcpServerPrivate(QLlcpServer *q) { } +QLlcpServerPrivate::~QLlcpServerPrivate() +{ +} + bool QLlcpServerPrivate::listen(const QString &/*serviceUri*/) { /*//The server is already listening diff --git a/src/nfc/qllcpserver_android_p.h b/src/nfc/qllcpserver_android_p.h index 32e6259c..5d5e2aea 100644 --- a/src/nfc/qllcpserver_android_p.h +++ b/src/nfc/qllcpserver_android_p.h @@ -61,6 +61,7 @@ class QLlcpServerPrivate : public QObject Q_OBJECT public: QLlcpServerPrivate(QLlcpServer *q); + ~QLlcpServerPrivate(); bool listen(const QString &serviceUri); bool isListening() const; |