How to unlock android phone through ADB
If you have to click OK after entering your passcode, this command will unlock your phone:
adb shell input text XXXX && adb shell input keyevent 66
XXXXis your passcode.
66is keycode of button OK.
adb shell input text XXXXwill enter your passcode.
adb shell input keyevent 66will simulate click the OK button
Is there a way to unlock android phone via adb, if I KNOW the pattern
This is an old question but in the interest of helping anyone who finds this post, check out my android-pattern-unlock shell script.
It uses ADB's sendevent to draw a known unlock pattern into the lock screen. Worked for me and allowed me to gain access with a broken screen.
Activate/unlock phone via adb shell
adb shell input keyevent 26 to wake up the device. (Source) Now do the text input or whatsoever you want to do. And, unlocking can also be done using
input command but different locks requires different technique, so you'll have to Google a bit, or provide the info here so that I/others can answer it.
The same command can put the device to sleep as well.
Is there a way to check if Android device screen is locked via adb?
This command will output everything relating to power for the device:
adb shell dumpsys power
You can pipe this to a grep to get the values of
adb shell dumpsys power | grep 'mHolding'
If both are false, the display is off.
mHoldingWakeLockSuspendBlocker is false, and
mHoldingDisplaySuspendBlocker is true, the display is on, but locked.
If both are true, the display is on.