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 to 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. ADB can help you enter the PIN or draw a pattern to unlock your Android phone.

Note: You can’t 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. 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.

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

Table of Content

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.Open terminal in the platform tools folder
  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.adb devices command in windows powershell
  6. Now that ADB has detected your device, use the following command to proceed.
    adb shell

    adb shell command powershell

  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

    simulate click okay adb shell

  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

    unloack android pin using adb command

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

Unlock Android Phone Using Pattern via ADB

You can easily unlock an Android device with a PIN using ADB commands. However, things get complicated doing the same if you have set a pattern instead. Drawing a pattern with continuous swipe events using commands is difficult. After extensive research, I have found some 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. 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 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. It 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 1920 px 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, 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.

5 Ways to Restore Deleted Contacts on Android

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 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. It lets you control it using your mouse. Vysor is 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

Was this Article helpful?
YesNo