summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-12-07 16:05:31 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-12-08 05:12:54 +0000
commit5c25bb79da0d37c0cf67ba7feb88b04ce1fd7377 (patch)
tree7056d96be86be026081165adeff05bdcf4b28509
parentb6bd4008c01faa4af6620a1a652a6f88ef3c3a8a (diff)
Don't use "socketChannel" if the "getServiceChannel" call failed
getServiceChannel() does not exist on more recent Android platforms. The JNI call returns an exception and socketChannel is either 0 on debug or undefined in release builds. The previous code did not reliably recognize the case "0" (debug) or "random int" (release) as an error state and hence channel variable was overridden with wrong value. Change-Id: Ia81219376661be3fbbe0c9122f707bb82defa946 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp
index ab8cd876..56d4f77b 100644
--- a/src/bluetooth/qbluetoothsocket_android.cpp
+++ b/src/bluetooth/qbluetoothsocket_android.cpp
@@ -252,15 +252,15 @@ bool QBluetoothSocketPrivate::fallBackConnect(QAndroidJniObject uuid, int channe
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
- }
-
- if (socketChannel
- == remoteDevice.getStaticField<jint>("android/bluetooth/BluetoothDevice", "ERROR")
- || socketChannel == -1) {
- qCWarning(QT_BT_ANDROID) << "Cannot determine RFCOMM service channel.";
} else {
- qCWarning(QT_BT_ANDROID) << "Using found rfcomm channel" << socketChannel;
- channel = socketChannel;
+ if (socketChannel
+ == remoteDevice.getStaticField<jint>("android/bluetooth/BluetoothDevice", "ERROR")
+ || socketChannel == -1) {
+ qCWarning(QT_BT_ANDROID) << "Cannot determine RFCOMM service channel.";
+ } else {
+ qCWarning(QT_BT_ANDROID) << "Using found rfcomm channel" << socketChannel;
+ channel = socketChannel;
+ }
}
}