Skip to content

Commit bb6fb63

Browse files
committed
add extra_reader_presence_check_delay to poll function in dart
1 parent 4955d1b commit bb6fb63

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

android/src/main/kotlin/im/nfc/flutter_nfc_kit/FlutterNfcKitPlugin.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,10 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
330330
val timeout = call.argument<Int>("timeout")!!
331331
// technology and option bits are set in Dart code
332332
val technologies = call.argument<Int>("technologies")!!
333+
val extraPresenceDelay = call.argument<Int>("extra_reader_presence_check_delay")
334+
333335
runOnNfcThread(result, "Poll") {
334-
pollTag(nfcAdapter, result, timeout, technologies)
336+
pollTag(nfcAdapter, result, timeout, technologies, extraPresenceDelay)
335337
}
336338
}
337339

@@ -584,8 +586,7 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
584586

585587
override fun onDetachedFromActivityForConfigChanges() {}
586588

587-
private fun pollTag(nfcAdapter: NfcAdapter, result: Result, timeout: Int, technologies: Int) {
588-
589+
private fun pollTag(nfcAdapter: NfcAdapter, result: Result, timeout: Int, technologies: Int, extraReaderPresenceCheckDelay: Int?) {
589590
pollingTimeoutTask = Timer().schedule(timeout.toLong()) {
590591
try {
591592
if (activity.get() != null) {
@@ -605,11 +606,10 @@ class FlutterNfcKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
605606
result.success(jsonResult)
606607
}
607608

608-
// The EXTRA_READER_PRESENCE_CHECK_DELAY is for fixing an obscure bug with
609-
// some Android versions like LineageOS 17.1 that caused the PACE authentication to fail.
610-
// See https://github.com/privacybydesign/vcmrtd/issues/91 for more info.
611609
val options = Bundle()
612-
options.putInt(EXTRA_READER_PRESENCE_CHECK_DELAY, 2000)
610+
if (extraReaderPresenceCheckDelay != null) {
611+
options.putInt(EXTRA_READER_PRESENCE_CHECK_DELAY, extraReaderPresenceCheckDelay)
612+
}
613613
nfcAdapter.enableReaderMode(activity.get(), pollHandler, technologies, options)
614614
}
615615

lib/flutter_nfc_kit.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ class FlutterNfcKit {
337337
bool readIso18092 = false,
338338
bool readIso15693 = true,
339339
bool probeWebUSBMagic = false,
340+
Duration? extraReaderPresenceCheckDelay,
340341
}) async {
341342
// use a bitmask for compact representation
342343
int technologies = 0x0;
@@ -354,6 +355,9 @@ class FlutterNfcKit {
354355
'iosMultipleTagMessage': iosMultipleTagMessage,
355356
'technologies': technologies,
356357
'probeWebUSBMagic': probeWebUSBMagic,
358+
if (extraReaderPresenceCheckDelay != null)
359+
"extra_reader_presence_check_delay":
360+
extraReaderPresenceCheckDelay.inMilliseconds,
357361
});
358362
return NFCTag.fromJson(jsonDecode(data));
359363
}

0 commit comments

Comments
 (0)