概述
工作中要对测试机进行一些操作时,首先需要判断当前手机所处的状态(黑屏、亮屏锁定、解锁)以便选择相应的操作
实现
首先通过adb shell dumpsys power | find "Display Power: state="来获取手机当前为黑屏还是亮屏
···
C:\>adb shell dumpsys power | find "Display Power: state="
Display Power: state=OFF
···
然后通过adb shell dumpsys window policy | find "isStatusBarKeyguard"来判断是否锁定,true值为锁屏,false为解锁
```
C:\>adb shell dumpsys window policy | find "isStatusBarKeyguard"
mStatusBar=Window{71c9ed7 u0 StatusBar} isStatusBarKeyguard=true
```
参考文章:https://blog.csdn.net/u012700515/article/details/80404235