[Android] UnlockWatch - mitigate phone pattern/pin guessing

Believe it or not i could not find an app which would reboot phone on certain number of failed unlock attempts. Why would anyone want this? To prevent unlocking encrypted devices of course!

My setup

  1. Phone: galaxy S5 stock rom, rooted and debloated.
  2. Encrypt device.
  3. Set pattern lock.
  4. Set cryptfs password using Cryptfs password manager
  5. Install and run UnlockWatch once, grant permanent root and add as device administrator.


This setup provides you with encrypted device which uses strong password on boot, and pattern (or pin if you choose so) lock to unlock device normally. Three failed pattern (or pin) entries will reboot device and you will have to enter your long and strong password. Application is using android device administrator API and does not need to run in the background. It is very light on resources and reliable. Also note that invalid attempt is counted only if invalid pattern or pin length is at least as long as minimal length enforced by OS.

Other software

While writing this post i discovered SnooperStopper app. It is supposed to do same thing as UnlockWatch + Cryptfs password manager, however setting password did not work on my android 6 and source code is nowhere to be seen.

The good stuff

Source code: https://github.com/rokups/UnlockWatch


I really like the concept, I know Blackberry has something similar. Though their method is a lot more “Slash and Burn” as it will wipe with device after so many failed retries. You should probably also mention that this requires a rooted device as you are calling su.

Something that does bother me is that you are calling reboot directly through su. Maybe I’m just showing my ignorance of Linux, but I know that on Windows its generally not a good idea to call system commands like that as an attacker could hijack the name of the application you are trying to call. If someone could clarify if this is an issue on linux machines as well that would be greatly appreciated.

I don’t think there is anything wrong in this case, your scenario of copying applications and stealing root is possible across the board, that is not just this application.

Yes, forgot about root part. Actually there is bit of a story behind calling su -c reboot. As it turns out android allows only system apps to get reboot capability. Device administrator API got a reboot call, but its on android 7.0 or 8.0. So i had to use su -c reboot to reboot the device.

As for shadowing reboot command to invoke malicious code - if someone can land code on your device then no amount of lock screen magic is going to help.


As for that, I would recommend locking your bootloader as well, you can have an encrypted phone, but somebody could still use ADB and flash a custom application to intercept the password, and then retrieve the phone back and have full access.