[Module] NFC Screen Off

Search This thread

lapwat

Senior Member
Mar 4, 2015
82
27
Quelquepart
OnePlus 2
Redmi K20 Pro
NFC Screen Off

Read NFC tags when screen is off.
Disable NFC tagging sound.
[WIP] Tap to pay when screen is off.

ALWAYS include Magisk installation logs when posting an issue.

Useful integrations: NFC Card Emulator Pro - Tasker

How does it work?

The NFC app is patched during installation into a `modded` version. This `modded` version is injected at boot time by service.sh so that the phone thinks the screen is always on and unlocked.

This patch only applies to NFC Service so it does not impact any other functionality of the phone that involves screen state detection.

The `modded` app was generated using this method.

Help section

MY NFC IS NOT DETECTED ANYMORE

If you did not unlock your device since last boot, unlock it and wait 30 seconds for the module to be loaded.

After that time, if NFC does not start automatically or manually, it means that the patch does not work for your device. You can uninstall the module and create an issue.

I AM STUCK IN A BOOTLOOP

Remove the module manually.

1. Boot into TWRP
1. Advanced -> File Manager
1. Delete /adb/modules/NFCScreenOff
1. Reboot

THE MODULE IS NOT WORKING SINCE LAST UPDATE

Perform a clean reinstallation.

1. Uninstall the module
1. Reboot
1. Install the module
1. Reboot

If it does not solve your problem, you can create an issue.

I LIKE THE MODULE



TAP TO PAY DOES NOT WORK WHEN SCREEN IS OFF

This is a Work In Progress...
 

Attachments

  • NFCScreenOff-v0.3.0.zip
    326.1 KB · Views: 376
Last edited:

maujogue

Senior Member
Feb 22, 2018
143
28
NFCScreenOff

Enable NFC pooling while phone is locked and screen is off for Android 9 and above.

Make it work for host card emulator to pay in stores
Ask me
It broke my nfc payments. Any fixes ?
Should it work normally with Google pay ?
 
Last edited:

crime_of_heart

Senior Member
Jun 20, 2009
406
888
OnePlus 5
Thanks for enabling this option.

It may not necessarily be a bad thing that it breaks safety net.

Enabling mobile payments while phone is locked is NOT a good idea. Your phone will be vulnerable to money theft with some special NFC devices. They can get close to your phone while it is in your pocket or purse and that is enough for them to steal your money.
 

maujogue

Senior Member
Feb 22, 2018
143
28
Thanks for enabling this option.

It may not necessarily be a bad thing that it breaks safety net.

Enabling mobile payments while phone is locked is NOT a good idea. Your phone will be vulnerable to money theft with some special NFC devices. They can get close to your phone while it is in your pocket or purse and that is enough for them to steal your money.
Yes, that's a bad idea. I just want it to not brake payments, as I couldnt use Google pay even if I unlocked with this module
 

lapwat

Senior Member
Mar 4, 2015
82
27
Quelquepart
OnePlus 2
Redmi K20 Pro
It broke my nfc payments. Any fixes ?
Should it work normally with Google pay ?

Yes it should continue to work normally with Google Pay.

What I meant in the description of the module is:
For now, it only works for reading NFC tags. For payments in stores, the phone still needs to be at least on. If the module is working for tags but breaks your payments, leave a comment.

Is it the case for you? The module works for NFC tags but the payments are broken?

What are your specs (device, rom, android version)?
 
Last edited:

rodken

Senior Member
Jan 11, 2010
391
80
Yes it should continue to work normally with Google Pay.

What I meant in the description of the module is:
For now, it only works for reading NFC tags. For payments in stores, the phone still needs to be at least on. If the module is working for tags but breaks your payments, leave a comment.

Is it the case for you? The module works for NFC tags but the payments are broken?

What are your specs (device, rom, android version)?

Now I get it regarding Google Pay.
 

maujogue

Senior Member
Feb 22, 2018
143
28
Yes it should continue to work normally with Google Pay.

What I meant in the description of the module is:
For now, it only works for reading NFC tags. For payments in stores, the phone still needs to be at least on. If the module is working for tags but breaks your payments, leave a comment.

Is it the case for you? The module works for NFC tags but the payments are broken?

What are your specs (device, rom, android version)?
Exactly. I tried paying but nothing happens, like if nfc didn't exists on my phone. I desinstalled the module and I could pay again. Paying is more important than reading nfc tags for me !
 

lapwat

