I found that when I stack two NFC ISO15693 tags on top of each other and then try to scan the tags, then the Android NFC stack completely crashes. And wont work until NFC is restarted. Sadly no exception is thrown by the application.
The only related log I could find was the following (Logcat):
2020-03-09 14:36:25.196 3401-10183/? E/BrcmNfcJni: NfcTag::selectFirstTag:starting timer
2020-03-09 14:36:25.209 3401-3657/? E/BrcmNfcJni: nfaDeviceManagementCallback: chr_sub_error_no:7
2020-03-09 14:36:25.223 3401-10183/? E/BrcmNfcJni: nativeNfcTag_handleNonNciMultiCardDetection: check_tag_ntf = 0, check_cmd_sent = 1
and
2020-03-09 14:59:10.937 5551-16123/? E/libnfc_nci: [ERROR:nfa_dm_act.cc(888)] invalid protocol, mode or state
After that NFC wont react at all, in any application on the phone until NFC is restarted. I also tested ISO 14443-4, since I had them lying around, and they do not have the same problem.
I will not include application code, because it doesn't have to do anything with application code. The crash happens even on the main screen of the phone, thus has to be an underlying NFC stack error which I have no control over.
Seems like a collision error.
I have tested this on a Honor 9, and on a Samsung A51; both times the NFC stack crashes.
Any suggestions? I am really lost.
Edit: Here is a more complete, log. I hope It is all the necessary information.
On scan log:
2020-03-10 07:59:24.822 5551-26548/? E/libnfc_nci: [ERROR:nfa_dm_act.cc(888)] invalid protocol, mode or state
After turning off NFC:
2020-03-10 07:59:36.867 32008-32008/? E/NFC: isNFCStateChangeAllowed - Begin
2020-03-10 07:59:36.893 5551-26548/? E/libnfc_nci: [ERROR:NativeNfcManager.cpp(890)] nfaConnectionCallback: NFA_SELECT_RESULT_EVT error: status = 3
2020-03-10 07:59:36.893 5551-26557/? E/libnfc_nci: [ERROR:NativeLlcpServiceSocket.cpp(65)] nativeLlcpServiceSocket_doAccept: fail accept
2020-03-10 07:59:36.894 5551-26548/? E/libnfc_nci: [ERROR:nfa_dm_act.cc(888)] invalid protocol, mode or state
2020-03-10 07:59:36.895 5551-26557/? E/SnepServer: IO error
java.io.IOException
at com.android.nfc.dhimpl.NativeLlcpServiceSocket.accept(NativeLlcpServiceSocket.java:42)
at com.android.nfc.snep.SnepServer$ServerThread.run(SnepServer.java:215)
2020-03-10 07:59:36.918 5551-26558/? E/libnfc_nci: [ERROR:NativeLlcpServiceSocket.cpp(65)] nativeLlcpServiceSocket_doAccept: fail accept
2020-03-10 07:59:36.935 5551-26559/? E/libnfc_nci: [ERROR:NativeLlcpServiceSocket.cpp(65)] nativeLlcpServiceSocket_doAccept: fail accept
2020-03-10 07:59:36.938 5551-5689/? E/NfcLogManager: insertLogInternal::feature=NF03
2020-03-10 07:59:37.090 5551-26548/? E/libnfc_nci: [ERROR:gki_ulinux.cc(693)] GKI TASK_DEAD received. exit thread 3...
2020-03-10 07:59:37.090 5551-26548/? E/libnfc_nci: [ERROR:gki_ulinux.cc(117)] gki_task task_id=3 terminating
2020-03-10 07:59:37.188 5551-26546/? E/libnfc_nci: [ERROR:gki_ulinux.cc(117)] gki_task task_id=4 terminating
2020-03-10 07:59:37.190 5551-5689/? E/NfcLogManager: insertLogInternal::feature=NF01
2020-03-10 07:59:37.192 5551-5689/? E/NfcLogManager: makeAndSendLog - start
2020-03-10 07:59:37.193 5551-5689/? E/NfcLogManager: insertLog::feature=USEF