How to Unlock Android Phone Through Adb

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

Where

  • XXXX is your passcode.
  • 66 is keycode of button OK.
  • adb shell input text XXXX will enter your passcode.
  • adb shell input keyevent 66 will 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

Use 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 mHoldingWakeLockSuspendBlocker and mHoldingDisplaySuspendBlocker:

adb shell dumpsys power | grep 'mHolding'

If both are false, the display is off.

If mHoldingWakeLockSuspendBlocker is false, and mHoldingDisplaySuspendBlocker is true, the display is on, but locked.

If both are true, the display is on.



Related Topics



Leave a reply



Submit