yashsingh1/xdaforums huggingface dataset:
[Xposed Framework Modules] booboss:
Hi,

Good to know :)

I'll consider changing room.

Thanks!!!
[Xposed Framework Modules] nevvjeff:
I just update my phone with lollipop, loving this OS, but without this module my nfc ring is just useless.....

Can't help anyone with the source code, cause I don't know coding, but I hope someone can do the update of this module soon, cause it just be the first one I use after installing Xposed ..... :crying:
[Xposed Framework Modules] i.surfers:
Just to help anyone that could update this module, it's working partially.

- Screen on is fully working and still sending TAG_CHANGED intent

- Screen on and locked working, but only when Smart Lock is enabled and with some NFC tag associated

- Screen off is NOT working at all

I have a GT-9505 using AntaresOne 5.0.2 custom rom with Xposed 3.0 alpha2 and NFC LockScreenOff Enabler 1.9.7.7
[Xposed Framework Modules] irotsoma:
Doesn't work at all on my HTC One M8 with ARHD 30.x or 40.x (Sense 6 and 7 ROMs respectively) or CM12. I tried adding the NFC tag to smart lock to verify based on your post. That didn't help :(
[Xposed Framework Modules] riqdiq:
Wish this was working for my nexus 6 running 5.0.2 CM12
[Xposed Framework Modules] XlAfbk:
I just learned that cataclysm rom supports polling with screen off on lollipop. now we "just" need to get that into an xposed module.
[Xposed Framework Modules] XlAfbk:
modded apk for CM12

While we're waiting for a Xposed module for Lollipop I've managed to mod CM12s NfcNci.apk to poll with screen off

If you need tag-lost-support, intents, ... then you also need this threads Xposed module.

If you phone is using Nfc.apk instead of NfcNci.apk use the apk from http://xdaforums.com/showpost.php?p=59818534&postcount=480

Install instructions:

1. backup your /system/app/NfcNci/NfcNci.apk (to e.g. sdcard, do NOT keep the backup in /system/app/!)

2. push the attached NfcNci_screenoff.apk to /system/app/NfcNci/NfcNci.apk (adb push NfcNci_screenoff.apk /system/app/NfcNci/NfcNci.apk) or use a root-enabled file manager to replace the file

3. chmod 644 /system/app/NfcNci/NfcNci.apk

4. reboot

How to create this mod yourself:

1. adb pull /system/app/NfcNci/NfcNci.apk

2. decompile (e.g. using apktool)

3. make changes according to attached diff

4. compile (+ zipalign)

5. copy META-INF + AndroidManifest.xml from original

I'll be updating this .apk whenever it breaks, until a Xposed mod is released

Update 31.03.2015:

- new version that no longer redetects tags on screen state change

- step by step instructions for creating the mod + diff attached
[Xposed Framework Modules] twinsen.net:
I can confirm it works on CM12-20150326-NIGHTLY-d802 :) Yay! Finally I'm able to detect my car dock just by NFC, wihout turning on screen! Another win battle against stupid exaggerated Google security...
[Xposed Framework Modules] riqdiq:
Where do you change the description?
[Xposed Framework Modules] num1gever:
Amazing! Confirmed working on LG G3 AOSP based rom (Euphoria) with SELINUX on enforcing!
[Xposed Framework Modules] almahix:
Cool! Can't wait for xposed for 5.1 so I can try it out. Thanks!

---------- Post added at 04:14 PM ---------- Previous post was at 03:45 PM ----------

Oops...nvm.

---------- Post added at 04:28 PM ---------- Previous post was at 04:14 PM ----------

Tried to replace the apk in my 5.1 ROM and tag wasn't scanned in any mode. Dang. Is there anything to do other than backup original apk and substitute the new one?
[Xposed Framework Modules] almahix:
Anyone know of a Shamu (nexus 6) ROM with this?
[Xposed Framework Modules] XlAfbk:
I've updated my apk in my previous post to no longer fire on screen state changes.

