1

I would like to be able to query, via my application, whether or not the user has enabled a password or pin on their lock screen. How can I go about doing this?

I've looked into How to detect if PIN/password/pattern is required to unlock phone? but this only seems to tell me whether the device has a pattern lock screen. I'd specifically like to know if the user has enabled something more secure, e.g. a pin or password. (I would be ok if it returned true for all of these cases, but it actually returns false in the case where the user has a numeric PIN or alphanumeric password, but not a pattern lockscreen).

I'm thinking I could use the Device Management API, but I'm not entirely sure how to go about setting this up. Moreover, this seems to be targeted at developers of enterprise-level applications, who want to enforce certain policies on their clients. I'm a small app developer, and because it has security ramifications on what I'm doing, I'd just like to be able to detect if a user has already enabled these features.

Community
  • 1
  • 1
jwir3
  • 6,019
  • 5
  • 47
  • 92
  • Check out my updated answer on the other SO question you link too http://stackoverflow.com/a/27801128/236743 :) – Dori Jul 03 '15 at 16:11

1 Answers1

1

This "Stackoverflow: Check for lock" link can help you out with using the Device Management API. It's odd that there's only direct support for pattern lock screen recognition, but nothing I've found suggested otherwise.
The link below also has a link to a grepcode page, which could further help you out. The most recent answer shows that you basically do a getLong() to get the value of the security settings. From there, you simply run whatever code you planned on running, based off of the number you get back!

Community
  • 1
  • 1
Steven_BDawg
  • 796
  • 6
  • 21
  • I did see this page once prior to writing this question. What sucks about this is that I haven't been able to get it to work on either ICS devices (non-rooted) or KK 4.4 devices (rooted). It always seems to return 1 (LockType.NONE_OR_SLIDER), even if the lock is set to use a PIN. – jwir3 Feb 06 '14 at 21:12
  • 1
    Also, the GrepCode page isn't really useable, because it seems to be hidden in the current android release (i.e. I'd need to compile my own SDK, which isn't an option). – jwir3 Feb 06 '14 at 21:13
  • Hm, so I was able to find the following: http://developer.android.com/reference/android/app/KeyguardManager.html#isKeyguardSecure%28%29 The problem still exists, though, because I'd like to be able to use this on API < 16 (namely API 14), but it's not supported until API 16. So, is there another way? – jwir3 Feb 06 '14 at 22:43
  • Potential solutions seem to point to there being no real other way currently unless the device is rooted perhaps. :/ – Steven_BDawg Feb 17 '14 at 21:11