diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2014-07-01 09:42:13 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@digia.com> | 2014-07-10 14:44:16 +0200 |
commit | fd85f6fc28061fd162cdc41dbe5c9c70e066c34b (patch) | |
tree | cca536bc69fef1c7b1e1d6cdefc4d56d707dc612 | |
parent | b2cebb6530fecedfa1facd8e7ff7020a4147b803 (diff) |
Remove usage of BluetoothSocket.isConnected()
It seems not all devices reliably return the correct value when calling
isConnected(). connect() succeeds but isConnected() is still false.
On the positive side it is not really needed either.
Calling connect() returns an exception if it fails and close() can be
safely called multiple times. Therefore we only have to check for ocurring
exceptions.
Furthermore isConnected() is API lvl 14 and was not guarded. Removing
the call resolves this problem too.
Task-number: QTBUG-39815
Change-Id: Idf8472c268231a2cfac0f5cd87294384ff779c3f
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
-rw-r--r-- | src/bluetooth/qbluetoothsocket_android.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp index f2969da8..d499b6ad 100644 --- a/src/bluetooth/qbluetoothsocket_android.cpp +++ b/src/bluetooth/qbluetoothsocket_android.cpp @@ -98,6 +98,8 @@ void QBluetoothSocketPrivate::connectToServiceConc(const QBluetoothAddress &addr Q_Q(QBluetoothSocket); Q_UNUSED(openMode); + qCDebug(QT_BT_ANDROID) << "connectToServiceConc()" << address.toString() << uuid.toString(); + if (!adapter.isValid()) { qCWarning(QT_BT_ANDROID) << "Device does not support Bluetooth"; errorString = QBluetoothSocket::tr("Device does not support Bluetooth"); @@ -157,7 +159,7 @@ void QBluetoothSocketPrivate::connectToServiceConc(const QBluetoothAddress &addr } socketObject.callMethod<void>("connect"); - if (env->ExceptionCheck() || socketObject.callMethod<jboolean>("isConnected") == JNI_FALSE) { + if (env->ExceptionCheck()) { if (env->ExceptionCheck()) { env->ExceptionDescribe(); env->ExceptionClear(); @@ -383,14 +385,11 @@ void QBluetoothSocketPrivate::inputThreadError(int errorCode) //cleanup internal objects //if it was call to local close()/abort() the objects are cleaned up already - bool stillConnected = socketObject.callMethod<jboolean>("isConnected"); - if (stillConnected) { - QAndroidJniEnvironment env; - socketObject.callMethod<void>("close"); - if (env->ExceptionCheck()) { - env->ExceptionDescribe(); - env->ExceptionClear(); - } + QAndroidJniEnvironment env; + socketObject.callMethod<void>("close"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); } inputStream = outputStream = remoteDevice = socketObject = QAndroidJniObject(); |