Senior Member
Mar 4, 2015
82
27
Quelquepart
OnePlus 2
Redmi K20 Pro
@lapwat Hi, awesome module. It is not working for me since the path (and app name) for nfc app is system/app/NxpNfcNci/NxpNfcNci.apk

Android 10.3.0
Oneplus 6
Stock ROM

Edit:attach log

Thanks for the logs. Can you send those files to me:
  • /system/app/NxpNfcNci/NxpNfcNci.apk
  • /system/framework/framework-res.apk

I will do a version for people with NxpNfcNci app (I guess it is OnePlus customized NfcService).
My stock Xiaomi ROM had a NQNfcNci app.
 
Oct 12, 2018
32
9
  • Like
Reactions: R0ttenB4ndit

2me3

Member
Mar 4, 2015
44
5
Is it possible to modify the installation script to account for ncinfc with other names? For instance on the Razer phone 2 it is named NQNFCnci so the script can't find it
 

lapwat

Senior Member
Mar 4, 2015
82
27
Quelquepart
OnePlus 2
Redmi K20 Pro
Not the same guy, but also using Oneplus. It installed successfully but doesn't seem to be working.

Is it possible to modify the installation script to account for ncinfc with other names? For instance on the Razer phone 2 it is named NQNFCnci so the script can't find it

From what I understand from feedbacks, the apk app can have several names:
  • NfcNci
  • NQNfcNci
  • NpxNfcNci

Those names do not depend of the device but depend of the ROM.

Two apk with the same name will in fact be different. They are very related to the framework of the ROM.

Loading an APK from another ROM even if it is the same Android version will have little chance to work.

I cannot detect all the specs of the device. Magisk only gives me the Android SDK Version that's all.
I could make an apk for every ROM.

2 possibilities:
- Zip framework.apk + (NQ/Npx)NfcNci.apk, send it to a server. The server will return a custom apk just for your ROM. This is the one that Magisk will use.
- Build the custom APK directly on the phone, but I cannot find how to run apktools, jarsigner, etc on Android (because there is no JAVA env on Android)
 
  • Like
Reactions: 2me3

lkp171

Senior Member
Aug 6, 2018
97
42
Hi, on my first try a few days ago it didn't install i think it was because the path too, but now it works perfect. Thanks dev:good:

oneplus 6
Android 10 OB 33
xXx magisk on stock rom
Blu spark kernel


Sent from my OnePlus6 using XDA Labs
 
  • Like
Reactions: lapwat

2me3

Member
Mar 4, 2015
44
5
From what I understand from feedbacks, the apk app can have several names:
  • NfcNci
  • NQNfcNci
  • NpxNfcNci

Those names do not depend of the device but depend of the ROM.

Two apk with the same name will in fact be different. They are very related to the framework of the ROM.

Loading an APK from another ROM even if it is the same Android version will have little chance to work.

I cannot detect all the specs of the device. Magisk only gives me the Android SDK Version that's all.
I could make an apk for every ROM.

2 possibilities:
- Zip framework.apk + (NQ/Npx)NfcNci.apk, send it to a server. The server will return a custom apk just for your ROM. This is the one that Magisk will use.
- Build the custom APK directly on the phone, but I cannot find how to run apktools, jarsigner, etc on Android (because there is no JAVA env on Android)

Yes I extracted the zip and modified the customize/service.sh scripts to properly work with my rom and as you stated it did not work. as soon as the script killed the nfc service it triggered a reboot to recovery.

I PM'd you a gdrive link to the stock apk's from the razer phone 2 Pi stock rom. If you have some time would please build it for me? I tried to do it myself a while ago but ran out of steam before i even got all the dependencies running on my computer lol. I can modify your magisk package to work with it myself.

I like your idea of a server that automatically runs the process to patch the apk. Would every use need to upload both the framework.apk and nfcnci or just the nfc? The only concern I would have is bandwithd as the framework apk is 30+ MB's. If you could build the server into a docker container I think it would be easy enough for others to host you could probably find some people willing to host it for free. Another option could be using a google drive account to allow people to upload the apk's for their phone then batch process them all and sort them by model/build # or something to cover most phones/roms . I have a gapps for business account with unlimited storage I could probably lend for this purpose