If you discover any issues please make sure to quote me so i get a notification.
[Xposed Framework Modules] i.surfers:
Hi XlAfbk!

First of all, thanks for your work!

Here your mod is not working...

I have a GT-9505 with AntaresOne Optimized 5.0.2 custom rom and Xposed 3.0 alpha2 with NFC LockScreenOff Enabler 1.9.7.7.

My NFC tile and preferences just disappeared...

I made a backup of the NfcNci.apk renaming it to NfcNci_ORIGINAL.apk and then copied your NfcNci_screenoff.apk and renamed to NfcNci.apk, then rebooted.

Do you know what could be wrong?

Thanks!
[Xposed Framework Modules] XlAfbk:
I guess your ROM isn't using CMs platform keys while my modded apk is using them. You could try just copying AndroidManifest.xml and META-INF from your apk to the mod (using 7z/winrar/...), it might work. If it doesn't you'll have to mod it yourself, see my original post for instructions.
[Xposed Framework Modules] num1gever:
I can confirm it's working on AOSP too. So his problem could be permissions maybe. [MENTION=3609883]i.surfers[/MENTION] Have you changed permissions for the modded apk? It needs to be rw-r--r-- (0644).
[Xposed Framework Modules] almahix:
Still no joy on AICP 9 (5.1) for shamu, but dev may implement it. He merged the kitkat version and it worked for him.
[Xposed Framework Modules] pawci0:
On LG E975 (CM12 nightly built 20150331) when I used your .apk I got NFC force close multiple times.

Something noteworthy: my Nfc app was located in: /system/app/Nfc/Nfc.apk

I decided to modify this app by myself. Just followed the instructions and it worked like a charm!

Attached the file after my modifications - maybe someone will use it.

Thank you XlAfbk!
[Xposed Framework Modules] booboss:
It seems I'm missing something. What instructions, where?
[Xposed Framework Modules] Orphee:
Hello,

I have a Oneplus One with official CM11S rom.

I have an issue with screenoff support... It seems after a little time, the phone does not detect tag lost until I switch on the screen...

What can i do ?

Thank you
[Xposed Framework Modules] i.surfers:
Never mind, I was letting both NfcNci_ORIGINAL.apk and NfcNci.apk inside /system/app/NfcNci folder, that was the problem!

So I moved NfcNci_ORIGINAL.apk to sdcard and rebooted then it started working!

:) :good:

Thank you very much guys!!
[Xposed Framework Modules] XlAfbk:
Right, I completly forgot that some devices are still using that (been a while since modding the apk was the goto solution ;)). Thanks for sharing your apk!

Those in http://xdaforums.com/showpost.php?p=59780557&postcount=469

Is there anyone with a little "overriding stuff with Xposed"-experience? I'd like to get the Xposed module back to working state but don't have enough time to learn everything from scratch. So if you've done stuff like this in Xposed before and would like get together for a little hacking session please PM me.
[Xposed Framework Modules] almahix:
The AICP 9 (5.1) ROM for Shamu and Hammerhead (and probably other) phones now feature an NFC polling mode control that will enable screen off NFC operations. Works great!
[Xposed Framework Modules] nhhacic:
Please make it work for lollipop. I really like this tweak.
[Xposed Framework Modules] 4stimpy:
I have tried everything in my power to try and get this to work.

I have a nexus 4 on stock 5.01.

I didn't wanted to fuss to much with the phone.

At this moment i got it rooted an have xposed 3.0 installed and working( other modules work)

Only to find out that i did not do enough reading because the old module doesn't work with lollipop.

Now i did try the apk swap but this does not work for my phone.

I already spent two days to try and get this to work, but this is where it ends.

Can't get it to work, and my knowledge stops here.

