yashsingh1/xdaforums huggingface dataset:
[Galaxy Note 10.1 Accessories] gmkelly001:
I've noticed that the 10.1 won't power some things like a 2.5" portable drive that my Note 2 can power just fine. Not sure if there is a reason for this and it's working as intended or just a bug?
[Galaxy Note 10.1 Accessories] Szadzik:
It is only by a fluke that the Note 1 powers an HDD. These devices are not designed to power anything but USB sticks. Not sure if there is enough juice to power a USB3 stick so do not look for bugs or solutions as this is not a bug but that how the device is designed.
[NFC Hacking] ascsa:
Impressive work!

Could not test it by myself so far, because I´m a little bit busy with other stuff , but had a look at your code, and I think it should work pretty good for your use case!

Not sure if it will work for everyone, because if I got it right, the dispatchTagEndpoint part will start a new dispatching process, and therefore a normal swipe/ tap of the tag (I think most people will swipe their tags) will give you 2 dispatching events ....--> some people/ apps will get confused ... .... However with NFC Retag you could add for example an empty cycle to catch this second event and handle this way your "swipe" tags and your "stationary" tags ...

I´m also not sure, If the broadcom nfc stack will handle this similar ...I only had a quick look at the nxp.NativeNfcManager ....but again: Impressive work!

EDIT: OK, several month later ....it´s implemented within NFC ReTag version 2.6.....;)
[NFC Hacking] madfish73:
It will be nice if you add support of action "android.nfc.action.TAG_LOST" to ReTAG, and I'll try to mod NFC.apk to broadcast that action when tag removed.
[NFC Hacking] ascsa:
yep, had a similar idea ... not sure if I could add it within the next update and I have to think about it, how to handle it (e.g. via a special cycle), but this should be possible.
[NFC Hacking] madfish73:
I've done this and it worked perfectly with modded "AnyTag NFC" apk.

I play a trick with tagid, if intent action is "TAG_LOST" then let tagid = tagid + "_TAG_LOST" else tagid = tagid + "_TAG_DISCOVERED".
[NFC Hacking] klau1:
Will it work on stock rooted Galaxy S3 i747 (carrier versions)?
[NFC Hacking] madfish73:
No, I never tested it on Galaxy S3. But if you upload the Nfc.apk here, I will give it a try.
[NFC Hacking] klau1:
Please try this one:

NFC.APK from ROM: [root66_BMC_I747MVLDLK4]

Thank you! You are very helpful!

EDIT:

edited to add the odex file
[NFC Hacking] madfish73:
It also needs nfc.odex to do the mod.
[NFC Hacking] klau1:
Sorry about that.

Here it is: Attached with this post.
[NFC Hacking] madfish73:
Sorry, still missing some files.

I've tried to use files of Note2 framework, there's no framework_ext.odex in Note2 framework files list.

I really don't know what files needing, so I have to try it one by one. Please upload the following file:

/system/framework/framework_ext.odex
[NFC Hacking] klau1:
No worries, I appreciate your effort :good:

Here is the framework and NFC files: Attached with this Post

Here is the rooted Rom: root66_BMC_I747MVLDLK4.7z

There are also:

framework2.jar

framework2.odex

framework-res.apk

^those were not included with in the ZIP file. Let me know if you need them too.
[NFC Hacking] madfish73:
try it and tell me the result:

1. download attachment, rename it to Nfc.apk

2. bakcup your files: /system/app/Nfc.apk, Nfc.odex

3. delete /system/app/Nfc.odex

4. Copy attatchment file(named it Nfc.apk) to /system/app

5. reboot

View attachment 1769854
[NFC Hacking] klau1:
Re: Detecting NFC Tag removal hacking [add video demo & apk !!!]

The result is great! It works very well. I downloaded your modded anynfc too.

Do you have a paypal account to donate to? Not much to give but maybe enough for a beer:D
[NFC Hacking] klau1:
Re: Detecting NFC Tag removal hacking [add video demo & apk !!!]

There is only one problem.

The NFC doesn't function on screen off or lock screen.

For reference, This one (attached) from LK3 rom has the modded code for working in Screen Off and Lock Screen. Perhaps it will work if the code can be copied over to the LK4 NFC.APK you modded?
[NFC Hacking] madfish73:
Well, I missed a constant value in the code, this one maybe ok, try it again:

View attachment 1771004
[NFC Hacking] klau1:
Re: Detecting NFC Tag removal hacking [add video demo & apk !!!]

Yep it works! Awesome!:thumbup: let me know about that PayPal donation email anytime:D :beer:

I hope there is a way to universalize this so many phones can work.

Perhaps something like Xposed Framework can work. It modifies method calls of APKs at runtime.

http://xdaforums.com/showthread.php?t=1574401
[NFC Hacking] LoveNFC:
Which files do you need exactly? NFC.apk and NFC.odex? Or should I just upload the NFC.apk from a stock deodexed ROM? I'd like to get this working on a stock Galaxy Nexus and stock Nexus 4.
[NFC Hacking] klau1:
Re: Detecting NFC Tag removal hacking [add video demo & apk !!!]

Read the previous post about framework files I sent
[NFC Hacking] LoveNFC:
There's no framework-ext file in the Nexus devices, so I've attached Framework.odex and its related files, as well as ext.odex and its related files.

The Nexus 4 unsurprisingly is a bit different. It has NFCNci.apk/.odex instead of just NFC.apk.

Hopefully the modification will still be possible, but I won't be surprised if it's not.

By the way, these files are taken from a stock Galaxy Nexus on 4.2.1, and a stock Nexus 4 on 4.2.2.

The files wouldn't attach, so here they are:

http://speedy.sh/dwPu9/Galaxy-Nexus-NFC.zip

http://speedy.sh/E46QA/Nexus-4-NFC.zip

Thanks!
[NFC Hacking] madfish73:
use logcat to get the log, there maybe some useful infos. please upload the modified nfc.apk here.
[NFC Hacking] madfish73:
1. what's your android version?

2. install terminal emulation and run

3. type:

su

logcat -f /sdcard/nfcmod.log

4. test tag found & lost

5. after nfc service crashing, press Vol down + C to break logcat

6. upload /sdcard/nfcmod.log

7. upload /data/exposed/debug.log
[NFC Hacking] madfish73:
Glad to hear this good news :good:
[NFC Hacking] jabberwock:
Android version is 4.1.2

My logs: http://db.tt/Hz4efzzS
[NFC Hacking] madfish73:
didn't find nfc service crashing infos. please download the new version from first post and try again.
[NFC Hacking] ascsa:
Yep, I would have preferred this "tag lost" message as an official android feature, before implementing it within NFC ReTag, but as the android and nfc forum guys focus just on some "unicorn" nfc payment features and lame pairing options , your module mod within the Xposed framework is the next best solution ...
[NFC Hacking] mbze430:
will this have adverse effect on Google Wallet? And the modified NFC.apk... is that for AOSP roms?
[NFC Hacking] madfish73:
Because I don't have Google Wallet, so I'm not sure that. But as what I've modified, I believe it just effect on tag removal action.

I suggest you using Xposed mod instead of nfc.apk mod.
[NFC Hacking] mbze430:
Ohhh.. I was under the impression that the modded nfc.apk that allows you to do the lift off the tag. Because Paranoid Android rom allows you to turn on NFC with screen off already.
[NFC Hacking] madfish73:
Sorry I did not make it clear in the first post. The Xposed plugin module NFCLockScreenOffEnabler.apk has been modified to support tag removal detecting, so you don't need the nfc.apk mod any more!
[NFC Hacking] mercurio.:
i am also trying to get this running for the razr i, and as no xposed framework is aviable to mod the apk is the only way. could maybe someone have a look at the logcat i attached and may tell what could be a solution?

thanks in advance
[NFC Hacking] cbb77:
Not sure if this has already been posted but I'm currently experiencing times when the NFC doesn't work at all. Seems to be if I have not used the NFC functionality in a while. I just noticed it toward the end of last week / weekend. I typically use NFC in the car and had a work from home day as well as didn't really go out till late in the day on the Saturday. I could not get my SG4 to recognize the tag in my car. Normally works without issue. Had to turn NFC off and back on for it to work. Same thing this morning. Didn't use NFC on Sunday and this morning didn't want to work initially. Turning off and back on resolved it and it works fine throughout but seems like there is some sort of timeout being applied here. Is this the case?
[NFC Hacking] madfish73:
Sorry, wrong quote...... :)

The file NativeNfcTag.smali hadn't been modified correctly.

08-27 00:16:33.939 D/NfcService( 3787): Tag detected, notifying applications

08-27 00:16:33.939 I/am_crash( 442): [3787,com.android.nfc,638541,java.lang.AbstractMethodError,abstract method not implemented,NativeNfcTag.java,-1]

08-27 00:16:33.939 E/AndroidRuntime( 3787):	at com.android.nfc.nxp.NativeNfcTag.SetTagLostCallBack(NativeNfcTag.java)

08-27 00:16:33.939 E/AndroidRuntime( 3787):	at com.android.nfc.NfcService$NfcServiceHandler.handleMessage(NfcService.java:2390)

08-27 00:16:38.219 I/binder_sample( 3787): [android.app.IActivityManager,2,4274,com.android.nfc,100]
[NFC Hacking] madfish73:
I encounter this problem when battery is low
[NFC Hacking] madfish73:
I encounter this problem when battery is low. Galaxy Nexus, BAKED ROM.
[NFC Hacking] madfish73:
The file NativeNfcTag.smali hadn't been modified correctly.

08-27 00:16:33.939 D/NfcService( 3787): Tag detected, notifying applications

08-27 00:16:33.939 I/am_crash( 442): [3787,com.android.nfc,638541,java.lang.AbstractMethodError,abstract method not implemented,NativeNfcTag.java,-1]

08-27 00:16:33.939 E/AndroidRuntime( 3787):	at com.android.nfc.nxp.NativeNfcTag.SetTagLostCallBack(NativeNfcTag.java)

08-27 00:16:33.939 E/AndroidRuntime( 3787):	at com.android.nfc.NfcService$NfcServiceHandler.handleMessage(NfcService.java:2390)

08-27 00:16:38.219 I/binder_sample( 3787): [android.app.IActivityManager,2,4274,com.android.nfc,100]

try this mod: View attachment nfc-RAZR-I-for-orphee-mod.apk
[NFC Hacking] madfish73:
try the mod in prev post.
[NFC Hacking] mercurio.:
thanks a lot. your mod works. i'm gonna try to find out what i did wrong.

eidit:

i think i found the error. in the word file it says:

method public declared-synchronizedSetTagLostCallBack(Landroid/content/Context;)V

and i suppose it should be:

method public declared-synchronized SetTagLostCallBack(Landroid/content/Context;)V

well, that's what happens if you just copy and paste. stupid me!
[NFC Hacking] Orphee:
Hi,

I'm comparing your file with mine

Currently the difference I found is in NativeNfcTag.smali :

NativeNfcTag.smali

In your doc :

# virtual methods

.method public declared-synchronizedSetTagLostCallBack(Landroid/content/Context;)V

In your Nfc mod :

# virtual methods

.method public declared-synchronized SetTagLostCallBack(Landroid/content/Context;)V

There is a space missing in the doc between declared-synchronized and SetTagLostCallBack(Landroid/content/Context;)V

NativeNfcTag$PresenceCheckWatchdog.smali

In your doc :

iget-object v0, p0,Lcom/android/nfc/nxp/NativeNfcTag$PresenceCheckWatchdog;->this$0:Lcom/android/nfc/nxp/NativeNfcTag;

In your Nfc mod :

iget-object v0, p0, Lcom/android/nfc/nxp/NativeNfcTag$PresenceCheckWatchdog;->this$0:Lcom/android/nfc/nxp/NativeNfcTag;

