Thanks Meter 316
Join Date: Mar 2010
Location: Leighton Buzzard
DONATE TO ME
[DEV] NFC Unlock
Hi, I've been building my own N5 ROM for a while now but don't have the time to release/maintain/support it plus there are plenty of other options out there that are very similar. BUT, I recently got me an NFC Ring and so wanted to build NFC unlocking into the framework and this is something that currently can only be achieved using an Xposed module so I thought I'd share the code.
First of all, a huge thanks to MohammadAG and qwerty12 for their work on the Xposed module here
as this is what a lot of my changes are based on.
The first thing I did was modify Nfc and Settings apps so you can choose when to enable Nfc Polling...
- Polling off
- Screen off
- Screen on and locked
- Screen on and unlocked
- Screen on and locked only - this is a new mode i've put in that turns Nfc on with the screen and then off again once unlocked. As I only use Nfc on my phone for unlocking, this is really useful as its nice on the battery and doesn't prompt with the empty tag viewer every time i unlock!
Then, using the Xposed module
as a basis for the code I added Nfc unlocking into the framework and Nfc app as well as a new item under Security Settings where you can add/remove tags that are allowed to unlock.
In terms of security:
- the Nfc tag acts as an override to whatever other lock screen you're using, pattern, pin etc.
- The tag contents are only handled if the screen is unlocked. If polling is set to 'screen on and locked' then the tag will be picked up as soon as the device is unlocked but there's no way for an unauthorised tag to have its contents handled while the screen is off or on and locked.
- The unlock is triggered from the Nfc app as an intent, it's probably possible to trigger this intent from elsewhere but the tags uid is checked from within the keyguard while handling it so the uid needs to be known and passed as part of the intent for this to work.
It's all working nicely for me so far but given I'm not massively familiar with the guts of the android lock screen security and creating new UI's, there's probably room for improvement.
So, ROM devs feel free to add this to your ROMs, giving credit where credit is due and let me know of any fixes or improvements either here or as pull requests on my github. The modified repos are here:
Find me on IRC
Nexus 5 32GB Black running AOSP+
ASUS Infinity TF700T running CM11.0
HTC One X+ (with a cracked screen :-/ ) running AOSP+
HTC One X running TripNRaVeR CM10.1 (Bricked into APX mode)
Desire HD running IceColdSandwich
HTC Hero running CronosDroid