经过adb命令获取手机是否锁屏状态,能够经过下面指令:
1.adb shell dumpsys window policy^|grep isStatusBarKeyguard
2.adb shell dumpsys window policy^|grep mShowingLockscreenshell
运行第1条命令,获取到结果,以下:
isStatusBarKeyguard=false mFocusedWindow=Window{3c2b801 u0 com.tencent.mm/com.tencent.mm.ui.LauncherUI}
mShowingLockscreen=false mShowingDream=false mDreamingLockscreen=false
运行第2条命令,获取到结果,以下:
isStatusBarKeyguard=true mFocusedWindow=Window{241b4081 u0 StatusBar}
mShowingLockscreen=true mShowingDream=false mDreamingLockscreen=trueui
已解锁状态值:
isStatusBarKeyguard=false
mShowingLockscreen=false
若是出现以上2指令有一条指令输出值空,则取
isStatusBarKeyguard=false
或
mShowingLockscreen=false
做为判断便可。ip
还能够根据以下操做使手机亮屏解锁input
亮屏
adb shell inputkeyevent 26
keyevent 26表示点击powerevent
解锁
adb shell inputswipe 500 50 500 700
swipe 表示滑动,从500,50滑动到500,700sed