The situation when you have forgotten the pattern key or PIN code on your smartphone is one of the most stressful for any user Android. In a panic, many people immediately rush to perform a hard reset, not even suspecting that this will lead to the complete loss of all photos, contacts and important documents. However, if your device was previously connected to a computer and USB debugging was activated on it, there is a real chance to restore access to the system while retaining all information.

In this article we will examine in detail the technical methods of bypassing the screen lock using a personal computer. The main emphasis will be on the use of tools Android Debug Bridge (ADB)that allow you to interact with the operating system at a deep level. It is important to understand that the success of the operation directly depends on the version of Android and the preliminary security settings that were enabled before the blocking.

The process of restoring access requires care and strict adherence to instructions. Any incorrect action when working with system files can lead to unstable operation of the device, so we strongly advise you to carefully read each step before performing it. Below are proven action algorithms for various blocking scenarios.

Checking prerequisites and compatibility

Before taking active steps, you need to critically evaluate the condition of your device. The main question that needs to be answered is: was the “For Developers” menu enabled USB debugging before the screen locked? Without this parameter, most software methods for removing the key via a PC will be useless, since the computer simply will not have rights to control the smartphone.

It is also worth considering the version of the operating system. On older versions Android (before 5.0 Lollipop), deleting the key file was a trivial task. On modern versions, such as Android 12 or Android 13, the security system is much more sophisticated, and key files can be encrypted or tied to a hardware security module. TrustZone.

If you have never connected your phone to this particular computer before, the system may ask for debugging confirmation directly on the smartphone screen. Because the screen is locked, you won't be able to click Allow. In this case, this method, unfortunately, will not work, and you will have to look for alternative ways to solve the problem.

⚠️ Attention: If, after several unsuccessful attempts to enter the key, the device requires you to enter a Google account or shows a wait timer, do not try to guess the code further. This can lead to a complete blocking of the device by the manufacturer's security services.

📊 Was USB debugging enabled on your device before blocking?
Yes, it was definitely enabled
No, I never did
I don’t remember, I think so
I don’t know what it is

Preparing the working environment and installing drivers

To successfully complete the procedure, you will need a high-quality USB cable and a computer running Windows, macOS or Linux. The first step is to install the platform SDK Platform-Tools, which contains the necessary utilities adb i fastboot. They should be downloaded exclusively from the official website of Android developers to avoid the introduction of malware.

After downloading the archive, it must be unpacked into a convenient directory, for example, the root of drive C. Next, you need to install the correct ones USB drivers for your smartphone. For devices of popular brands, such as Samsung, Xiaomi or Google Pixel, drivers are often installed automatically the first time you connect, but in some cases manual installation will be required via Device Manager.

Checking the connection between the PC and the smartphone is carried out via the command line. Connect the device with a cable and enter the command adb devices. If the list displays the serial number of your device with status device, then the connection is established correctly and you can proceed to the next step.

☑️ Preparing tools

Done: 0 / 4

Method for deleting the key file via ADB Shell

This is the most effective method for devices with rights root or on older versions of Android, where the key file is stored in clear text on the system partition. The essence of the method is to directly delete the file gesture.key or password.keythat contains the hash of your graphic design.

First, you need to gain access to the device’s command shell. Enter the command adb shellin the terminal. If the device does not ask for confirmation on the screen (due to previously granted permission), you will be able to access the file system. Next, you will need to go to the directory where the blocking data is stored.

adb shell

cd /data/system

ls

In the list of files, find gesture.key (for a pattern) or password.key (for a PIN code). To delete a file, use the command rm. After performing this operation, the system will not find the file with the password the next time you reboot and will unlock the screen or prompt you to install a new key.

rm gesture.key

reboot

What to do if the file is not deleted?

If when you try to delete you receive a “Permission denied” error, this means that you do not have superuser (root) rights. In this case, this method will not work without first rooting the device, which in itself is difficult to do on a locked screen.

Using the ADB utility to reset security settings

If direct deletion of files is not possible, you can try to change the security settings through the system database. This method works on some devices where the lock settings are stored in a writable database Settings.db or Secure.db.

