Xiaomi’s smartphone is often stopped from letting its owner in because of a forgotten password, and users often look for ways to recognize the pattern lock, unaware that modern Android security protocols don’t store the code in an open, viewable form. Instead of “learning” the sequence of lines, you need to use the methods of access restoration that are provided by the developers of the MIUI and HyperOS system.
There are several proven ways to solve this problem, from using the Mi Cloud cloud service to performing a full reset via the Recovery menu. The choice of a particular method depends on whether the phone was tied to a Mi Account and whether the Find Device function was enabled before locking. In this article, we will discuss in detail the algorithms for different screen lock scenarios.
Attempting to choose a combination at random can lead to a temporary locking of the interface, after which the smartphone will require a wait of 30 seconds to several hours, which is why it is important to act consistently and use only proven software tools, so as not to turn temporary inconvenience into a complete inoperability of the gadget.
Why it's impossible to just look at the code
Many users mistakenly believe that the pattern lock is stored as a simple text entry in a file system that can be found and read. In fact, modern versions of Android, including Xiaomi shells, use hashing, which means that the system does not store the drawing itself, but its mathematical representation, which cannot be converted back into a visual image.
The file that locks is usually.key and is located in the /data/system partition. The access to this directory requires superuser rights (Root), which a normal locked device does not have, and even if there are Root rights, reading this file will not give a person a sequence of finger movements.
⚠️ Note: Internet programs that promise to “show” a forgotten password in a couple of clicks are 99 percent malware. They can’t bypass Android’s cryptographic protections and only steal your personal data.
The only legal way to “learn” the key is to remember it or use backup authorization methods built into the security system, and if you were hoping to find the magic “show password” button, it’s a disappointment: it doesn’t exist for the sake of protecting user information from intruders.
How does key protection work?
The system compares the picture you entered with the hash amount. If they match, access is allowed. If not, the error counter increases. After 5 errors, the device can require you to log in to the Mi Account or block input for a while.> Reset via the Mi Cloud service (Without losing data) This is the most gentle and effective method, but it only works if certain conditions are met. The device must be connected to the Internet (Wi-Fi or mobile network), and the Find Device function must be activated in the settings. If these conditions are met, you can remotely unlock the screen. To start, you need to go to the official Mi Cloud status. In the list of available actions, select the option "Unlock" (Unlock), the system will warn you that the pattern lock or digital key. PIN-Once confirmed, the lock will be removed from the smartphone screen, and you can set a new combination. ☑️ Check before reset Phone is on and charged Active Internet connection Known password from Mi accountIncluded function "Find device"Executed: 0 / 4 It's important to note that after this procedure, the old lock data is erased, which means you can't "remember" the old key, but you can have full access to all the photos, contacts and apps. If there's no Internet on the phone, this method, unfortunately, won't work until the network is available. An alternative option for devices that are not tied to the Xiaomi ecosystem but have an active Google account is Google’s device search service. The principle of operation is similar to the Mi cloud, but uses the infrastructure of the search giant. This method also requires an active Internet connection on the blocked gadget. Go to android.com/find and log in under the Google account that is the main one on the smartphone. In the list of devices, select your Redmi model or Poco. In the management menu, select the command “Clean the device” (Erase Mivice). However, some older versions of Android (below version 9) had a “Block” feature that allowed you to set a temporary password that replaced the pattern lock. Method Needs Internet Data Saving Needs Mi Cloud account Yes Yes Mi Account Google Find Yes No (most often) Google Account Recovery Mode No No No No No No No ADB (No Yes (theoretically) No It is worth considering that modern versions of Google security and MIUI It's almost impossible to change a password without resetting, so it's better to think of it as a way to remotely clean up if the data isn't critical, or as a backup for older models. Hard Reset via Recovery Menu If cloud services are unavailable, the Internet is off, or you do not remember passwords from accounts, the only reliable option is a complete reset to factory settings (Hard Reset). This procedure will delete all user data, including photos, contacts and apps, but return access to the phone. To enter recovery mode, you need to turn off the smartphone completely. Then pinch the combination of buttons: usually it is Volume Up and Power Button. Hold them until the Mi logo appears, then release the power button, but keep the volume up. In the Recovery menu, the volume buttons (up/down) navigate, and the choice is confirmed by the power button. You need to find the Wipe Data item and select Wipe All Data. The system will ask you to confirm the action by selecting Confirm. ⚠️ Warning: Once reset, the phone will require you to enter a password from a Google account or Mi Account that was previously synced (FRP). If you do not remember these passwords, unlocking the device will be extremely difficult. The deletion process can take 2 to 10 minutes depending on the memory capacity and processor model.Do not interrupt the power of the device at this point, as this can damage the file system and inability to boot the operating system in the future. ADB (There is a method to delete the key file without losing data, but it works only in one case: if the phone was pre-enabled “Debugging by Debugging” USB» (USB If this function was disabled by default, this method will not help. You will need a computer, USB-cable and installed drivers ADB. Connect your phone to your PC, open the command line in the tool folder ADB and type in the shell access command: adb shell. If access is obtained, enter the command to delete the key file. adb shell rm /data/system/gesture.key Once you've done the command, you need to restart the device, and you can type any combination on the lock screen, so the phone has to let the owner in. However, as mentioned earlier, on modern Xiaomi smartphones with enabled protection, this method is often blocked by the security system. If you type in the adb shell command you see a message about a denial of access or the device is not on the network, then debugging is disabled. In this situation, only a full reset through Recovery, described in the previous section. Protection against theft and accounts It is important to understand the security philosophy of Xiaomi. Locking the screen is only the first line of defense. If an attacker tries to reset the phone through Recovery, the protection will turn on. FRP (Factory Reset Protection: Phone will turn into a brick without having to enter your original account. This is to make sure that the stolen phone cannot be reflashed and sold. So if you buy a device with your hands, always demand that you exit all the seller's accounts with you. Otherwise, you risk getting a device that cannot be activated. For owners who are afraid of forgetting access, there is a recommendation to record data from Mi and Google accounts in a safe place. Restoring access to an account through the "Forgot Password" procedure on the manufacturer's website is often faster and easier than trying to hack the phone itself. Frequently Asked Questions (FAQ) Can Xiaomi unlock without losing a photo? The only way to save photos is using the Miset Cloud service, if the device is deleted in advance. What if the phone says "Device locked"? That means activating the security. FRP. You have to enter the username and password from the Google account that was last synced to this device, and without that, you can't legally unlock your phone, and will your fingerprint work instead of your key? Most Xiaomi models require a pattern lock input after the device is restarted or PIN-Biometrics (finger or face) only work after the first successful unlocking of the traditional method. How many times can you enter the wrong key? Usually, 5 attempts are given. After that, the phone is locked for 30 seconds, then for 1 minute, 5 minutes and so on. After many unsuccessful attempts, you may need to log in through a Mi-account.