Reputation: 6209
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.
Upvotes: 1
Views: 8998
Reputation: 806
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!
Upvotes: 1