I really hope someone comes up with an xposed module that works, or comes with a working apk for my phone.
[Xposed Framework Modules] XlAfbk:
it is working by replacing Nfc.apk (http://xdaforums.com/showpost.php?p=59818534&postcount=480 ) or NfcNci.apk (http://xdaforums.com/showpost.php?p=59780557&postcount=469), depending on which your phone uses

My post has pretty detailed instructions on how to mod the apk yourself, even if you've never done it before it shouldn't take you more than 2h to do it yourself.

But I'd think that my CM12-mod has a quite high chance of working on stock - did you put it in the wrong place, not keep the old apk and chmod it correctly?
[Xposed Framework Modules] 4stimpy:
What I did is remove original NfcNfi from system and store it in safe place.

Copied your NfcNfi_screenoff to the original location in the system and renamed it to NfcNfi like the original was.

Set the rights to 755 the same as original and restarted the system.

After the restart i did not have the nfc functionality anymore.

If i manually try to start your apk it fails to install.

I put the original bak and nof i have nfc again but still only on unlocked phone.

I will try and read even more because i don't understand how to get the apk tool running.

And the decompile end recompile thing.... i will have to read more to understand all that.

How can i vieuw the .diff file?
[Xposed Framework Modules] XlAfbk:
should be 644

it's really easy: grab apktool from http://ibotpeaches.github.io/Apktool/

apktool d NfcNci.apk = decompile

make changes

apktool c NfcNci.apk = compile (use classes.dex from this one)

It's a plain text file http://en.wikipedia.org/wiki/Diff
[Xposed Framework Modules] 4stimpy:
After i posted i noticed that the value should be 644.

So i tried it right away but it did not make a difference.

I managed to decompile both your NfcNfi_screenoff and my original NfcNfi.

There are a lot of folders and files, where should i look for the difference.

And where should i look to change something.

Tried a little thing, i noticed that the version of manifest file was 5.02 (and a something)

while my original had 5.01 (and something)

Now i tried apktool b NfcNfi_screenoff on your file(which i edited) but i get an error an no apk was generated.

So i tried apktool b NfcNfi on my original(not changed) folder but also get an error.

Also you write this?

5. copy META-INF + AndroidManifest.xml from original

What exactly do you mean by that.
[Xposed Framework Modules] pawci0:
I also lost the NFC functionality when the original Nfc.apk was still in the same folder (even if it was renamed). Nfc also didn't work with the apk modified by XIAfbk - it was somehow incompatible.

I recomend modifying the apk by yourself.

To use the manifest file from original apk, you can use builtin apktool option. Can't remeber which one it was, in help it was called something like "use original manifest".
[Xposed Framework Modules] XlAfbk:
the .diff file contains the list of changes to be made

Open the original .apk in 7zip/winrar/..., extract META-INF-folder and the .xml file, then open your modded .apk and put them in there

it was because some phones require NfcNci, some Nfc - it's not just the name that's different but also the program logic
[Xposed Framework Modules] 4stimpy:
I now know that i can edit smali files with notepad.

I also know which file was edited by XlAfbk.

What i am trying is to replace the folder original in NfcNfi_screenoff with the folder out of my own.

And i also want to replace the AndroidManifest.xml in the main folder with the one out of my own.

Only thing is now, how do i recompile without errors.

[MENTION=2832063]XlAfbk[/MENTION], thanks for your help, i am a slow learner but with some help i will get there.
[Xposed Framework Modules] XlAfbk:
also for .diff syntax highlighting use an editor with syntax highlighting (e.g. Notepad++) or http://tohtml.com/

That makes it easy for you to see what needs to be changed in the .smali files.

if you mod it yourself you don't need my apk at all, just the original you pulled from your phone (you decompile that, make the .smali changes) and your recompiled version (into which you put META-INF + Manifest from original)
[Xposed Framework Modules] XlAfbk:
Step by step tutorial for apk modding

Step by step tutorial for apk modding for Lollipop:

you only need this if the apks in http://xdaforums.com/showpost.php?p=59780557&postcount=469 or http://xdaforums.com/showpost.php?p=59818534&postcount=480 don't work for you

prelude: Depending on your device the Nfc-file might be named "NfcNci" or just "Nfc". This tutorial uses "NfcNci", if your device doesn't have that use "Nfc" in all steps instead.

1. Pull NfcNci.apk from your device: adb pull /system/app/NfcNci/NfcNci.apk

2. Download smali-<version>.jar and baksmali-<version>.jar from https://bitbucket.org/JesusFreke/smali/downloads

3. Put NfcNci.apk and the 2 .jar files in the same directory

4. open a command prompt in that directory

5. open NfcNci.apk with 7z/winzip/winrar/... and extract classes.dex from it (into the same directory)

6. run: java -jar baksmali-<version>.jar classes.dex -o out

7. navigate to directory out\com\android\nfc

8. open NfcService.smali in a text editor

9. search for "android.intent.action.SCREEN_OFF" and replace with "android.intent.action.SCREEN_OFFA"

10. search for "android.intent.action.SCREEN_ON" and replace with "android.intent.action.SCREEN_ONA"

11. search for "android.intent.action.USER_PRESENT" and replace with "android.intent.action.USER_PRESENTA"

12. search for "android.intent.action.USER_SWITCHED" and replace with "android.intent.action.USER_SWITCHEDA"

13. search for ".method private computeDiscoveryParameters" -> about 20 lines below it should be a line like "if-lt v2, p1, :cond_5b" -> replace the 2 parameters in that function (in this example: "if-lt p1, v2, :cond_5b")

14. open ScreenStateHelper.smali in a text editor

15. search for ".method checkScreenState()I" -> change all the return values ("const/4 v0, 0x...") to "const/4 v0, 0x3"

16. run: java -jar smali-<version>.jar out -o classes.dex

17. open NfcNci.apk with 7z/winzip/winrar/... and add classes.dex to it

18. push the modded apk to your device: adb push NfcNci.apk /system/app/NfcNci/NfcNci.apk

19. chmod 644 /system/app/NfcNci/NfcNci.apk

If you don't want to enable Screen off but only Lockscreen check out http://xdaforums.com/showpost.php?p=60080506&postcount=516
[Xposed Framework Modules] pawci0:
I remember having similar error when trying to build apk. You probably need some dependencies from your phone. Try downloading /system/framework/framework-res.apk and install it with apktool (option 'if').

Then build the Nfc.apk again.
[Xposed Framework Modules] vitoski:
Thank you very much for step by step instruction. I tried to modify Nfc.apk from my stock rom (Moto X 4.4.4) according to your instruction and found out that I cannot perform points 13 and 14.

I do not have computeDiscoverParameters method in NFCService.smali neither ScreenStateHelper.smali file in my classes.dex...

So I have a question to you. Does this instruction apply to deodex roms only?

I have Nfc.apk and Nfc.odex files in my system/app path.

Thanks for your help!

Sent from my XT1052
[Xposed Framework Modules] XlAfbk:
Those instructions are for modding the Lollipop .apk. For KitKat you don't need any .apk-mods, just use this threads Xposed module.
[Xposed Framework Modules] vitoski:
Thanks for quick reply, didn't know that it was for lollipop.

Unfortunately this Xposed module doesn't work for me on kitkat when the screen is off. I need to turn and unlock screen to get nfc tag recognized :(

Sent from my XT1052
[Xposed Framework Modules] XlAfbk:
you'll find instructions for modding Kitkat apks on xda, but afaik all these do is the same as this Xposed module
[Xposed Framework Modules] vitoski:
I did some research and tried to compare my NFCservice.smali with other similar mods but looks like I do not have same definitions as others were changing in their nfc.apk files.

Maby Motorola has its own way of implementing NFC...not sure. I suspect this is the reason why Xposed module does not work with my phone ?

Unfortunately my knowledge is very limited here and I don't know which parameter to modify to make it working...

Nevertheless thank you very much for quick replies and feedback!

Sent from my XT1052
[Xposed Framework Modules] XlAfbk:
What you could try - although I give it a low chance of success: Take Nfc.apk from another ROM for your phone (e.g. CM11), mod that and push it to your phone. But I'll guess that'll fail because the signatures mismatch. So the only way to achieve it I guess would be a custom ROM (or figuring out what to mod in your ROM).
[Xposed Framework Modules] vitoski:
I tried that solution but it failed as well. Don't know whether it was caused by signature mismatch or something else but nfc was not working at all. As you said I need to figure out how to mod nfc.apk in my rom to make it running.

Thx.

Sent from my XT1052
[Xposed Framework Modules] XlAfbk:
Try https://github.com/skylot/jadx to convert .dex to .java and get at least somewhat readable output. If you can identify the places to chnage in the .java code then finding them in .smali is usually possible as well.
[Xposed Framework Modules] 4stimpy:
I managed to work down the list, great step by step.

Only thing i want to make sure us step 17.

I have a folder named NfcNci.

I use 7zip, can i just 7zip this folder and rename it to .apk?

Because if i do that the new apk is 192 kb while the original was 350 kb
[Xposed Framework Modules] XlAfbk:
No. You must open the existing apk and add classes.dex (the one you just created with smali) to it. Really the reverse of step 5.
[Xposed Framework Modules] 4stimpy:
Woohoo, yeah.:):good:

I managed to make it work.

Many many thanks to XlAfbk

I really couldn't have done this without your step by step explanation.

The fact that you managed to spot the lines that should be changed between all those folders and file is also magic to me.

I spent in total 3 days of trail and error.

What was my main purpose?

I have an android car stereo, and i want to tether my phone to that.

Therefore i want to switch hotspot on and of with the nfc sticker on my keyfob.

Now i can keep my phone in my pocket to do so.

I someone would like the NfcNci.apk i made for my stock nexus 4 with android ver 5.01, please let me know.
[Xposed Framework Modules] XlAfbk:
Just post it I say :) Congrats on making it work.
[Xposed Framework Modules] 4stimpy:
Here it is, off course you have to rename it to NfcNci.apk.

This works on my rooted Nexus 4 with stock android ver 5.0.1
[Xposed Framework Modules] weiquata:
I managed to modify NfcNci.apk and I can hear the sound which NFC tag detected in lock screen.

But the screen remain locked?

Is there anything/steps I missed beside modified NfcNci.apk?
[Xposed Framework Modules] XlAfbk:
I actually haven't tested the unlocking option in this Xposed module, it might be that that doesn't work anymore and one has to use e.g. Tasker to unlock.
[Xposed Framework Modules] weiquata:
All right, thanks for the great work!