You can try disabling the password requirement at boot or changing the lock type to “None” using SQL queries via ADB. This requires entering specific commands that change values ​​in system tables. Success depends on how much the device manufacturer has restricted access to these tables for general users.

Try the following sequence of commands, which attempts to reset the failed attempt counter and reset the lock type:

adb shell content insert --uri content://settings/secure --bind name:s:lock_screen_lock_after_timeout --bind value:i:0

adb shell am start -a android.settings.SECURITY_SETTINGS

This approach is less secure than deleting files, but in some cases allows you to access the security settings menu, where you can manually disable the screen lock if the system allows you to do so without re-entering the old one password.

⚠️ Attention: Changing system databases can lead to software failures, such as an endless reboot (bootloop). Before making changes, make sure that you understand the essence of each command entered.

Comparison of unlocking methods and their effectiveness

Not all methods are equally useful for different smartphone models. Below is a table that will help you assess the chances of success depending on the chosen method and the characteristics of the device. This will save time and not waste it on obviously non-working options.

Method Requirements Risk of data loss Efficiency on Android 10+
Deletion gesture.key root access or Android < 5.0 No Low
Reset via ADB command USB debugging enabled No Medium
Find My Device Service Google Account, Internet High (full reset) High
Smart Lock Configured trusted places No Depends on settings

As can be seen from the table, methods that work without data loss become less and less effective with the release of new versions of the operating system. Google is constantly tightening its security policies, closing loopholes that repair technicians have exploited in the past.

💡

If you have a Samsung smartphone with a Samsung Account, try Find My Mobile on their official website. It allows you to remotely unlock the screen without losing data, even if USB debugging has not been enabled.

Alternative options and the Smart Lock function

Sometimes the solution to the problem is not in the plane of complex technical manipulations, but in using functions that you could configure earlier. The function Smart Lock allows you to keep the device unlocked under certain conditions, for example, when it is at home, connected to a Bluetooth headset, or in the owner's pocket.

Try going outside (if home is not a trusted place) or connecting to a known Bluetooth speaker or watch. If a trusted device trigger is triggered, the screen can be unlocked with a simple swipe without the need to enter a pattern. This is the easiest and safest method if it has been previously configured.

It is also worth checking if your phone is tied to a trusted location. Moving the device to another geolocation zone sometimes resets temporary locks or activates Smart Lock mode, allowing you to access the system.

⚠️ Attention: Settings interfaces and menu item names may differ depending on the manufacturer’s shell (MIUI, OneUI, ColorOS). Always check the steps with the latest documentation for your specific smartphone model.

💡

The Smart Lock function is the only software way to bypass the lock that does not require root access and works on the latest versions of Android, but only with prior configuration.

Frequently asked questions (FAQ)

Is it possible to remove a graphic key if USB debugging has not been enabled?

Unfortunately, without USB debugging enabled, software methods via a PC (ADB) will not work, since the computer will not have access to the file system. In this case, the only options left are using the manufacturer's services (for example, Find My Mobile for Samsung) or a full reset via Recovery Mode, which will lead to data deletion.

Will the ADB method delete my photos and contacts?

The file deletion method itself gesture.key via ADB does not affect user data. It only deletes the password entry. However, if you make a mistake in the process and damage other system files, a flashing may be required, which will already lead to data loss. Proceed with caution.

Will this method help on devices with disk encryption?

On modern devices with disk encryption enabled (which is enabled by default on Android 6.0 and above), the encryption key is often tied to your password or pattern. Deleting the key file may make the data inaccessible because the system will not be able to decrypt the userdata section without the correct credentials. In such cases, unlocking without data loss is almost impossible.

What to do if the computer does not see the phone in ADB mode?

Check the USB cable (try another), install the latest drivers for your phone model and make sure that the USB port is working. It is also possible that there is a request for debugging permission on your phone screen, which you cannot confirm due to a block. In this case, the method will not work.

Is using these methods legal?

Using these instructions is only legal if you are the owner of the device or have the owner's official permission to access it. Hacking other people's devices is an illegal act and is punishable by law.