From 263fc5186325a7dd59a7533b98b3bf1296ea0d16 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Tue, 16 Jul 2019 11:17:28 +0200 Subject: Do not handle PAIRING_VARIANT_PIN The user has to enter a pin in such cases. Since QBluetoothLocalDevice does not have an API to return a pin it makes no sense for QtBluetooth to handle this type of request. Android will provide its own fall back form. This patch is mostly a revert of f8c0572ddcd. Fixes: QTBUG-76565 Task-number: QTBUG-70295 Change-Id: I61062ac84ce508f3b82c7359a60d5c9c5bba86a4 Reviewed-by: Timur Pocheptsov Reviewed-by: Oliver Wolff --- src/bluetooth/android/localdevicebroadcastreceiver.cpp | 12 +++++++++++- src/bluetooth/qbluetoothlocaldevice_android.cpp | 11 ----------- src/bluetooth/qbluetoothlocaldevice_p.h | 1 - 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/bluetooth/android/localdevicebroadcastreceiver.cpp b/src/bluetooth/android/localdevicebroadcastreceiver.cpp index e3b01987..78aecc12 100644 --- a/src/bluetooth/android/localdevicebroadcastreceiver.cpp +++ b/src/bluetooth/android/localdevicebroadcastreceiver.cpp @@ -189,6 +189,14 @@ void LocalDeviceBroadcastReceiver::onReceive(JNIEnv *env, jobject context, jobje return; case 0: //BluetoothDevice.PAIRING_VARIANT_PIN { + qCDebug(QT_BT_ANDROID) << "Pairing : PAIRING_VARIANT_PIN -> use Android default handling"; + + // The section below is disabled because this Android pairing variant + // requires the user to enter a pin. Since QBluetoothLocalDevice does + // not have a setPin() equivalent which might be used to return the user's value. + // For now we ignore this request. If an app ignores such requests, + // Android shows a "fall-back" pin code entry form. + /* //generate a random key const QString pin = QStringLiteral("%1").arg(QRandomGenerator::global()->bounded(1000000), 6, 10, QLatin1Char('0')); @@ -225,10 +233,12 @@ void LocalDeviceBroadcastReceiver::onReceive(JNIEnv *env, jobject context, jobje } const QBluetoothAddress address(bluetoothDevice.callObjectMethod("getAddress").toString()); - emit pairingDisplayPinCode(address, pin); + emit pairingDisplayPinCode(address, pin);*/ + break; } case 2: //BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION { + qCDebug(QT_BT_ANDROID) << "Pairing : PAIRING_VARIANT_PASSKEY_CONFIRMATION"; keyExtra = valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ExtraPairingKey); key = intentObject.callMethod("getIntExtra", diff --git a/src/bluetooth/qbluetoothlocaldevice_android.cpp b/src/bluetooth/qbluetoothlocaldevice_android.cpp index 40e4c2d4..2995d368 100644 --- a/src/bluetooth/qbluetoothlocaldevice_android.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_android.cpp @@ -69,8 +69,6 @@ QBluetoothLocalDevicePrivate::QBluetoothLocalDevicePrivate( this, &QBluetoothLocalDevicePrivate::processConnectDeviceChanges); connect(receiver, &LocalDeviceBroadcastReceiver::pairingDisplayConfirmation, this, &QBluetoothLocalDevicePrivate::processDisplayConfirmation); - connect(receiver, &LocalDeviceBroadcastReceiver::pairingDisplayPinCode, - this, &QBluetoothLocalDevicePrivate::processDisplayPinCode); } QBluetoothLocalDevicePrivate::~QBluetoothLocalDevicePrivate() @@ -206,15 +204,6 @@ void QBluetoothLocalDevicePrivate::processDisplayConfirmation(const QBluetoothAd return; emit q_ptr->pairingDisplayConfirmation(address, pin); -} - -void QBluetoothLocalDevicePrivate::processDisplayPinCode(const QBluetoothAddress &address, const QString &pin) -{ - // only send pairing notification for pairing requests issued by - // this QBluetoothLocalDevice instance - if (pendingPairing(address) == -1) - return; - emit q_ptr->pairingDisplayPinCode(address, pin); } diff --git a/src/bluetooth/qbluetoothlocaldevice_p.h b/src/bluetooth/qbluetoothlocaldevice_p.h index 98c62151..1f99f27e 100644 --- a/src/bluetooth/qbluetoothlocaldevice_p.h +++ b/src/bluetooth/qbluetoothlocaldevice_p.h @@ -113,7 +113,6 @@ private slots: QBluetoothLocalDevice::Pairing pairing); void processConnectDeviceChanges(const QBluetoothAddress &address, bool isConnectEvent); void processDisplayConfirmation(const QBluetoothAddress &address, const QString &pin); - void processDisplayPinCode(const QBluetoothAddress &address, const QString &pin); private: QBluetoothLocalDevice *q_ptr; -- cgit v1.2.3