Once again thanks for all your work! If you have a bitcoin address i'd like to buy you a beer
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 7
    NFC Screen Off

    Read NFC tags when screen is off.
    Disable NFC tagging sound.
    [WIP] Tap to pay when screen is off.

    ALWAYS include Magisk installation logs when posting an issue.

    Useful integrations: NFC Card Emulator Pro - Tasker

    How does it work?

    The NFC app is patched during installation into a `modded` version. This `modded` version is injected at boot time by service.sh so that the phone thinks the screen is always on and unlocked.

    This patch only applies to NFC Service so it does not impact any other functionality of the phone that involves screen state detection.

    The `modded` app was generated using this method.

    Help section

    MY NFC IS NOT DETECTED ANYMORE

    If you did not unlock your device since last boot, unlock it and wait 30 seconds for the module to be loaded.

    After that time, if NFC does not start automatically or manually, it means that the patch does not work for your device. You can uninstall the module and create an issue.

    I AM STUCK IN A BOOTLOOP

    Remove the module manually.

    1. Boot into TWRP
    1. Advanced -> File Manager
    1. Delete /adb/modules/NFCScreenOff
    1. Reboot

    THE MODULE IS NOT WORKING SINCE LAST UPDATE

    Perform a clean reinstallation.

    1. Uninstall the module
    1. Reboot
    1. Install the module
    1. Reboot

    If it does not solve your problem, you can create an issue.

    I LIKE THE MODULE



    TAP TO PAY DOES NOT WORK WHEN SCREEN IS OFF

    This is a Work In Progress...
    2
    @lapwat Hi, awesome module. It is not working for me since the path (and app name) for nfc app is system/app/NxpNfcNci/NxpNfcNci.apk

    Android 10.3.0
    Oneplus 6
    Stock ROM

    Edit:attach log

    Thanks for the logs. Can you send those files to me:
    • /system/app/NxpNfcNci/NxpNfcNci.apk
    • /system/framework/framework-res.apk

    I will do a version for people with NxpNfcNci app (I guess it is OnePlus customized NfcService).
    My stock Xiaomi ROM had a NQNfcNci app.
    2
    The thing is, since this is not the default, nobody would try to do it randomly until finding somebody with this module. It's a very low chance, but still dangerous. Taiping to the fingerprint sensor or unlocking in other preferred way should be more secure, plus it's not that hard to do it. This module only has use if you excessively use NFC tags, otherwise it's just nothing but creating security gaps for nothing.

    Thanks to the dev anyways.

    ---------- Post added at 05:06 AM ---------- Previous post was at 04:56 AM ----------



    Here you go, get the build props with this code in your install.sh:

    Code:
    my_grep_prop() {
      local REGEX="s/^$1=//p"
      shift
      local [email protected]
      [ -z "$FILES" ] && FILES='/system/build.prop /vendor/build.prop /product/build.prop'
      sed -n "$REGEX" $FILES 2>/dev/null | head -n 1
    }
    
    local MANUFACTURER="$(my_grep_prop 'ro\.product\.manufacturer')"
      local        MODEL="$(my_grep_prop 'ro\.product\.model'       )"
      local       DEVICE="$(my_grep_prop 'ro\.product\.device'      )"
      [ -z "$MANUFACTURER" ] && MANUFACTURER="$(my_grep_prop 'ro\.product\.vendor\.manufacturer')"
      [ -z "$MODEL"        ] &&        MODEL="$(my_grep_prop 'ro\.product\.vendor\.model'       )"
      [ -z "$DEVICE"       ] &&       DEVICE="$(my_grep_prop 'ro\.product\.vendor\.device'      )"

    That's exactly what I need it for. I set up all sorts of NFC triggered automations and tasks back in lollipop and have missed using them dearly. I have never used gpay so security is basically irrelevant, I've never heard of anyone trying to attack phones in the wild over NFC


    Until now, the module worked great. But the lastest update (0.0.3) causes bootloops for me.

    -> Googel Pixel 3xl on android 10 (build QQ1A.200105.003)

    Could you also please provide the zip file to version 0.0.2?

    I couldn't find v2 on his github but I had a backup I've attached
    1
    @lapwat Hi, awesome module. It is not working for me since the path (and app name) for nfc app is system/app/NxpNfcNci/NxpNfcNci.apk

    Android 10.3.0
    Oneplus 6
    Stock ROM

    Edit:attach log
    1
    Any possibility to remove the NFC sound?
    Would love to do it if you can find where the sound is triggered in the source: https://android.googlesource.com/pl...s/tags/android-9.0.0_r48/src/com/android/nfc/

    EDIT

    Found it here: https://android.googlesource.com/pl...0_r48/src/com/android/nfc/NfcService.java#758

    Can make a patch if other users don't mind. I will let some time for people to see this message and if nobody is against removing the sound, I'll give it a try ;)
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone