[MOD][Xposed] NFC Unlocking (based on NFCLockscreenOff Enabler)

Search This thread

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Requires Xposed Framework!

This module is based off qwerty12's NFCLockScreenOffEnabler, coupled with madfish73's modifications.

The Moto X had a feature called the Motorola Skip, a $20 NFC tag that unlocks your device.
(Speaking of the Moto Skip, here's a tutorial by @Mikegrmn on how to make a similar tag)
This Xposed module imitates that, while giving a bit more freedom as it also works with the screen off, and with any NFC tag.

Screenshots:
ewabYoCl.png
GJ1zqCYl.png


Compatibility:
Any 4.0-4.4 NFC-equipped device that can run Xposed Framework.

Download:
http://repo.xposed.info/module/pk.qwerty12.nfclockscreenoffenabler

Source code:
https://github.com/MohammadAG/NFCLockscreenoffEnabler

Credits:
  • qwerty12 for original module.
  • madfish73 for tag lost support
  • rovo89 for the Xposed Framework
  • Niek Haarman for ListViewAnimations, initially I wanted the NFC tag list animated but it was unnecessary overhead, I kept support for swiping to delete tags though.
  • Roman Nurik for his UndoBar implementation.

Reason for fork:
I spent a lot of time researching how the lockscreen works so I could bypass the user's code without actually storing the code somewhere, and even when that was done, my implementation was insecure and left a big security hole, I also spent some time looking for ways to secure that which I've come up with. An explanation of how it was secured can be found here.
In any case, when I decided to post my work in that thread, it was because I felt I shouldn't fork another version of the module. However, 2 days later, I feel that it got buried in the thread with no one knowing about it, so I emailed qwerty12 and asked him if I could make a thread about the module with all the updates.

Suggestions?
I feel like the name and icon could be changed, if anyone has suggestions, feel free to reply with them down below :)

FAQ
  • This module isn't installing, it's saying something about signatures!
    Due to this being a fork, and no one can share their signatures, you're going to have to uninstall all previous versions prior to installing this.​
  • This module isn't working, what's wrong?
    Do you have Xposed Framework installed? Installing the Installer app isn't enough, you need to hit Install/Update it in. After that, you'll have to tick the module to enable it and soft reboot. If the module still doesn't work, turn on debug mode and attach a logcat after a reboot.​
  • I did what the question above said, I still can't unlock my phone using NFC!
    Have you authorized the tag? See this video by @subzero2000 to know how to do that http://www.youtube.com/watch?v=5ix-5utZwAY
    If you can't authorize the tag as in the video, someone (probably me) messed up somewhere, refer to http://xdaforums.com/showpost.php?p=46950451&postcount=101 to help us debug the problem.
    If you can authorize a tag, but still can't unlock, your manufacturer did something to the lockscreen that's very far from stock Android. Leave a comment and we'll try to help. Alternatively, ask a developer for your device to have a look at it.​
  • An app pops up each time I scan the tag saying that the tag is empty, what should I do?
    Either write to the tag so it does something else, or install this http://xdaforums.com/showthread.php?t=2474379
  • How do I configure Tasker?
    An intent is broadcasted as of version 1.9.5 that can be picked up by apps like Tasker.
    Just configure the app to receive the intent with action "android.nfc.action.TAG_CHANGED". The intent has two extras:
    "tag_uuid": type String, this extra holds the tag ID
    "tag_present": type boolean, this extra is true when the tag is detected, and false when it's lost.
    These extras can be used in Tasker by using the variables %tag_uuid and %tag_present​
 
Last edited:

dtekkt

Senior Member
Sep 16, 2010
616
299
Vienna
Samsung Galaxy S20 FE
Great, works as advertised. Only two things then it would be perfect:
Allow to disable the NFC tag sound and vibration, it's very annoying

Gesendet von meinem C6903 mit Tapatalk 4
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Great, works as advertised. Only two things then it would be perfect:
Allow to disable the NFC tag sound and vibration, it's very annoying

Gesendet von meinem C6903 mit Tapatalk 4

Done
vmTGFEJl.png


My device doesn't vibrate when using NFC, so I couldn't find out where that happens :/
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Thanks, works perfect without this annoying sound :thumbup: I could send you my NFC apk, I am using a xperia Z1. If it doesn't work out, doesn't matter as long as that annoying sound is gone :D

Gesendet von meinem C6903 mit Tapatalk 4

You could, or just wait it out. I'll be getting the Z1 when it reaches Israel.

Sent from my Samsung Galaxy S4 (GT-i9500) using Taptalk 4
 

glimmling

Senior Member
Jan 27, 2011
245
109
tuetenmensch.blogspot.com
Hello,

The module is crashing for me, when I want to authorize a NFC tag.
My device is a LG Optimus L7 II P710
Please have a look at the following logcat:

build.board: 7x27
build.bootloader: unknown
build.brand: lge
build.cpu_abi: armeabi-v7a
build.cpu_abi2: armeabi
build.device: vee7e
build.display: JZO54K
build.hardware: vee7
build.host: android-5pm-server-03
build.id: JZO54K
build.manufacturer: LGE
build.model: LG-P710
build.product: vee7e_open_eu
build.radio: unknown
build.serial: 530b90b9
build.tags: release-keys
build.time: 1373443135000
build.type: user
build.user: goodluck
version.codename: REL
version.incremental: P71010e-EUR-XX.1373443047
version.release: 4.1.2
version.sdk_int: 16

10-12 12:24:12.129 I/ActivityManager(9185): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=pk.qwerty12.nfclockscreenoffenabler/.NFCLockScreenOffEnablerActivity bnds=[128,254][236,377] u=0} from pid 15338
10-12 12:24:12.729 I/ActivityManager(9185): Displayed pk.qwerty12.nfclockscreenoffenabler/.NFCLockScreenOffEnablerActivity: +550ms
10-12 12:24:14.769 I/ActivityManager(9185): START {cmp=pk.qwerty12.nfclockscreenoffenabler/.NfcTags u=0} from pid 16988
10-12 12:24:15.119 I/ActivityManager(9185): Displayed pk.qwerty12.nfclockscreenoffenabler/.NfcTags: +266ms
10-12 12:24:17.349 I/ActivityManager(9185): START {act=android.nfc.action.TECH_DISCOVERED flg=0x20000000 cmp=pk.qwerty12.nfclockscreenoffenabler/.NfcTags (has extras) u=0} from pid -1
10-12 12:24:17.349 W/ActivityManager(9185): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.nfc.action.TECH_DISCOVERED flg=0x20000000 cmp=pk.qwerty12.nfclockscreenoffenabler/.NfcTags (has extras) }
10-12 12:24:17.379 E/AndroidRuntime(16988): at pk.qwerty12.nfclockscreenoffenabler.NfcTags.createAskForNameDialog(NfcTags.java:236)
10-12 12:24:17.379 E/AndroidRuntime(16988): at pk.qwerty12.nfclockscreenoffenabler.NfcTags.onNewIntent(NfcTags.java:189)
10-12 12:24:17.399 W/ActivityManager(9185): Force finishing activity pk.qwerty12.nfclockscreenoffenabler/.NfcTags
10-12 12:24:17.939 W/ActivityManager(9185): Activity pause timeout for ActivityRecord{42cd0128 pk.qwerty12.nfclockscreenoffenabler/.NfcTags}
10-12 12:24:20.479 W/InputDispatcher(9185): channel '42efb928 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NFCLockScreenOffEnablerActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
10-12 12:24:20.479 E/InputDispatcher(9185): channel '42efb928 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NFCLockScreenOffEnablerActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
10-12 12:24:20.479 W/InputDispatcher(9185): channel '4318fbc8 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NfcTags (server)' ~ Consumer closed input channel or an error occurred. events=0x9
10-12 12:24:20.479 E/InputDispatcher(9185): channel '4318fbc8 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NfcTags (server)' ~ Channel is unrecoverably broken and will be disposed!
10-12 12:24:20.479 W/InputDispatcher(9185): Attempted to unregister already unregistered input channel '42efb928 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NFCLockScreenOffEnablerActivity (server)'
10-12 12:24:20.479 I/ActivityManager(9185): Process pk.qwerty12.nfclockscreenoffenabler (pid 16988) has died.
10-12 12:24:20.479 I/WindowState(9185): WIN DEATH: Window{42efb928 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NFCLockScreenOffEnablerActivity paused=false}
10-12 12:24:20.489 W/InputDispatcher(9185): Attempted to unregister already unregistered input channel '4318fbc8 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NfcTags (server)'
10-12 12:24:20.489 I/WindowState(9185): WIN DEATH: Window{4318fbc8 pk.qwerty12.nfclockscreenoffenabler/pk.qwerty12.nfclockscreenoffenabler.NfcTags paused=false}
10-12 12:24:20.489 W/ActivityManager(9185): Force removing ActivityRecord{42af7238 pk.qwerty12.nfclockscreenoffenabler/.NFCLockScreenOffEnablerActivity}: app died, no saved state


