How to Unlock Your Android Phone Through ADB

How to Unlock Your Android Phone Through ADB

22 April 2024 Stephan Petzl Leave a comment Tech-Help

It can be quite frustrating when your Android phone’s screen stops working. Whether it’s a broken screen or a non-responsive touch input, you might find yourself unable to unlock your phone. Fortunately, if you have USB debugging enabled on your device, you can use Android Debug Bridge (ADB) commands to bypass the lock screen and regain access to your device.

Unlocking Your Phone with ADB

If you’re trying to unlock a phone with a simple lock (like a swipe or a pattern), you can use the ADB command:

adb shell input keyevent 82

This command simulates the menu key press which can help in bringing up the lock screen. If you have a passcode or a PIN, you’ll need to enter it as well:

adb shell input text XXXX && adb shell input keyevent 66

Replace XXXX with your actual passcode. After entering the passcode, the command adb shell input keyevent 66 simulates pressing the Enter or OK button.

Step-by-Step Guide to Unlocking Your Android Phone

  1. Connect your phone to the computer via a USB cable.
  2. Open a command prompt or terminal on your PC.
  3. Enter the command adb devices to ensure your device is properly connected.
  4. If your device is listed, proceed with the unlocking command based on your lock type.

Unlocking a Phone with a PIN or Password

For phones protected with a PIN or password, use the following commands:

adb shell input text XXXX && adb shell input keyevent 66

Make sure to replace XXXX with your actual PIN or password.

Unlocking a Phone with a Swipe Pattern

If your phone uses a swipe pattern, you can simulate the pattern by using swipe commands. For example:

adb shell input touchscreen swipe 930 880 930 380

This command swipes from the bottom of the screen to the top. The coordinates may vary based on your device’s resolution.

Alternative Solutions

If you’re unable to unlock your phone using the above methods, there are alternative tools that can help:

  • scrcpy: This application provides display and control of Android devices connected via USB (or over TCP/IP). It does not require any root access.
  • Vysor: A Chrome app that mirrors your Android screen to your computer. You can control your device with your mouse and keyboard.
  • USB OTG Cable and USB Mouse: By connecting a USB mouse to your phone, you can simulate touch input to unlock the phone.

Introducing Repeato

While unlocking your phone is essential, ensuring your apps work flawlessly is equally important. Repeato is a no-code test automation tool that allows you to create, run, and maintain automated tests for your apps on iOS and Android. It’s fast, works with all sorts of app frameworks, and utilizes computer vision and AI for precise test automation.

For developers and testers dealing with ADB commands, Repeato comes with ADB onboard, allowing you to execute ADB commands via “script steps” efficiently. This can be particularly useful when automating tasks such as unlocking devices, setting up testing environments, or managing multiple devices.

Learn more about how Repeato can streamline your app testing process by visiting our product comparison page.

Like this article? there’s more where that came from!