How to Unlock Android Phone via ADB (PIN & Pattern) (2024)

A broken touchscreen can make a phone or tablet unusable. You can’t even get past the lock screen. Using ADB might help you unlock it so you can at least access your data by connecting it to a computer. ADB commands can be helpful if you can’t enter the PIN or draw the pattern on your Android device. However, it’s not a practical solution because one can’t always carry a laptop for this purpose alone.

Please note that you won’t be able to remove the pattern or PIN lock on your Android phone using ABD commands. Therefore, if you forgot the PIN or pattern on your device, this tutorial is irrelevant to you. Also, due to the enhanced security on modern smartphones, you cannot bypass the Android lock screen using commands on your computer.

We have some useful tutorials to help users with damaged touchscreen and hardware buttons.

  • Turn on Android Devices without the Power Button
  • Turn off Android Phones without the Power Button

To use ADB via a computer, you must download and set up the latest SDK Platform tools and enable USB Debugging on your phone.

Unlock Android Phone Using PIN via ADB

Having installed ADB on your PC, follow the steps below to unlock an Android device that is locked with PIN protection through ADB commands.

  1. Unzip the ‘platform-tools-windows.zip‘ you downloaded earlier and open the extracted folder.
  2. Place the mouse cursor at an empty spot inside the folder window, press the Shift key, right-click the mouse, and select the ‘Open in Terminal‘ or ‘Open PowerShell window here‘ option to launch the command window.
  3. Connect your Android phone or tablet to your computer using a compatible USB cable.
  4. Type the following command in PowerShell and hit the Enter key to ensure ADB has recognized your Android device.
    adb devices
  5. You’ll see a string of alphanumeric values representing your device. If you get any error, try reconnecting your device or using a different USB cable.
  6. Now that ADB has detected your device, use the following command to proceed.
    adb shell

  7. To wake up your Android phone’s touch screen, use the following command after the $ sign.
    input keyevent 26
  8. Next. type the below command and press the Enter key to execute it. Don’t forget to replace ‘XXXX’ with the PIN or passcode you’ve set for your phone’s lock screen.
    input text XXXX

  9. The above command will unlock your Android device without entering your PIN without touching the screen. However, if you have to press ‘OK‘ after entering the PIN, you’ll need to use one more command to simulate the OK button click.
    input keyevent 66

  10. That’s it! You have successfully unlocked your Android device through ADB commands.

Unlock Android Phone Using Pattern via ADB

While it’s easy to unlock an Android device that is locked with a PIN using ADB commands, things get complicated doing the same if you have set a pattern instead. Drawing a pattern with continuous swipe events using commands is difficult. Upon extensive research about the possible ways to draw a lock screen pattern through ADB, I have found some working solutions that might do the job if followed carefully.

You can use the sendevent commands after invoking ‘adb shell’ to simulate the following actions or finger gestures on your phone’s pattern lock screen:

  1. Start touch (finger down)
  2. New point (finger move)
  3. End touch (finger up)

To perform the above actions to start and end a pattern swipe using ADB commands, you will need the following sendevent commands.
sendevent 3 0
sendevent 3 1
sendevent 0 0 0 # (event separator)

GitHub user Matt Wilson has prepared a script for unlocking the Android lock screen pattern. You can customize this script by changing the variables for the 9-point pattern setup of your Android phone. Needless to say, the Android pattern unlock script requires USB debugging enabled on your device to function properly.

The coordinates or variables of your pattern might differ depending on the resolution (in pixels) of your phone’s screen. Therefore, the hardest part of making this script work is to find the correct variables. There is another piece of code by Marian Schedenig called ADB Control which can help you view the screen of your Android phone or tablet in an output window on your computer. You can thus see the input taps and swipe events, and learn about the variables by clicking on the points of the pattern lock you have set on your phone.

Once you have the set of coordinates for the pattern of your Android device, you can easily replace the values for (x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5). The number of coordinates depends on the points of the pattern you’ve set.

The simplified version of Matt Winson’s script is shared by Haider Khan on Stack Overflow and contains the coordinates for an Android device with a 1080 x 1920px screen. Don’t forget to visit the source page for more information. You can execute the following commands after changing the x and y values that correspond with the pattern of your Android phone to achieve a continuous pattern swipe to unlock your phone using ADB.

adb shell
input keyevent 26
sendevent /dev/input/event3 3 57 14
sendevent /dev/input/event3 1 330 1
sendevent /dev/input/event3 3 53 x1
sendevent /dev/input/event3 3 54 y1
sendevent /dev/input/event3 3 58 57
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 3 53 x2
sendevent /dev/input/event3 3 54 y2
sendevent /dev/input/event3 3 58 57
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 3 53 x3
sendevent /dev/input/event3 3 54 y3
sendevent /dev/input/event3 3 58 57
sendevent /dev/input/event3 0 0 0

sendevent /dev/input/event3 3 53 xn
sendevent /dev/input/event3 3 54 yn
sendevent /dev/input/event3 3 58 57
sendevent /dev/input/event3 0 0 0
sendevent /dev/input/event3 3 57 4294967295
sendevent /dev/input/event3 1 330 0
sendevent /dev/input/event3 0 0 0

I hope the above string of ADB commands helped you unlock your Android phone pattern using cmd.

Remote Control Tools for Unlocking Android Devices

If you can’t use your phone’s touchscreen to input the lock screen PIN or draw a pattern to unlock it, some remote control tools might help you. Please note that these tools require USB debugging enabled on your Android device and your computer authorized to work.

Related posts

How to Get OTA Update after CSC Change on Samsung Devices

Scrcpy

Scrcpy is available for Linux, Windows, and macOS. It allows you to control your phone remotely via ADB. It requires a little app to be installed on your device to stream the contents of your phone’s screen to the computer to control it.

MonkeyRemote

MonkeyRemote is another remote control tool that connects over ADB and lets you control your phone using the computer mouse. Unlike Scrycpy and Vysor, it doesn’t require any app to be installed on the Android device you want to control via PC.

Vysor

Vysor is a great remote control tool that streams your phone’s screen on your computer and lets you control it using your mouse. It’s a web app for Chrome that communicates with your phone via ADB after you install a companion app.

If you know about a better way to unlock an Android phone PIN or pattern lock via ADB, please share it with us so that it can help others.

Read Next: How to Make a Call or Send Messages using ADB Commands

Did this article help you?

YesNo

How to Unlock Android Phone via ADB (PIN & Pattern) (2024)

References

Top Articles
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 5918

Rating: 5 / 5 (50 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.