How to check if screen lock is enabled in the settings using adb

半腔热情 提交于 2021-01-29 06:13:52

问题


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

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 ON or OFF
    • 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 Locked
    • mScreenState=ON_LOCKED -> Screen ON and Locked
    • mScreenState=ON_UNLOCKED -> Screen ON and Unlocked


来源:https://stackoverflow.com/questions/55467920/how-to-check-if-screen-lock-is-enabled-in-the-settings-using-adb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!