If you want to install this mod, on your phone, your phone needs to be rooted, and run Android Nougat (7.0 or 7.1.1).
I’ve only tested this on a Oneplus 3 running Oxygen OS.
This guide assumes you have adb successfully installed, if you don’t have that, please go install adb first.
First connect your phone to your pc, using a usb cable, enable USB-debugging in developer settings.
Now open a terminal, and type the following commands
adb shell su
There might be a popup on your phone screen, asking you if you want to allow root acces to ADB shell, click allow.
Now you have root access in your adb shell. Next step to do, is to remount /system as writable, create a backup, download the modified NfcNci.apk, and install it. Run the following commands to do that,
busybox mount -o remount,rw system cd /system/app/NfcNci/ mv NfcNci.apk NfcNci_bak.apk curl https://lasse-it.dk/files/NfcNci.apk > NfcNci.apk chmod 755 /system/app/NfcNci/NfcNci.apk killall com.android.nfc
Now make sure NFC is turned on, try to read a NFC tag with the screen on, then try with the screen turned off.
If NFC now doesn’t work at all, try rebooting your phone. If that doesn’t fix it, run the following commands, to revert this mod.
adb shell su busybox mount -o remount,rw system cd /system/app/NfcNci/ rm NfcNci.apk mv NfcNci_bak.apk NfcNci.apk
Now NFC should function again, when the phone is unlocked.
14 thoughts on “How to: Android 7.0 read NFC tags when screen is off”
does this also work for android 7.1.1 or is there any minor difference to 7.0?
Raphael
I haven’t tested it on Android 7.1.1, but will probably work fine, otherwise you can just revert the changes, if it doesn’t work π
Lasse Hyldahl Jensen
Is there a way to do this on Windows?
I’ve tried it and everything worked until the “curl” command.
Raphael
You need to have adb installed, and remember to run the commands on the device, not windows. This is done by typing “adb shell” followed by “su” to gain admin access on your android device
Lasse Hyldahl Jensen
Awesome π Thanks For sharing.
BTW, I still use Marshmallow ROM’s mainly because the Xposed Framework is not yet available with Nougat. Is there a chance to have a mod that works with MM? <3 The "NcfScreenOffEnabler" XposedModule work only with KK and LP π
Julien BARET
I’m not sure if it will work on Marshmallow, if it doesn’t work, you can always revert back to the original NfcNci.apk. You can also try modifying the APK yourself, i have a guide on that here: https://lasse-it.dk/2017/01/how-to-modifying-nfcnci-apk-to-run-when-screen-is-turned-off-on-android-nougat/
Lasse Hyldahl Jensen
Thank you. Indeed I looked at your guide (very nice btw), but the NfcService and ScreenStateHelper files are a bit different. I have some knowledge but not enough.
For example, the “checkScreenState ()” method is defined as:
“return !this.mPowerManager.isScreenOn() ? SCREEN_STATE_OFF : this.mKeyguardManager.isKeyguardLocked() ? SCREEN_STATE_ON_LOCKED : SCREEN_STATE_ON_UNLOCKED;”
There is no βconst/4 v0, 0xβ¦β should I just return “SCREEN_STATE_ON_UNLOCKED” ?
If you are interested, see the 2 files (Marshmallow)
https://drive.google.com/open?id=0B0eBDY29hoSRUFBVRTQxWkVFUVU
Sorry to bother you with all these questions, it does not matter if I do not have any answers π
Julien BARET
Nevermind, with smali I got things similar than your guide π Will give a try.
Julien BARET
Super! hit me up if you need more help π
Lasse Hyldahl Jensen
After quite a few hours I finally succeeded. π
I first had problems to decompile and recompile apk.
Indeed the service NFC often stopped, I had compilation errors etc ..
And then my NfcService.smali file is quite different from your, so I modified only one thing: the 4 lines:
Android.intent.action.SCREEN _ *** A
…
And it works for now.
Thanks again, I will not have succeeded without your guide π
Julien BARET
Awesome!
Lasse Hyldahl Jensen
Hi, thanks for your tuto, sadly it doesn’t work for me (S7 edge on Android 7.0 stock).
I think I will downgrade ti marschmallow until xposed available on nougat…
seb
Hey, im using Lineage OS 14.1 and i dont have a NfcNci folder in /system/app theres just a NQNfcNci Folder with an NQNfcNci.apk in it but replacing and renaming this one doesnt work. Any ideas?
Julian Kok
Please help me, I messed up NFC by trying this with Android 8, renamed the NfcNci_bak.apk back to NfcNci.apk, NFC still crashes after reboot. Help is incredibly highly appreciated!
TikeLeSpike