Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
886 views
in Technique[技术] by (71.8m points)

api - What's the difference between isDeviceLocked and isKeyguardSecure in android's KeyguardManager?

Below is excerpted from http://developer.android.com/reference/android/app/KeyguardManager.html

public boolean isDeviceLocked ()

Returns whether the device is currently locked and requires a PIN, pattern or password to unlock. Returns true if unlocking the device currently requires a PIN, pattern or password.

public boolean isKeyguardSecure ()

Return whether the keyguard requires a password to unlock. Returns true if keyguard is secure.

What's the difference between isDeviceLocked and isKeyguardSecure?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

public boolean isDeviceLocked ()

This method takes the current UI state of the Lockscreen into account.

So if a secure Screen Lock has been setup, it will contrary to isKeyguardSecure() return false if:

  • The user has unlocked the Lockscreen and is using the device
  • The Smart Lock feature (Settings -> Security -> Smart Lock) allows the device to be unlocked without further authentication

public boolean isKeyguardSecure ()

This method does NOT take the current UI state of the Lockscreen into account.

So if a secure Screen Lock has been setup, it will always return true, regardless of if the Lockscreen has been unlocked by the user or if Smart Lock allows unlock without further authentication.

I was not able to reproduce the behavior reported by ByteHamster btw.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...