Is there a way to check if Android device screen is locked via adb?

前端 未结 8 1314
迷失自我
迷失自我 2020-12-10 08:04

I know that PowerManager and/or KeyguardManager can help me check if a device screen is locked/unlocked. Is there a way to check this via adb?

8条回答
  •  甜味超标
    2020-12-10 08:18

    This works only when device has NFC:

    # returns one of: mScreenState=OFF|ON_LOCKED|ON_UNLOCKED
    adb shell dumpsys nfc | grep 'mScreenState='
    

    OFF - Screen off

    ON_LOCKED - Screen displays locked screen

    ON_UNLOCKED - device unlocked

提交回复
热议问题