There is a space missing (I don't think it is important here)

NfcService$NfcServiceHandler.smali

In the last post you gave me :

invoke-interface/range {v24..v25}, Lcom/android/nfc/DeviceHost$TagEndpoint;->SetTagLostCallBack(Landroid/content/Context;)V

In your Nfc mod :

invoke-interface/range {v24 .. v25}, Lcom/android/nfc/DeviceHost$TagEndpoint;->SetTagLostCallBack(Landroid/content/Context;)V

The spaces are missing (don't think it is important here too)

In the end, maybe I'm wrong but the only big error is the following line :

.method public declared-synchronized SetTagLostCallBack(Landroid/content/Context;)V

Can you confirm ?

Thank you :)

Edit : grilled lol
[NFC Hacking] mercurio.:
i added the two spaces and everything works great (see previous post)
[NFC Hacking] madfish73:
yes, you are right. The space missing in ".method public declared-synchronized SetTagLostCallBack(Landroid/content/Context;)V " makes the method SetTagLostCallBack unimplemented.
[NFC Hacking] Orphee:
Thank you for your help :)

Anyway to enable screen off NFC too ?

To enable NFC on lockscreen I took exemple from : http://xdaforums.com/showthread.php?t=2263930

I added in NfcService.smali

iget-object v0, p0, Lcom/android/nfc/NfcService;->mKeyguard:Landroid/app/KeyguardManager;

invoke-virtual {v0}, Landroid/app/KeyguardManager;->isKeyguardLocked()Z

move-result v0

[B][COLOR="Red"]const/4 v0, 0x0[/COLOR][/B]

And in NfcService$2.smali

#getter for: Lcom/android/nfc/NfcService;->mKeyguard:Landroid/app/KeyguardManager;
invoke-static {v10}, Lcom/android/nfc/NfcService;->access$2600(Lcom/android/nfc/NfcService;)Landroid/app/KeyguardManager;

move-result-object v10

invoke-virtual {v10}, Landroid/app/KeyguardManager;->isKeyguardLocked()Z

move-result v10

[B][COLOR="Red"]const/4 v10, 0x0[/COLOR][/B]

Is there a way to do the same for screenoff ?

Thank you :)
[NFC Hacking] mercurio.:
from what i read it should be possible but i suppose it would be a battery killer as the constant polling probably kills the deep sleep.
[NFC Hacking] Orphee:
Yes i know, but sometimes it could be usefull, while charging, bedtime...

A NFC tag to mute sound until removed from NFC tag.
[NFC Hacking] madfish73:
I think it only need to modify .method applyRouting(Z)V of NfcService.smali.

try to add these lines to the begining of method applyRouting if you want screen-off-nfc:

.method applyRouting(Z)V
.locals 6
const/4 v1, 0x3
iput v1, p0, Lcom/android/nfc/NfcService;->mScreenState:I
...
...

and these if you want screen-on-locked-nfc:

.method applyRouting(Z)V
.locals 6
const/4 v2, 0x1
iget v1, p0, Lcom/android/nfc/NfcService;->mScreenState:I
if-eq v1, v2, :screenStateOff
const/4 v1, 0x3
iput v1, p0, Lcom/android/nfc/NfcService;->mScreenState:I
:screenStateOff
...
...
[NFC Hacking] Orphee:
On my RazrHD the mod works, but there is no lost sound. Did I miss something ?
[NFC Hacking] mercurio.:
does this have an impact into the sleep behavior? does a phone with nfc durring screen off go into deepsleep at all? would be gread if you could tell me your expreiences reguarding battery consumption!
[NFC Hacking] madfish73:
You miss nothing. To simplify the modification, I remove the taglost sound mod.
[NFC Hacking] madfish73:
I realy dont' know that, you can try it.

To me(Galaxy Nexus), it's no difference, because I always charge my phone every night whether I enable Nfc or not.
[NFC Hacking] Orphee:
Ho, okay :(

Thank you anyway :)
[NFC Hacking] Orphee:
Hi again,

I'm trying to add taglost sound to my apk...

I took the files from post #78 and #79 as example...

Compilation works, but I have a force close when NFC service starts (loop)

Could you please help me ?

Nfc.apk is the original.

Nfc-RazrHD is the modded.

Thank you :)

Edit : My bad, I found my error...

