summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-06-24 17:01:53 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-28 15:55:42 +0000
commitcd6d31a4630f71f16f3ada1cbd9f577621223cbf (patch)
treeaee8bdfacefe5ae600cf7f2b6e041dcd7b7fa3e0
parentc4b79b088db49ee16a9e40b42263bdf019009abf (diff)
NFC Android: fix checkIsTargetLost() logic
This commit fixes two issues: * adds the missing assignment to a 'connected' variable, which was lost during refactoring; * modifies the logic so that setTagTechnology() call does not check all the available technologies, but only the selected one. Previous behavior could result in switching the tag technology while still connected to a tag. This, in turn, was leading to isConnected() returning false (because we were connected to *other* technology). As a result, the logic of checkIsTargetLost() was broken and detected that the target was lost while it still was in range. Fixes: QTBUG-55734 Change-Id: I4f7ea776beb97e07ebe21c8fd63946d898105eb7 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> (cherry picked from commit 74c6e404f2d41b9ab317b64e4dfe53b8f2ea3f17) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/nfc/qnearfieldtarget_android.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/nfc/qnearfieldtarget_android.cpp b/src/nfc/qnearfieldtarget_android.cpp
index 2b7e1b12..35443d04 100644
--- a/src/nfc/qnearfieldtarget_android.cpp
+++ b/src/nfc/qnearfieldtarget_android.cpp
@@ -318,7 +318,7 @@ void QNearFieldTargetPrivateImpl::setIntent(QJniObject intent)
void QNearFieldTargetPrivateImpl::checkIsTargetLost()
{
- if (!targetIntent.isValid() || !setTagTechnology(techList)) {
+ if (!targetIntent.isValid() || !setTagTechnology({selectedTech})) {
handleTargetLost();
return;
}
@@ -327,7 +327,7 @@ void QNearFieldTargetPrivateImpl::checkIsTargetLost()
bool connected = false;
auto methodId = env.findMethod(tagTech.objectClass(), "isConnected", "()Z");
if (methodId)
- env->CallBooleanMethod(tagTech.object(), methodId);
+ connected = env->CallBooleanMethod(tagTech.object(), methodId);
if (!methodId || env.checkAndClearExceptions()) {
handleTargetLost();
return;