本文主要是介绍adb unlock,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
当通过adb链接手机自动化一些任务的时候,我们需要自动解锁手机(也可以不只是密码?)
下面的代码是通过adb解锁手机的代码,仅供参考....
#!/bin/shPASSWORD=1234
STATE_OFF='OFF'
STATE_ON_LOCK='ON_LOCKED'
STATE_ON_UNLOCK='ON_UNLOCKED'if [ $# > 1 ]; then PASSWORD=$1
fistatePhone(){screenState=$(adb shell dumpsys nfc | grep 'mScreenState=' | awk -F= '{gsub(/\r/,"",$2);print $2}')echo $screenState
}lockPhone(){screenState=`statePhone`echo "the state is:"$screenStateif [ $screenState == $STATE_OFF ]; thenecho 'press power'adb shell input keyevent 26sleep 0.5screenState=$STATE_ON_LOCKfiif [ $screenState == $STATE_ON_LOCK ]; thenecho 'swip up'adb shell input touchscreen swipe 930 880 930 380sleep 0.5echo 'enter the password
这篇关于adb unlock的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!