summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Trillmann <jens.trillmann@governikus.de>2021-08-17 09:25:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-24 11:35:25 +0000
commita1c57c1cf8c4f9aed3d1346262c1f8e044faa2a4 (patch)
treee0ffb2d20487708a48a2db79f7f411a7ef5f0c87
parent27029057b039e4efbfd67deb883d50e3b1ce69b1 (diff)
Android: Call handleTargetLost directly on NFC TagLostException
If in a transceive() a TagLostException occurs, subsequent calls to transceive() may lead to an app crash with "JNI DETECTED ERROR IN APPLICATION: GetMethodID received NULL jclass" on Android 11 if the timer did not clean up first. This fix calls handleTargetLost directly. This could lead to a race condition in which the targetLost signal is send twice, which should be handled correctly by the Qt code. Change-Id: I886e0bd436272ee393a92b0193fd4d40ed4e965e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Lars Schmertmann <lars.schmertmann@governikus.de> (cherry picked from commit 8362edb220cb77e7bcaf766dc8a9545d1c9246e5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/nfc/qnearfieldtarget_android.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nfc/qnearfieldtarget_android.cpp b/src/nfc/qnearfieldtarget_android.cpp
index 35443d04..4a7a0612 100644
--- a/src/nfc/qnearfieldtarget_android.cpp
+++ b/src/nfc/qnearfieldtarget_android.cpp
@@ -229,9 +229,9 @@ QNearFieldTarget::RequestId QNearFieldTargetPrivateImpl::sendCommand(const QByte
if (!myNewVal.isValid()) {
// Some devices (Samsung, Huawei) throw an exception when the card is lost:
// "android.nfc.TagLostException: Tag was lost". But there seems to be a bug that
- // isConnected still reports true. So we need to invalidate the target to allow
- // checkIsTargetLost to recognize this missing card.
- targetIntent = QJniObject();
+ // isConnected still reports true. So we need to invalidate the target as soon as
+ // possible and treat the card as lost.
+ handleTargetLost();
reportError(QNearFieldTarget::CommandError, requestId);
return requestId;