Avtansh
Avtansh

Reputation: 11

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

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.

Upvotes: 1

Views: 2473

Answers (1)

crifan
crifan

Reputation: 14328

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

Upvotes: 2

Related Questions