Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-46377

Android <=4.1 Devices not connecting via Bluetooth at all

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0 RC
    • 5.3.2, 5.4.1
    • None

    Description

      Hey,

      We were testing our application, and we had connecting issues with Android API <17 devices. So we wrote a second patch for it and it is working now.

      The originial ticket is here: https://bugreports.qt.io/browse/QTBUG-40172


      Edit:

      In the past, there was an issue about Android device connection via bluetooth. We did write a fallback method. All written in here: https://bugreports.qt.io/browse/QTBUG-40172

      And then, we encounter another problem but only android 4.1 and below devices was not connecting. So we try another approach for it and tried unsecure connection methods. And then it worked. With this following code, all android devices can connect to our bluetooth broadcaster.

      Following code overwrites some part of code of this patch:

      https://codereview.qt-project.org/#/c/90473/

      in src/bluetooth/qbluetoothsocket_android.cpp:151

          QAndroidJniObject method;
      
          // android <= 4.1 devices connects only if we are using insecure socket.
          if (QtAndroid::androidSdkVersion() < 17) {
              qCWarning(QT_BT_ANDROID) << "Connecting via insecure connection.";
              method = remoteDeviceClass.callObjectMethod(
                      "getMethod",
                      "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;",
                      QAndroidJniObject::fromString(QLatin1String("createInsecureRfcommSocket")).object<jstring>(),
                      paramTypes.object<jobjectArray>());
          } else {
              qCWarning(QT_BT_ANDROID) << "Connecting via secure connection.";
              method = remoteDeviceClass.callObjectMethod(
                      "getMethod",
                      "(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;",
                      QAndroidJniObject::fromString(QLatin1String("createRfcommSocket")).object<jstring>(),
                      paramTypes.object<jobjectArray>());
          }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-46377
          # Subject Branch Project Status CR V

          Activity

            People

              ablasche Alex Blasche
              firatagdas Firat Agdas
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews