OH HEY, IT'S A OVER-INVOLVED WRITE-UP OF A TASKER PROJECT. YEAH. SHUT UP.
GOAL: To have the phone locked with a strong password while out and about, with unlocking possible either by typing in the annoyingly complex password (duh) or using the magic of NFC. NFC Unlocks need to automatically go from the "Enter Password" screen into fully accessible desktop with no screen input.
NFC Keychain/Stickers (~$10-15)
Stock 4.2.2 (PA and CM should work too)
NFC Task Launcher (Free)
Secure Settings Plugin (Free)
Modified NfcNci.apk (Free)
ES File Exporer (Free)
Step 1: Lockscreen NFC
For the intended behavior, you'll need to activate an NFC tag with the lockscreen on. This isn't stock behavior. Modified APK to the rescue. I used this one. Ideally, you'd have NFC that reads while the phone's screen is off, and this IS possible, but it'll kill your battery. This APK (I think?) will do that if you're nuts. Anyway, you just replace the stock APK with the modified one and delete (or rename, if you're smart) the NfcNci.odex file. I used ES File Explorer, but you can push via ADB or whatever. And there are other APKs in that thread for CM-based mods. In flashable ZIP form too.
NFC can now be read from the lockscreen. Hoorah!
Step 2a: The Tasking Begins
The first part of all this is getting a "turn on the lockscreen while I'm out, turn it off when I'm home setup." Those are EVERYWHERE so I won't go too in-depth. BUT, mine uses Secure Settings not to disable the keyguard, but rather to set and clear a password when leaving and connecting to a safe wi-fi (respectively).
Note: Using "enable/disable" keyguard keeps your password out of any app's hands, but a "disabled" keyguard in tandem with a secure guard (pass, pin, pattern) will shunt you back to the lockscreen if you hit the home soft key or try to choose a notification. Bleh.
Step 2b: The Tasking Returns
For the actual NFC bits, I've got two tasks that handle the dirty work. The heavy lifter is a task called "Bypass" which, through NFC Task Launcher, is triggered by my NFC tags. Bypass does three things. In order:
- Secure Settings Clear Password: Clears the password.
- Secure Settings Disable Keyguard: Removes the "drag to unlock" lockscreen. Doesn't cause the problems mentioned above because it's not secure.
- Set Variable %NeedsLock to 1: Indicates that the password needs to be re-enabled on screen turn-off.
Then, there's the Task that re-secures the device, "Rengage," which is triggered any and all times the screen turns off. I tried having Bypass be timed, but a time-out would just pop the lockscreen back up mid-use, and that sucks. Here's Rengage:
- IF %NeedsLock = 1 THEN Secure Settings Enable Keyguard: Partly so later Bypass commands won't try to disable a disabled keyguard, partly because Bypass won't work on the password screen next time if this step is missing for reasons I don't totally understand.
- IF %NeedsLock = 1 THEN Secure Settings Set Password: Duh.
- %NeedsLock = 0: Clean up.
Note: %NeedsLock is actually set to 0 by all my keyguard-related tasks except Bypass because I don't trust things
Step 3: Awkward Attachments
I programmed two stickers and one keychain all to launch the "Bypass" task. I covered one sticker in tape (to keep goop away from my wrist and because I think the Android droid is DUMB) and taped it to my watchband, put one inside my wallet, and put the keychain on my keys. The result is that I can unlock my phone by holding it to my off-hand wrist (~95% success rate), tapping it to my back pocket (~50%), or tapping it to my keys pocket (~30%). The watchband looks dumb with the sticker taped to it, but it's the easiest and most reliable solution. Sometimes I have to yank up my sleeve, but only sometimes.
Step 4: Be Awesome
Took me way too long to set up (~5 hours total? incl debugging, debugging, and more debugging), but it's awesome to use. Every time. Without fail.
So far this is the most involved Tasker loadout I've put together. Though, in hindsight, it seems super simple. I've got my eyes set on some grander goals, and I wish I had a car so I could turn my old smartphones into wi-fi enabled, auto-downloading dashcams, but *shrug*. Programming again--and for a practical reason--was bliss and I want to dive back in.
In summary: THIS is why I love Android. My phone is awesome because I am awesome. Fuck yeah.