[Redmi K20 Pro / Xiaomi Mi 9T Pro Guides, News, & D] ionflux:
I realize that there's no howto guide yet on this forum. To a new Xiaomi device user, this can be daunting.

This is my guide on how I flashed my China Redmi K20 Pro and fixed Google Pay.

I am NOT responsible for whatever happens to your device as a result of following the below instructions.

At all times remember to download only the ones applicable for the China version i.e. recovery, ROM.

EXTRA:: New phone out of the box and waiting for bootloader unlock?

Install Google Play. Some of the download links in the thread are outdated so it is best to go to apkmirror.com to search, download and install them.

1) In order to flash any custom ROM, the bootloader must be unlocked

Xiaomi locks this by default on all devices. You must unlock it before proceeding to next steps, or you will brick your device. If it's bricked, try this or read the last section of this post.

i. Check Mi lock status from Developer Options. To enable Developer Options, go to Settings -> My Device -> All Specs -> tap on MIUI version. The Developer Options will appear in Settings -> Additional Settings eventually after about 7 taps.

The unlock time can take anywhere from 2 days to 30 days. You can check the timer in step 1vi. You no longer need to apply to Xiaomi to unlock the bootloader.

ii. Download the miflash_unlock_en_3.3.827.31. Extract the zip and run miflash_unlock.exe

iii. On the computer, sign in to the same mi account that's being bound to your phone.

iv. Send the phone to fastboot mode (power down, then power button + volume down button at the same time until the android picture appears).

v. Connect the phone to the computer by USB.

vi. On the computer, attempt to proceed to unlock. It will show you the number of hours left that you need to wait before the phone can be unlocked. Try again after that.

2) Bootloader unlocked

When you try to unlock the phone now (step 1iii - vi), the phone's screen will suddenly change while your mi unlock tool is "verifying" the phone. The tool will say error unlocking. This is normal. On the phone's screen, after progressing about 10% it will appear to reset. Your phone is now unlocked. You can verify the lock status by repeating step 1.

3) Install TWRP custom recovery

You need an Intel (AMD Ryzen seems to be an issue) Windows PC and ADB/fastboot installed. If you don't already, download from here.

There are several recoveries out there, but this one works for me. Download your choice into your PC. When you are done:

i. Open PowerShell (in File Explorer, shift + left click on an empty space) in that folder you downloaded into. If it's a zip, extract to get the .img file.

ii. Send phone into fastboot mode (power down, then vol down button + power button together).

iii. Connect phone to computer.

iv. Type

fastboot devices

into the PowerShell window. On your computer, you will be able to see that the phone is now in fastboot mode.

v. Type

fastboot flash recovery TWRP-3.3.1-0529-REDMI_K20PRO-CN-wzsx150.img

vi. When done, send your phone into TWRP recovery (vol up button + power button together).

Note: You must complete step vi or you will lose TWRP recovery because official ROMs restore to official recovery. If you missed this step, you must repeat from steps 3ii to go into TWRP.

4) Send ROM to your phone. If you have the ROM downloaded into your phone already, you may skip this step

Choose a ROM from the ROM section. For me, I use xiaomi.eu 9.8.22. Direct download link for the lazy.

Continuing in the same PowerShell window, type:

adb devices
adb push "D:\xiaomi.eu_multi_HMK20ProMI9TPro_9.8.22_v10-10.zip" /sdcard/

Replace D:\...... with the full path to the downloaded ROM. The file transfer may take some time. Wait for the PowerShell window to finish the executing command. It took 320 seconds for me.

5) Flash the ROM

For a clean ROM install, be sure to wipe the data, Dalvik and cache partitions. It is called a dirty flash if you wipe only Dalvik and cache.

i. On your phone while still in TWRP, go to Wipe -> Advanced Wipe -> select Dalvik / ART Cache and Data partitions. DON'T choose the FORMAT DATA or wipe any other partition.

ii. Select Install, then choose the ROM and swipe to start the flash. Alternatively, you can also run the same by continuing in the PowerShell window:

adb shell twrp install /sdcard/xiaomi.eu_multi_MI9_9.8.22_v10-10.zip

iii. When done, select "Reboot System". The first startup will take some time (maybe 3 minutes). You may disconnect the cable from the computer now.

6) Congrats! You are now using a custom ROM!

7) Set up Google Pay

Last tested and still working on 29 August 2019.

There's still one last obstacle. It seems that even though we can pass SafetyNet, Google Pay still doesn't want to work.

a) Make sure Google Pay app has already been installed and run once.

b) Install Magisk Manager

i. Open the App and then download the Magisk zip file.

ii. Send the phone into recovery. Power down the phone, then power button + vol up button at the same time.

iii. Select the Install menu, then select the Magisk zip file and slide to confirm flash. When done, select "Reboot to system".

c) Open Magisk App, then under Downloads, find and install

Busybox for Android NDK

and

SQLite3 for ARM aarch64

. Reboot phone.

d) Download the GPay SQLite Fix (more reading here)

Which version to use? It depends on how you want the fix:

Fix stays even if Magisk is uninstalled - use v1.5

To uninstall later, use Termux, type in the following:

su
chattr -i /data/data/com.google.android.gms/databases/dg.db

Grant superuser to the App when prompted.

Fix is uninstalled together when Magisk is uninstalled - use v1.7

e) Open Magisk app, go to Modules, press on the + button to custom select a module. Select file manager, then browse to the downloaded zip file. When done flashing, reboot phone. You can begin to setup contactless payment next.

If you used v1.5, you may uninstall Magisk now.

TIP: You need to change the NFC method if you want to use Google Pay.

Under Settings, go to Wireless & Networks -> More -> Secure element position -> Use HCE Wallet.

Help! It keeps rebooting into TWRP and never into my ROM!

I hope you never end up needing this. But if it did happen:

a) Download and install MIUI ROM Flashing Tool from MIUI.com. Guide is also available in the page.

b) Download a fastboot ROM from here example: China V10.3.8.0PFKCNXM Fastboot.

c) Unzip into a directory with no space in between:

D:\Redmi K20 Pro\fastboot - NOT OK
D:\Redmi_K20_Pro\fastboot - OK

d) Send phone to fastboot mode (power down, then vol down button + power button together).

e) Connect phone to computer

f) Open the MIUI ROM Flashing Tool. Browse to the directory where you had extracted the file e.g. D:\Redmi_K20_Pro\fastboot\raphael_images_V10.3.8.0.PFKCNXM_20190601.0000.00_9.0_cn

The program always defaults to "clean all and lock". This option will install the official ROM and lock the bootloader.

Make sure to change to "clean all" to keep the bootloader unlocked.

g) Press "refresh" to confirm your phone is listed and then press "flash" when you are ready.

The flashing process will take several minutes. Do not disconnect the cable.

The program will show "success" under result.

Your phone will automatically boot into the official ROM.

You may then repeat step 3 Install TWRP custom recovery.