Another question, my device reads nfc tags even in screen off..

Any suggestion?
[Xposed Framework Modules] 4stimpy:
That was the purpose of this mod.

In Xposed there is an option to read nfc screen of or screen on but unlocked.

That should probably be possible by editing the NfcNci file with the correct parameters.

That is above my knowledge at this moment.
[Xposed Framework Modules] weiquata:
Ya, if it read only while screen on, that will be good for me.

Is this the parameter to read at screen off? --> "android.intent.action.SCREEN_OFF" and replace with "android.intent.action.SCREEN_OFFA"

I will try later.

Updated:

I found out the solution to read NFC only while screen on (either lock or unlock).

Just modified some steps from this post.
[Xposed Framework Modules] Orphee:
Hello,

Could someone make screenoff and taglost support for OPO CM12S please ?

here is the file extracted from CM12S rom.

Thank you

Edit : I followed this post to enable screenoff myself :

http://xdaforums.com/showpost.php?p=59941326&postcount=497

Now I can/need to use Xposed module (for 4.4) for tag lost ?

Thanks

Edit 2 : Finally tried it with xposed module tag lost and modded APK, it works like a charm, thank you very much !

Added modded APK in attachement
[Xposed Framework Modules] twinsen.net:
We are all glad that we have a modification to make nfc work when screen is off, but what about the author of original Xposed module? That Xposed called Alpha2 works very well, I don't have any problem with it. So, as we know what to modify, maybe someone having good programming skills can modify also Xposed module?
[Xposed Framework Modules] pawci0:
The original xposed module works almost perfect with the modified Nfc.apk. The only problem I observed is with the TAG_LOST event, which sometimes doesn't work when screen is off.
[Xposed Framework Modules] twinsen.net:
Yes, it could be a problem for someone like me. I'm using NFC to recognize that phone was inserted in car dock. And this is only half-way to make it work: to scan NFC tag, and assume that phone is STILL in the dock. To inform my phone that I'm leaving the car, is to manual screen off with the button AND lost of power. If above event would work properly, I could explicit have a state if phone is in the dock, or not. So now I have to use other triggers to achieve my goal.
[Xposed Framework Modules] XlAfbk:
Haven't seen that one yet. My usecase is also a car mode, so two times a day I remove the phone with display off from NFC tag and so far it always worked. Have you noticed any pattern on when it works and when it doesn't?
[Xposed Framework Modules] pawci0:
Not yet. It seems like the phone is staying in deep sleep. When I take the tag away nothing happens (at least not for the first several seconds) until I wake the phone - then I can hear the signal of lost tag.