Thank you!
 

tripex2k

Senior Member
Apr 16, 2011
114
37
Villingen-Schwenningen
I tried to get it working with several NFC tag stickers, keychain chips and id cards, but well, nothing really works to get it to unlock my HTC One. I run the ViperOne 2.7 rom with Exposed framework and wrote the pin as text to the cards for testing and enabled a pinlock. Any ideas what could be wrong? Which infos do you need.
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
Hello,

The module is crashing for me, when I want to authorize a NFC tag.
My device is a LG Optimus L7 II P710
Please have a look at the following logcat:

Thank you!

The logcat you posted seems to lack the first line in the crash, which has the word Exception in it and/or Caused by. Can you crash the app again and post another logcat?

Sent from my Samsung Galaxy S4 (GT-i9500) using Taptalk 4
 

MohammadAG

Inactive Recognized Developer
Sep 7, 2009
1,080
5,504
30
Jerusalem
mohammadag.xceleo.org
I tried to get it working with several NFC tag stickers, keychain chips and id cards, but well, nothing really works to get it to unlock my HTC One. I run the ViperOne 2.7 rom with Exposed framework and wrote the pin as text to the cards for testing and enabled a pinlock. Any ideas what could be wrong? Which infos do you need.

A logcat would be enough. Also if you could please post a deodexed copy of android.policy.jar.

Sent from my Samsung Galaxy S4 (GT-i9500) using Taptalk 4
 

08BajaBoy

Senior Member
Aug 23, 2012
53
16
Downey
I can't install version 1.9. it gives me a message saying "An existing package by the same name With a conflicting signature is installed." Should I delete 1.1 and install 1.9?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 44
    Requires Xposed Framework!

    This module is based off qwerty12's NFCLockScreenOffEnabler, coupled with madfish73's modifications.

    The Moto X had a feature called the Motorola Skip, a $20 NFC tag that unlocks your device.
    (Speaking of the Moto Skip, here's a tutorial by @Mikegrmn on how to make a similar tag)
    This Xposed module imitates that, while giving a bit more freedom as it also works with the screen off, and with any NFC tag.

    Screenshots:
    ewabYoCl.png
    GJ1zqCYl.png


    Compatibility:
    Any 4.0-4.4 NFC-equipped device that can run Xposed Framework.

    Download:
    http://repo.xposed.info/module/pk.qwerty12.nfclockscreenoffenabler

    Source code:
    https://github.com/MohammadAG/NFCLockscreenoffEnabler

    Credits:
    • qwerty12 for original module.
    • madfish73 for tag lost support
    • rovo89 for the Xposed Framework
    • Niek Haarman for ListViewAnimations, initially I wanted the NFC tag list animated but it was unnecessary overhead, I kept support for swiping to delete tags though.
    • Roman Nurik for his UndoBar implementation.

    Reason for fork:
    I spent a lot of time researching how the lockscreen works so I could bypass the user's code without actually storing the code somewhere, and even when that was done, my implementation was insecure and left a big security hole, I also spent some time looking for ways to secure that which I've come up with. An explanation of how it was secured can be found here.
    In any case, when I decided to post my work in that thread, it was because I felt I shouldn't fork another version of the module. However, 2 days later, I feel that it got buried in the thread with no one knowing about it, so I emailed qwerty12 and asked him if I could make a thread about the module with all the updates.

    Suggestions?
    I feel like the name and icon could be changed, if anyone has suggestions, feel free to reply with them down below :)

    FAQ
    • This module isn't installing, it's saying something about signatures!
      Due to this being a fork, and no one can share their signatures, you're going to have to uninstall all previous versions prior to installing this.​
    • This module isn't working, what's wrong?
      Do you have Xposed Framework installed? Installing the Installer app isn't enough, you need to hit Install/Update it in. After that, you'll have to tick the module to enable it and soft reboot. If the module still doesn't work, turn on debug mode and attach a logcat after a reboot.​
    • I did what the question above said, I still can't unlock my phone using NFC!
      Have you authorized the tag? See this video by @subzero2000 to know how to do that http://www.youtube.com/watch?v=5ix-5utZwAY
      If you can't authorize the tag as in the video, someone (probably me) messed up somewhere, refer to http://xdaforums.com/showpost.php?p=46950451&postcount=101 to help us debug the problem.
      If you can authorize a tag, but still can't unlock, your manufacturer did something to the lockscreen that's very far from stock Android. Leave a comment and we'll try to help. Alternatively, ask a developer for your device to have a look at it.​
    • An app pops up each time I scan the tag saying that the tag is empty, what should I do?
      Either write to the tag so it does something else, or install this http://xdaforums.com/showthread.php?t=2474379
    • How do I configure Tasker?
      An intent is broadcasted as of version 1.9.5 that can be picked up by apps like Tasker.
      Just configure the app to receive the intent with action "android.nfc.action.TAG_CHANGED". The intent has two extras:
      "tag_uuid": type String, this extra holds the tag ID
      "tag_present": type boolean, this extra is true when the tag is detected, and false when it's lost.
      These extras can be used in Tasker by using the variables %tag_uuid and %tag_present​
    17
    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
    13
    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
    5
    So, here are some pictures I took while making my fake skip clip. Cost is about $1 for the NFC tag, $2 for the felt pieces (you should get about 5 skip clips out of them). The magnets were lying around. I bought a computer mouse some time ago, and the packaging had a neat little cardbox flap that was held in place with the magnets. Any magnets that are strong enough to hold the skip clip together through the felt and some clothing (like the pockets of your trousers) should do.


    IMG_20130831_191632.jpg
    These are all parts you need. The round shiny thingies are the magnets. I used only one of them for the part that sits outside my pants pockets, and two on the inside. This provides more adhesion when clipped together. Depends on what kind of magnet you have.

    IMG_20130831_194341.jpg
    These are the pre cut felt clips. If your magnets aren't round, just cut the felt accordingly. Don't forget to let some leeway around the magnet as you need some space where you can put the stitches to hold everything together.

    IMG_20130831_195805.jpg
    This is how the pieces come together. I stickied the NFC chip on the black felt cut out right above the magnet that is sitting on the green felt. Make sure that the position of the NFC chip is so that it sits completely on the outer side of your pocket and only has one layer on felt on top. I don't know how much layers NFC could take to still work.

    IMG_20130831_203205.jpg
    This shows the first stitch and how the pieces come together again.

    IMG_20130831_204306.jpg
    To make sure the magnet doesn't move around too much, I also stitched above the magnet through the whole width of the felt stripe to create a kind of pocket for the magnet. You maybe could also just glue the magnet on, but gluing felt usually makes the felt stiff.

    IMG_20130831_210205.jpg
    The final "product" stretched out. You can feel where the tag is. This is important so you don't clip the thing on with the tag inside your pocket. Like I said before, I don't know how many of layers of felt/pocket NFC still works through. Maybe I'll put a mark with some stitches on the correct side some time in the future.

    IMG_20130831_210513.jpg
    The final "product" again, this time clipped together.
    Just clip it on your trousers pocket, or jacket, or ...

    Have fun.
    Please press thanks if you like it.

    Once I make a complete instructable out of it, I may also include how to set up everything with xposed and such. I'll put a link to instructables should I post it as instructable.
    5
    Great, works as advertised. Only two things then it would be perfect:
    Allow to disable the NFC tag sound and vibration, it's very annoying

    Gesendet von meinem C6903 mit Tapatalk 4

    Done
    vmTGFEJl.png


    My device doesn't vibrate when using NFC, so I couldn't find out where that happens :/