summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_android.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-07-01 09:42:13 +0200
committerAlex Blasche <alexander.blasche@digia.com>2014-07-10 14:44:16 +0200
commitfd85f6fc28061fd162cdc41dbe5c9c70e066c34b (patch)
treecca536bc69fef1c7b1e1d6cdefc4d56d707dc612 /src/bluetooth/qbluetoothsocket_android.cpp
parentb2cebb6530fecedfa1facd8e7ff7020a4147b803 (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>
Diffstat (limited to 'src/bluetooth/qbluetoothsocket_android.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp17
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();