[Xiaomi 12 (Global)] C0rn3j:
Notes:​

* I am not a developer.

* I did all of this on Arch Linux, you shouldn't have trouble doing this on either Linux or Windows.

* See the Telegram group if you have issues - search for "Xiaomi 12 OFFICIAL" on TG, unfortunately cannot link directly to it on XDA.

* This is an unofficial version of LineageOS

* Thanks to @gr0ndpa whose writeup I based this guide on.

* Massive thanks to @ArianK16a who actually made LOS work on Xiaomi 12, despite Xiaomi breaking GPL licensing and not providing full kernel sources for Android 12

Prerequisites:​

* Your bootloader must be unlocked. This thread does not cover this.

* You should use latest platform tools on Windows.

* Your device should be charged above 50%. Well, it doesn't have to be, but this is just for your phone's safety.

* Download 4 required .img files - boot, vendor_boot, dtbo and recovery from the latest build that has them all - rest miss recovery/vendor_boot, linking latest one at the time of writing for convenience

* Download latest ROM of your choosing (GMS=with gapps, VANILLA=no gapps) from arian-ota/ota

* If you intend to root the device with Magisk, also download latest boot.img

* Make a proper backup if needed and push it to another storage.

First steps:​

* After you have unlocked the bootloader, device will reboot automatically. Finish the setup, enable developer settings and finally enable USB-Debugging in developer settings.

* In Windows open the folder in which you have unzipped the platform tools.

* Hold left shift and press right click, click "open powershell window here"

* Connect the phone via USB

* Execute the following in Windows Terminal and grant the permissions for this PC on your device:

adb devices

* Execute the following to either reboot to fastboot or fastbootd. Flashing works from either, I used fastbootd:

adb reboot fastboot # fastbootd
adb reboot bootloader # fastboot

The flashing procedure:​

* Flash boot, vendor_boot, dtbo and recovery by executing the following in Windows Terminal:

fastboot flash boot lineage-19.1-20220618-UNOFFICIAL-cupid-boot.img
fastboot flash vendor_boot lineage-19.1-20220618-UNOFFICIAL-cupid-vendor_boot.img
fastboot flash dtbo lineage-19.1-20220618-UNOFFICIAL-cupid-dtbo.img
fastboot flash recovery lineage-19.1-20220618-UNOFFICIAL-cupid-recovery.img

* Finally execute the following, or reboot to recovery by holding VOLUME UP and POWER buttons until you see Mi logo on your device's screen:

fastboot reboot recovery # or bootloader

* If you get MIUI recovery, reboot back to fastboot, you should hopefully get LOS fastbootd now and be able to redo the steps and get LOS recovery next

Sideload the ROM from LOS recovery:​

* ALL DATA WILL BE ERASED WITH THE NEXT STEP

* Go to Factory reset and perform Format data / Factory reset

* Go to Apply update, followed by Apply from ADB

* Execute the following Windows Terminal:

adb sideload lineage-19.1-20220810-UNOFFICIAL-GMS-cupid.zip

* Reboot your device

Rooting:​

* Follow this thread but use the latest boot.img you downloaded earlier instead of the one from stock ROM.

Certification:​

* If you won't fake the build prop to get certified status, you should at least follow Alphabet's instructions to make sure your device does not potentially get blacklisted from Play services

* Certification is required to run some apps - i.e. Netflix, Revolut, ...

* You can view certification state in Play store -> Profile -> Settings -> About -> Play Protect certification. This will cache the status. For a while, how to force the check again is shown down below

* Your device will not be certified on this ROM because it does not attempt to fake build props

* To get known good props for security update date and device fingerprint, you need either a rooted device with MIUI you want to extract the values from by executing the following in root adb shell:

grep -e fingerprint -e security_patch /system/build.prop

Or you can download latest recovery .zip from the download thread and open the file located in it from /META-INF/com/android/metadata in the archive

* Here's an example of the two values needed for my EEA device I got from the recovery zip:

2022-07-01
Xiaomi/cupid_eea/cupid:12/SKQ1.211006.001/V13.0.19.0.SLCEUXM:user/release-keys

* Install the following module through Magisk https://github.com/Magisk-Modules-Repo/MagiskHidePropsConf

* Run the following:

adb shell
su
props
1 # Set the fingerprint to the one you obtained
5 # Add a custom prop with the name ro.build.version.security_patch, it should already exist, but it is most likely wrong

* Install the following module through Magisk

Releases · kdrag0n/safetynet-fix

Google SafetyNet attestation workarounds for Magisk - kdrag0n/safetynet-fix

github.com

* After the final reboot, remove storage of "Google Play Store" app to refresh the cache manually, open Play store and check the status, you should be in the green now

Known issues:​

* Face recognition libraries are not included due to legal reasons, if one is interested in adding them, see the discussion starting here

* Minimum brightness is too bright. This can be mitigated by adding the "Extra Dim" card in the notification menu and long-pressing it to configure your desired intensity.

* When Smooth Display (120Hz) is enabled, screen flashes/redraws when it changes to and from 90Hz. This is more noticeable with lower brightness and no light in the room, and not really noticeable in daylight. Can be triggered by opening settings and typing a word and waiting half a second.

* Netflix(and only Netflix) is not available from the Play store on GSM ROM even with certification. Netflix provides an APK on their website, but that still gives me an unsupported device message. https://help.netflix.com/en/node/57688