问题
I need to know how to check if any type of screen lock is enabled in the settings part of the device. I need to check this using an adb command (by using adb shell). I also need to know the type of lock applied.
I have tried dumpsys but did not get any success.
I want to know if the screen lock is enabled in the settings even if the device is currently unlocked, just check if any security is there, in any state.
回答1:
Has answered in Is there a way to check if Android device screen is locked via adb? - Stack Overflow and copy to here:
- My Phone:
XiaoMi 9- Android:
10
- Android:
use adb to check status of screen locked
method 1: (universal) use mDreamingLockscreen
- Command:
adb shell dumpsys window | grep mDreamingLockscreen - Output:
mShowingDream=false mDreamingLockscreen=true mDreamingSleepToken=null-> Screen Locked- no matter Screen is
ONorOFF
- no matter Screen is
mShowingDream=false mDreamingLockscreen=false mDreamingSleepToken=null-> Scrren Unlocked
method 2: use nfc (if android has NFC module)
- Command:
adb shell dumpsys nfc | grep 'mScreenState=' - Output:
mScreenState=OFF_LOCKED-> Screen OFF and LockedmScreenState=ON_LOCKED-> Screen ON and LockedmScreenState=ON_UNLOCKED-> Screen ON and Unlocked
来源:https://stackoverflow.com/questions/55467920/how-to-check-if-screen-lock-is-enabled-in-the-settings-using-adb