Also, once the phone goes to sleep while on a tag, taking it away and taping another tag doesn't seem to work anymore until I wake the phone again.
[Xposed Framework Modules] Orphee:
Same for me
[Xposed Framework Modules] XlAfbk:
Screenoff-mod for CM12.1

Attached is the screenoff-mod for CM12.1 builds. Changes are exactly the same as before.

BUT: on 5.1 the Xposed module doesn't work anymore. Thus all the features provided by the module (tag-lost intents, unlocking, customizable sounds) are lost.

My plan is to wait for a more stable Xposed build and hope it'll fix the problem (seems to be the same one loads of modules experience)
[Xposed Framework Modules] 4stimpy:
I got the notification on my phone that 5.1 is available.

Will i loose root if u upgrade and do it all over again?

I will probably have to make a new NfcNci, but id rather not root it again and loose all the settings again.
[Xposed Framework Modules] elmerohueso:
Packaged up as flashable ZIP. Nexus 4, Android 5.0.1 only.

I don't actually have time to test it currently, so use at own risk, but let me know if it works.
[Xposed Framework Modules] twinsen.net:
Maybe someone could develop flashable zip, which remove/backup original classes.dex from NfcNci.apk and put modded classes.dex to it, or just exchange apk for modded one?

After every nightly I have to exchange NfcNci.apk to my version, which is rather boring....
[Xposed Framework Modules] elmerohueso:
Look at the post right above yours. My flashable zip is specific to N4 stock 5.0.1, but you can swap out any NfcNci.apk and then edit the device checks in the updater-script.

---------- Post added at 09:25 AM ---------- Previous post was at 09:00 AM ----------

Me, too. If it goes into deep sleep, tag lost doesn't kick off until it wakes. While this is understandable, it kind of defeats the purpose of tag lost with screen off as you'll always be turning the screen on to check if tag lost actually worked.
[Xposed Framework Modules] XlAfbk:
instead of always replacing the apk/flashing an additional zip if you're using a ROM with addon.d support (like CM) you can just put the attached .sh (had to zip it as I can't upload .sh) in /system/addon.d/, it'll backup and restore the .apk when flashing new ROMs.

if after a rom update Nfc is broken just remove the file and reflash the rom to get the roms original apk
[Xposed Framework Modules] elmerohueso:
And here's the stock NFC if you want to go back (tested and working for me). I went back since tag lost doesn't seem to kick of during deep sleep, anyway.
[Xposed Framework Modules] almahix:
Anybody have a solution (for we non-dev types) using AOSP-based 5.1 ROMs on Nexus 6?
[Xposed Framework Modules] Marv42:
I'm looking for a sony z1compact LP solution. I treid the different versions but I find for me no working version