This guide is for advanced users, please only proceed if you have experience with decompiling apps, and modifying android apps.
You need a rooted android 7.0 phone to apply this mod.
First please install all these programs:
- smali & baksmali
- Java Development Kit
When you have all those programs, start by extracting the system files, that have to be modified, by running the following commands in an empty directory:
adb pull /system/framework/arm/ adb pull /system/app/NfcNci/NfcNci.apk adb pull /system/app/NfcNci/oat/arm64/NfcNci.odex
Now we have all the files needed to modify NfcNci.apk.
To apply the mod, we need to decompile NfcNci.odex, using the following command:
baksmali x -c arm/boot.oat -d arm/ NfcNci.odex -o NfcNci/
Now go to NfcNci/com/android/nfc/ and open NfcService.smali in a text editor, then replace the following strings:
- android.intent.action.SCREEN_OFF with android.intent.action.SCREEN_OFFA
- android.intent.action.SCREEN_ON with android.intent.action.SCREEN_ONA
- android.intent.action.USER_PRESENT with android.intent.action.USER_PRESENTA
- android.intent.action.USER_SWITCHED with android.intent.action.USER_SWITCHEDA
Then find the first appearance of “if-lt”, and replace the 1st and 2nd parameters like this “if-lt p1, v5, :cond_99″ needs to be “if-lt v5, p1, :cond_99″.
You will probably not encounter the same parameters as me.
Now save and close NfcService.smali
Next up, open ScreenStateHelper.smali in a text editor. In this file, you have to find “.method checkScreenState()” and replace all instances of “const/4 v0, 0x…” with “const/4 v0, 0x3”, this will make the method always say the screen is turned on.
Now save and close ScreenStateHelper.smali and go back to the directory where NfcNci.apk is located.
Now you have to compile the directory NfcNci/ by running this command:
smali a -o classes.dex NfcNci/
Now insert classes.dex into NfcNci.apk using an archive manager.
Then create a zipaligned version of NfcNci.apk using this command:
zipalign -v 4 NfcNci.apk NfcNci_align.apk
Now you just need to copy NfcNci_align.apk to your phone using the following commands:
adb push NfcNci_align.apk /sdcard/NfcNci.apk adb shell su busybox mount -o remount,rw system mv /system/app/NfcNci/NfcNci.apk /system/app/NfcNci/NfcNci_bak.apk cp /sdcard/NfcNci.apk /system/app/NfcNci/NfcNci.apk chmod 755 /system/app/NfcNci/NfcNci.apk killall com.android.nfc
There might appear a pop up on your phone you have to allow it.
Now NFC should work, when your screen is turned off.