In NfcService$NfcServiceHandler.smali :

I did not replace :

invoke-static/range {v26 .. v26}, Lcom/android/nfc/NfcService;->access$400(Lcom/android/nfc/NfcService;)Lcom/android/nfc/DeviceHost;

by

invoke-static/range {v26 .. v26}, Lcom/android/nfc/NfcService;->access$300(Lcom/android/nfc/NfcService;)Lcom/android/nfc/DeviceHost;

and

invoke-static {v1}, Lcom/android/nfc/NfcService;->access$1000(Lcom/android/nfc/NfcService;)Lcom/android/nfc/NfcDispatcher;

by

invoke-static {v1}, Lcom/android/nfc/NfcService;->access$900(Lcom/android/nfc/NfcService;)Lcom/android/nfc/NfcDispatcher;

It still crash, but now it is harder for me to understand logcat... (see zip in attachement)

Edit again : Finally did it.

7zip was compressing the taglost.ogg sound file... I did it with WinRAR without compressing... It works now !

Thank you !
[NFC Hacking] madfish73:
WOW, congratulations!!!
[NFC Hacking] Orphee:
Thank you for you help and your patience :)

http://xdaforums.com/showthread.php?t=2423648

(By the way, mod for enable while screen off didn't work, I have to take time to extract logcat for this)
[NFC Hacking] kantjer:
I have been using a mod on my S4 that enables NFC with screen off and still I have seen deepsleep percentage over 80%. So no it doesn't seem to effect battery consumption.

PS. I would love to see a screen off version of this mod.
[NFC Hacking] the_rebel:
This is just beautiful, and works perfectly for me. Thank you very much for this sorely missed feature. And its not something I didn't know I missed till I got it, a few months back I had a discussion with Magnus Spånggård, the creator of NFC plugin for Locale to see if this feature could be added and he said that sadly Android OS doesn't support it.

Cheers
[NFC Hacking] Orphee:
Hi,

I searched for screenoff modification...

In NfcService.smali :

I added

const/4 v0, 0x0 (at line 2336)

In NfcService$2.smali :

I added

const/4 v10, 0x0 (at line 92)

In fact I tried to do it same way I did for lockscreen ON (line 2350 and line 166 in each files just after isKeyguardLocked)

It works... but :

It works only for NFC Tag detected...

I'm trying to do a NFC tag bed time...

When Tag detected, sound muted and When tag lost, sound unmuted.

I can leave my screen off 10 minutes NFC is working when new tag is detected. But for tag lost, after 1 minute on the TAG while screen OFF, it doesn't detect the tag lost... (deep sleep ? because if I only wait 30 seconds, tag lost is still detected and I can play with scan again and again)

I must turn screen ON to reactivate NFC, I have to rescan the tag to trigger again the tag detected and tag lost.

I guess I'm doing it the wrong way...

Edit : it seems Xposed module has the same behavior.
[NFC Hacking] the_rebel:
My happiness was short-lived. The battery usage when my phone is lying idle on top of a NFC tag is more than 15% per hour! Twice a fully charged phone hasn't survived the night.

Is there anything I can do to help my situation, or is this to be expected?

Thank you.

NFC polling mode with screen off, turned on.

Nexux 4, Latest AOKP ROM, 4.2.2, Latest Franko kernel.
[NFC Hacking] madfish73:
try these mod, only need to modify NfcService.smali, remark lines 2069-2094

# if-nez p1, :cond_6

# iget-boolean v1, p0, Lcom/android/nfc/NfcService;->mNfcPollingEnabled:Z

# if-eqz v1, :cond_7

# .line 2258
# :cond_6
# const-string v1, "NfcService"

# const-string v2, "NFC-C OFF, disconnect"

# invoke-static {v1, v2}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

# .line 2259
# const/4 v1, 0x0

# iput-boolean v1, p0, Lcom/android/nfc/NfcService;->mNfcPollingEnabled:Z

# .line 2260
# iget-object v1, p0, Lcom/android/nfc/NfcService;->mDeviceHost:Lcom/android/nfc/DeviceHost;

# invoke-interface {v1}, Lcom/android/nfc/DeviceHost;->disableDiscovery()V

# .line 2261
# invoke-virtual {p0}, Lcom/android/nfc/NfcService;->maybeDisconnectTarget()V

replace line 2185 from

const/4 v2, 0x3

to

const/4 v2, 0x1
[NFC Hacking] madfish73:
Sad news. I never test the battery usage when put the phone on tag. All my tags(BedTime tag, CarMode tag) used with this Nfc mod are beside a touchstone, so when my phone is put on top of these tags, it also being charged by the touchstone.
[NFC Hacking] the_rebel:
Thank you for your quick reply. But your mod has many users, has nobody else faced the same problem? My tested usage (nfc to silence phone over the night) can't be too uncommon.
[NFC Hacking] ascsa:
Hmmm sure, this should be expected... Your device is permanently connected with the tag...same connection as you would read or write the tag. Polling every few milliseconds and powering the tag. I analysed it some time ago, but if I remember it right my testing device was polling 10-15times per Second . There is no nfc sleep mode while tag is detected, simply because nfc doesn't support this tag lost behavior... To make it short: this mod catches the tag lost messages, because a lot of user's demanded it, but keep in mind that nfc never was designed to work this way, so expect high power consumption, frequent nfc crashes and perhaps some early worn out effect of your nfc chip (don't think anyone really has some longterm experience with this use yet).. And all this couldn't be changed by any mod...

... Sent from mobile...
[NFC Hacking] the_rebel:
Thank you for the information. In light of this, I guess I'll have to forego the comfort of just putting the phone at a certain place and picking it up to activate/deactivate profiles. I'm now looking into what else comes closest - like activating accelerometer profile to detect slightest movement and deactivating night profile. Downsides are obvious, won't work in car and no idea yet of battery usage.
[NFC Hacking] ascsa:
Naah,don´t get me wrong, the best solution for your need is still nfc ....if you want to stay on the save side, just use some toggle function ....first swipe activates your profile, second swipe deactivates it ...

"nfc on while screen on, but locked" option shouldn´t affect power consumption significantly if your screens goes off frequently, and you avoid the hassle to unlock the device every time (in fact, this was the android standard behavior within Gingerbread, and google changed it , to add some additional security for google wallet ...)

The "NFC always on" option could give you some nfc crashes, because without some frequent restarts this service seems to freeze sometimes ...usually disable and enable nfc manually should fix this ...so you must decide, what´s more convenient for you.

The Tag lost behavior is more problematic, but by using a charger at the same time, the power consumption should not be a problem .... and regarding the worn-out effect, it´s something you should keep in mind because it´s something different than the standard behavior, but until now, I never heard of a defect nfc chip ...

However, if you root your phone and install some mods, custom roms etc. everybody should be aware that any mod, custom rom etc. could have some side-effects...
[NFC Hacking] the_rebel:
Just noticed that polling only with screen on creates an interesting issue. As soon as the screen goes off even when the phone is on the tag, it registers as a tag removal - I was hoping that it'd register a removal when 'screen goes on next time and it sees the tag is no more there'. So in the current scenario putting the phone on the tag makes it go silent, and as soon as the screen turns off, silent mode goes off too.

And this also means that tag removal event would not be of much use in screen off mode, as it'll register on screen off instead of actual tag removal.

I'm probably missing something here, ain't I?
[NFC Hacking] ascsa:
Yep, you're right... That's exactly the reason, why I added the "support screen off mode" setting within NFC ReTag.... It ignores the tag lost messages fired due to the screen off event ... Turning screen on fires again the tag found activities and removing the tag fires the usual tag lost.. So basically push the power button to turn the screen on and then remove the tag...

... Sent from mobile...
[NFC Hacking] the_rebel:
I tried NFC ReTag for the first time, it is a very nice app, and if I may be so bold to say, deserves a better GUI. No offence meant, just a little feedback.

Ok, it doesn't register a tag removal when screen goes off - which is good. But once I turn the screen on and phone is not on the tag, it still doesn't register a removal, that's odd, I figured it should see it at that moment that the tag is gone, shouldn't it?