[Xiaomi Mi A2 Lite Guides, News, & Discussion] :
The *DEFINITIVE* Guide to get HavocOS (and possibly any GSI) working

Disclaimer:

This tutorial will reset phone to stock before any flashing. However, unlike what user Voodoojonny has been claiming, my first attempt at upgrading I did so from 9.6.9.0 and did not have any issues with WiFi or others. So if you have OFFICIAL TWRP already installed and are on the latest stock version, from my experience there shouldn't be any issues. So just jump on from the post-TWRP install steps.

Prep-work:

Minimal ADB and Fastboot; (this is my go-to for quickly setting up adb for quick usage)

Latest MiFlashTool (If you need to factory reset);

TWRP;

9.6.4.0 Stock image for full factory reset/userdata.img file;

Magisk Download;

Latest Magisk Manager;

GApps for Android 9.0; (I recommend Pico package)

Latest HavocOS Image;

SELinux Manager for Magisk; (file is hosted on my mediafire account since there was no premade zip of the latest version)

And yes, all of these will be used. Don't worry, it's not as bad is it looks :)

Tutorial

Phase 1 Stock+TWRP

Step 1: Extract MiFlashTool and 9.6.4.0 images somewhere that's easy to remember (C:/MiFlashTool or something works fine). Also, install Minimal ADB and Fastboot;

Step 2: Reboot phone into bootloader mode, from the off state that Power+VolDown then connect it to USB;

Step 3: Open MiFlashTool and locate the folder that contains the 9.6.4.0 stock rom. Here, choose flash_all.bat. Do not choose the one with lock on it because that locks bootloader and just creates pain-in-the-ass issues.

Step 4: Play a couple matches of Pong on your browser while phone resets. Anything that isn't a clean sheet victory is not acceptable. Phone will restart when done.

Step 5: Set-up phone quickly. I usually just skip all the steps. Do not set a pattern for encryption or fingerprint.

Step 6: Power-off, Power+VolDown, connect USB. It's TWRP time. Copy the files you downloaded from the TWRP website into the same folder you install Minimal ADB and Fastboot to. It just makes life easier. Open Minimal ADB and Fastboot.

Step 7: Boot into temporary TWRP:

fastboot boot twrp-daisy-3.2.3-0.img

Step 8: Push TWRP installer into phone

adb push ./twrp-installer-daisy-3.2.3-0.zip /sdcard

Step 9: Go to install, choose the zip you just pushed. After the install is done, go back to main menu, reboot back into recovery to make sure it's working. If it is, great! Phase 1 is done.

Phase 2: Actually installing HavocOS/Pie GSI of Your Choice.

Step 10: Copy the HavocOS image you downloaded into the Minimal ADB and Fastboot folder (rename it to HavocOS.img), again this isn't mandatory but makes following my steps easier. Also copy the userdata.img file from the stock rom into the same folder.

Step 11:

fastboot flash system HavocOS.img

You will get a warning but it's perfectly fine. After about 40 seconds you'll get a message saying it's done.

Step 12:

fastboot flash userdata userdata.img

Step 13: Let's boot back into TWRP from the image file.

fastboot boot twrp-daisy-3.2.3-0.img

Step 14: Simply reboot from temporary recovery into actual recovery. DO NOT BOOT THE OS YET.

Step 15: Connect USB and copy Magisk ZIP, Magisk Manager apk and GApps into your phone.

Step 16: Flash GApps and Magisk ZIP into phone. I usually do it in this order, but I don't think it really matters.

Step 17: Reboot into OS :D We're not done yet, but at least you can enjoy some Pie already!

My phone had a weird behavior at this point. It tried to boot once, then rebooted itself, then actually booted successfully into HavocOS. So if your phone randomly reboots the first time it tries to boot, it should be fine. It was for me. Also on boot you'll notice HavocOS has no navigation bar. Drag notifications down, go into settings -> havocOS settings -> navigation bar and activate it.

Phase 3: The Finishing Touches

Step 18: Install the Magisk Manager APK, we need to to give root access to apps.

Step 19: Configure your phone so you can access the Play Store. Don't install anything besides a root file manager since we'll be wiping data.

Step 20: Open the root file manager of your choice and go into /vendor/etc/ and open the fstab.qcom file. Look for the line that says "forceencryption=footer" right at the beginning of the file and change it to "encryptable=footer";

Step 21: Power-off. Power+VolUp and boot into TWRP. It will probably complain about encryption. Hit Cancel, go to Wipe and choose Wipe Data. Once again your internal storage will be wiped. Copy Magisk Manager APK again as well as SELinux Manager module. Reboot back into OS.

Step 22: Boot will take some time because you just Factory Reseted your phone again. When you boot back in, you will have full storage back ;).

Step 23: Install Magisk Manager APK once again, then go into Modules and press +. Locate the SELinux Manager zip and install it.

Step 24: During install you will be prompted to press Vol Up for Enforcing, then Vol Down for Permissive. This will set SELinux to Permissive permanently. Reboot.

Step 25: THERE ARE NO MORE STEPS. YOU'RE WINNER :victory: Set-up your phone any way you want, enjoy a slice of that sweet Android Pie.

Extra Goodie Edition: I'm currently using this version of GCam, seems to be working fine.

I spent too much time doing this, I'm going to bed. G'night folks.