Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE] Use NFC to unlock your phone, Galaxy S3 or other!

OP stealthdave

9th August 2013, 11:43 PM   |  #1  
OP Senior Member
Flag Los Angeles
Thanks Meter: 43
 
134 posts
Join Date:Joined: Jan 2012
UPDATE!!! There's a new XPosed Framework module in town that makes this whole thread obsolete. Check out the new NFC Unlock module, forked from the NFC LockScreenOff Enabler module already used in this project. Way simpler, fewer moving parts to configure, and works well. Check it out. Otherwise, this has been a fun way to learn how to use Tasker! Thanks, all!



Original Post

This is a guide to show you how to set up your phone to be unlocked by an NFC tag. There are several other threads on the subject for various phones and carriers, but it took me several weeks worth of research and testing to come up with something that actually worked on my phone, and this tutorial is the culmination of that effort. In theory, it should work for a wide variety of ROMs (including Stock), phones and carriers, and even survive ROM updates (provided you maintain root), but I have only tested it on a Sprint Galaxy S3 (model d2spr) that is rooted and running CyanogenMod 10.1.

DISCLAIMER! I am NOT responsible for any damage to your phone, loss of data, use of your phone, or spontaneous sharknadoes that may occur if you try these steps! It worked for me, but I make no guarantees that it will work for you! Back up all your data and your ROM, and use this at your own risk!

HARDWARE REQUIREMENTS
  • An NFC capable phone, like your Sprint Samsung Galaxy S3 with Root Access enabled
  • An NFC tag, such as Samsung TecTiles

SOFTWARE REQUIREMENTS
STEP 1: Install the software!
Install all of the software listed above.
Open XPosed Framework and enable the MoDaCo Toolkit OR the NFCLockscreenoffEnabler.apk in the Modules tab

STEP 2: Turn on NFC scanning all the time
Normally, Android only scans for NFC tags when the phone is unlocked. We need to scan for NFC tags when the phone is locked, and in our case, when the screen is off. Open the MoDaCo Toolkit app and check the box to Enable NFC when screen is off under Settings -> Wireless

WARNING!!! Turning on NFC scanning when the screen is off may adversely affect your battery life!

STEP 2 ALTERNATIVE: Turn on NFC scanning at Lockscreen
Open the NFCLockscreenoffEnabler.apk app and select Enable NFC when phone is locked, but the screen is on. This option should be a little easier on your battery. (Thanks to @nacron for finding this!)

STEP 3: Make Secure Settings a Device Administrator
Open Secure Settings and go to the Configuration Menu by tapping the wrench icon in the upper-right hand corner. Once there, check the box next to Device Administrator and select "Activate" on the confirmation screen.

STEP 4: Teach Tasker how to Lock and Unlock your phone
We can either do this the easy way, or the hard way.

Easy Way - Import the Tasks
  1. Download and unzip NFC-Unlock-Tasker-Tasks.zip and copy the enclosed XML files to your phone
  2. Open Tasker and long-press the Tasks tab
  3. Select Import and open the files that you just copied
  4. There is no step 4.

Hard Way - Manually Enter the Tasks
If you don't trust the import function, or just want to learn more about creating tasks in Tasker, you can create the tasks manually.


Open Tasker and select the Tasks tab. Create a new Task by tapping the big "+" sign, name it "LOCK", and add the following actions:
  1. Select Task -> If
    • Under Condition on the LEFT side of the condition, type TRUN (the variable for Tasks Running)
    • Tap the Condition Operator icon (the grey button in the middle) and select Doesn't Match, or !~
    • On the RIGHT side of the condition, type *Unlock*
  2. Under the If statement, select Plugin -> Secure Settings then tap Edit.
    Select Keyguard and set the following options:
    • Select radio button On
  3. Select Plugin -> Secure Settings then tap Edit.
    Select Lock Device and set the following options:
    • Box for Device Admin Enabled is checked
  4. Select Task -> End If

Create a new Task named "Unlock", and add the following actions:
  1. Select Task -> Stop And select the Lock Task that we created earlier.
  2. Select Plugin -> Secure Settings then tap Edit.
    Select Wake Device and set the following options:
    • Wake Type: Screen & Keyboard Lights On
    • Duration: 30 seconds
  3. Select Task -> Wait and set duration to 100 MS
  4. Select Plugin -> Secure Settings then tap Edit.
    Select Keyguard and set the following options:
    • Select radio button On
  5. Select Task -> Wait and set duration to 100 MS
  6. Select Plugin -> Secure Settings then tap Edit.
    Select Keyguard and set the following options:
    • Select radio button Off
    • Check box [b]Run in background (No Notification)

If you run this Task now, you probably won't notice anything different right away. However, if you lock your phone and then unlock it, you'll notice that any security that you had set up is now bypassed. That's why we needed to teach Tasker how to lock your phone, as well.


STEP 5: Teach NFC Task Launcher to Unlock your phone
  • Open NFC Task Launcher and create a new task for NFC named "Unlock Phone".
  • Take your NFC tag and follow the instructions on the screen to write the tag for this task.
  • Add a new Task by tapping the big "+" icon in the upper right corner.
    • Select Category Tasker
    • Check "Tasker Task" and tap "Next"
    • Type "Unlock" in the field next to the magnifying glass icon under Tasker Task and tap "Add to Task"

Congratulations! You can now unlock your phone with your NFC tag! Of course, as we mentioned above, this leaves your phone without any passcode protection that you may have previously enable. Which leads us to our final step...

STEP 6: Teach Tasker to Lock your phone
  • Open Tasker and select the Profiles tab
  • Create a new Profile with the big "+" at the bottom of the screen and select Event
  • Select Display -> Display Off
  • Go back to the Profiles page by tapping the "< Event Edit" icon in the upper left corner.
  • Select the Lock Task that you made earlier

Now when the screen goes off, your phone is secure again.

That's it! My hope is that this tutorial is easy to follow so that anyone who wants to unlock their phone with an NFC tag can get it working. While there are a lot of steps, I tried to make them clear and specifically looked for a method that was flexible enough to allow me to update my phone or even use a different phone with this method, without having to track down a modified NFC.apk for my specific firmware every time I wanted to update.

In regards to how battery life is affected by having NFC turned on all the time, my personal experience shows no appreciable decrease in battery life. I went all day yesterday without charging (about 15 hours) with typical usage for me, which includes 2-3 hours of podcast playback over both wired and bluetooth headphones, occasional GMail and Facebook usage, Solitaire, and 45-60 minutes of phone calls, which is on par with what I was getting before the hack. As with all things, your mileage may vary. If battery life becomes an issue, try the new NFCLockscreenoffEnabler.apk plugin that @nacron found instead of the MoDaCo one which gives you the On At Lockscreen option in addition on Always On. It should save you a bit on battery life.

Many thanks to the authors of the software I used (XPosed Framework, MoDaCo Toolkit Plugin, NFCLockscreenoffEnabler.apk, NFC Task Launcher, Tasker, Secure Settings Plugin), as well as this thread and this web page for giving me the framework to construct this rather elaborate NFC hack.

I would love to hear from others if this works on other phones.

Changelog:
  • 2013-09-05 - Add NFCLockscreenoffEnabler.apk option for NFC on at Lockscreen (thanks @nacron for this!)
  • 2013-08-14 - Changes to the Tasker Tasks that make the lock and unlock functions run a bit more smoothly by avoiding collisions. (i.e., if you're unlocking the phone, it won't try to lock it until the unlock is done.) I've also added easy-to-import XML files for the Tasks, so you don't have to type them in manually anymore!
  • 2013-08-09 - Initial release (can you "release" a process?)
Attached Files
File Type: zip NFC-Unlock-Tasker-Tasks.zip - [Click for QR Code] (1.5 KB, 794 views)
Last edited by stealthdave; 1st November 2013 at 12:28 AM. Reason: - obsoletion
The Following 12 Users Say Thank You to stealthdave For This Useful Post: [ View ]
9th August 2013, 11:45 PM   |  #2  
Senior Member
Thanks Meter: 26
 
115 posts
Join Date:Joined: Jul 2008
Thumbs up
Wow, thanks for the info.
14th August 2013, 10:03 PM   |  #3  
OP Senior Member
Flag Los Angeles
Thanks Meter: 43
 
134 posts
Join Date:Joined: Jan 2012
New instructions and importable task files make getting this set up a whole lot easier! Updates in the OP!

I've attached a cheap NFC tag to my watch wristband, cleverly disguised by gold nail polish, and unlock by NFC is now my preferred unlock method.
Attached Thumbnails
Click image for larger version

Name:	watch-band-nfc.jpg
Views:	1482
Size:	39.7 KB
ID:	2188965  
21st August 2013, 10:13 PM   |  #4  
ZeroManArmy's Avatar
Senior Member
Flag Colorado
Thanks Meter: 105
 
766 posts
Join Date:Joined: Nov 2011
Donate to Me
More
I like this. Posting to keep track of it.
21st August 2013, 10:22 PM   |  #5  
Casen's Avatar
Senior Member
Flag Washington D.C.
Thanks Meter: 22
 
263 posts
Join Date:Joined: Sep 2010
More
Well, as soon as root is found for the DROID MAXX, I will be using this.

Sent from my Nexus 7 using Tapatalk 2
27th August 2013, 07:30 PM   |  #6  
Junior Member
Flag Bucharest
Thanks Meter: 2
 
1 posts
Join Date:Joined: Dec 2011
More
Hello,

After trying this on a Samsung Galaxy S3 Stock 4.1.2 and Slim Bean (worked like a charm), I have found a glitch on the stock firmware. When making a call the screen would go off via the Proximity sensor so <b>Tasker</b> would lock the phone.

So I made a little addon to the following part and the problem stoped:

Original:

STEP 6: Teach Tasker to Lock your phone
  • Open Tasker and select the Profiles tab
  • Create a new Profile with the big "+" at the bottom of the screen and select Event
  • Select Display -> Display Off
  • Go back to the Profiles page by tapping the "< Event Edit" icon in the upper left corner.
  • Select the Lock Task that you made earlier

Modified:

STEP 6: Teach Tasker to Lock your phone
  • Open Tasker and select the Profiles tab
  • Create a new Profile with the big "+" at the bottom of the screen and select Event
  • Select Display -> Display Off
  • Go back to the Profiles page by tapping the "< Event Edit" icon in the upper left corner.
  • Select the Lock Task that you made earlier
  • Select Display off (long-press) -> Add -> State -> Sensor -> Proximity sensor -> Check invert

That's it!

Now when you get a call and answer it Tasker will know that the proximity sensor is used and will not lock the phone
Hope it works for you too.

Thanks,
[/QUOTE]
The Following 2 Users Say Thank You to sebidraghici For This Useful Post: [ View ]
27th August 2013, 07:38 PM   |  #7  
Senior Member
Flag Shaw, MS
Thanks Meter: 75
 
324 posts
Join Date:Joined: Sep 2008
More
Quote:
Originally Posted by stealthdave

New instructions and importable task files make getting this set up a whole lot easier! Updates in the OP!

I've attached a cheap NFC tag to my watch wristband, cleverly disguised by gold nail polish, and unlock by NFC is now my preferred unlock method.

Thats slick man. I may have to use that for myself lol
The Following User Says Thank You to 754boy For This Useful Post: [ View ]
28th August 2013, 01:54 AM   |  #8  
Senior Member
Thanks Meter: 23
 
291 posts
Join Date:Joined: Jun 2010
This is great, thanks man but one problem. When I use my tag to unlock the phone, use the phone then hit the android home button to return to my default screen, it locks the phone instead. If I unlock it normally (Entering PIN) it doesn't display this behavior. What am I doing wrong.
28th August 2013, 04:26 PM   |  #9  
Junior Member
Thanks Meter: 3
 
26 posts
Join Date:Joined: Aug 2013
Deleted
Last edited by LevanG; 29th August 2013 at 12:36 PM. Reason: posted by mistake
28th August 2013, 07:50 PM   |  #10  
OP Senior Member
Flag Los Angeles
Thanks Meter: 43
 
134 posts
Join Date:Joined: Jan 2012
Quote:
Originally Posted by LevanG

Hi, can I use this method to unlock my LG Lucid2?

I want to use it on GSM network...

Wrong kind of "unlock", I'm afraid. This unlocks your screen so that you can bypass the lock screen; it doesn't do anything for carriers locking the phone to their network. Think of this as using an NFC tag as your password.

The Following User Says Thank You to stealthdave For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
android, guide, nfc, root, unlock
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes