Lock screen without disabling fingerprint

ChesterKing picture ChesterKing · Mar 19, 2017 · Viewed 14.8k times · Source

I have the following problem. I'm trying to make an app that locks the screen. The method via DevicePolicyManager works very well. So far so good. But when I lock my phone with DPM the fingerprint unlocking method is disabling and I have to enter my pattern (or PIN or whatever I set) to unlock the phone. If I lock it the normal way (ie with power button) the fingerprint unlocking works.

So my question is How to lock the screen programmatically and be able to unlock it afterwards via fingerprint?

PS: I have an galaxy s5 mini with marshmallow lineage os

Answer

Ashwin Mothilal picture Ashwin Mothilal · Mar 19, 2017

That is the normal flow. It takes the device to restarted state where the device will ask for a pattern or password. Google have not provided any api for this. You can check any app in PlayStore which has locking feature will behave like this.

Edited: For the below queries you have asked response is shared here

  1. How can a user lock his phone without using the power button (through an app for example) and still be able to unlock it using fingerprint?

    There's intentionally no API for apps to call to lock the device.

  2. Is there a security reason/concern around this?

    Yes, there's a DOS (denial of service) concern if we allow apps to lock the device. Either intentional or accidental (app bug).

Found it here[https://code.google.com/p/android/issues/detail?id=79735#c115]

I think you need to search for how to lock with app shortcut and not with power button. Atleast I could help to this level.