当前位置: 代码迷 >> 综合 >> adb unlock
  详细解决方案

adb unlock

热度:71   发布时间:2024-01-09 16:09:20.0

当通过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