Fix for unstable NFC connection on LineageOS (Android 13+)

In the last few months, I have debugged a quite interesting issue concerning Android smartphones running LineageOS and Android version 13+ : The NFC connection to a smartcard (or Apex chip) would just break even though the chip was still computing stuff.

I will spare you the gnarly details, in short the NFC driver used by LineageOS starting with Android 13 is the open-source one from the AOSP project, called NfcNci. Before, the (semi) closed source one was used (NQNfcNci), made by NXP and Qualcomm. Anyway, the open source driver has a “bug” in that it does not wait long enough for a chip to return a response, instead assuming it has been removed.

This issue is quite an easy fix if you have access to the app source code. Fidesmo, for example, has been already notified and will publish this fix very soon.

For all other apps, I present to you a LSPosed module written by me, which modifies any selected apps at runtime and injects the proper NFC driver configuration. This requires a rooted Android phone and some amount of setup, I am not liable for any damage to your smartphone.

Check it out at GitHub - StarGate01/NFCPresenceFix: LSPosed module to fix the NFC presence timeout of AOSP NfcNci .

Read more at:

11 Likes

After a few very annoying smartphone reinstalls, I have to add this warning:

Do NOT try to inject this module into any app targeted by Shamiko / Magisk denylist or your smartphone WILL BOOTLOOP.

I don’t know wether this is a problem with this module or with Magisk, but I don’t intend to find out. In general, if you mess with Magisk / LSPosed, make sure to have and know a backup and recovery strategy.

2 Likes