[Xiaomi Mi A2 Lite Guides, News, & Discussion] BubuXP:
* I'm not responsible for bricked devices, dead SD cards, thermonuclear war, or you getting fired because the alarm app failed.
* Please do some research if you have any concerns about features included in the products you find here before flashing it!
* YOU are choosing to make these modifications, and if you point the finger at me for messing up your device, I will laugh at you.
* Your warranty could be void if you tamper with any part of your device / software.
* Same statement for XDA.

Here's an alternative method to install Magisk that support OTA updates (copied from the Mi A1 forum and expanded :) )

You need a PC with Android platform tools (they exist also for MacOS and Linux). When using Windows, you should also install MiFlash tool to get the required drivers to recognize the device.

BOOTLOADER UNLOCK

First thing to do: unlock the bootloader (if you didn't already do this, obviously). Smartphones with Android One are much easier to unlock compared to other Xiaomi phones with MIUI (where you have to ask for authorization and wait for weeks).

CAUTION: when you unlock the bootloader, the phone will reset, erasing all your saved data. Backup your data before unlocking.

1. Go to Settings > System > About phone > and tap many times on "Build number" until you unlock "Developer options" (on Andoird 9 "About phone" is right at the top of the Settings app).​

2. Go back to the previous page (i.e. Settings > System), where you can find now "Developer options". Go there and enable the "OEM unlocking" option (and it's better to never disable this).​

3. Now you can shutdown your phone, then turn it on while holding the "Volume down" button pressed. Release it when you see the Fastboot screen You can also use the command "adb reboot-bootloader" if you already connected the phone to the PC.​

4. Now connect the phone with your PC via USB cable, open an administrative command prompt, move to the directory where the Android platform tools are placed and unlock the bootloader with the following command:

fastboot oem unlock

The phone will reboot, erasing all the data.​

Now you unlocked your phone's bootloader and can continue to the next section.

MAGISK INSTALLATION

5. Download and install on the smartphone the latest version of Magisk Manager's apk available.

You need the smartphone to be connected to the internet, because Magisk won't install and won't work properly without a connection.​

6. Now you can easily download an already patched boot.img from the following list and jump straight to point 10 of this guide, or you can continue to the next point and learn to patch yourself an original boot.img

If you choose the short way, be sure that you select the patched_boot.img with the same "Build number" currently installed on your phone (see point 1 of this guide), and don't flash the file directly on the phone memory, because Magisk will not work properly (do exactly what this guide says, and you will not find problems, hopefully).

For our convenience, extract the patched_boot.img file in the same directory where Android platform tools are located.

patched_boot 9.6.4.0 (2018 July update) - patched with Magisk 17.1

patched_boot 9.6.6.0 (2018 August update) - patched with Magisk 17.1

patched_boot 9.6.8.0 (2018 September update) - patched with Magisk 17.1

patched_boot 9.6.9.0 (2018 October update) - patched with Magisk 17.1

patched_boot 9.6.10.0 (2018 November 1st update) - patched with Magisk 17.1

patched_boot 9.6.11.0 (2018 November 2nd update) - patched with Magisk 17.1

patched_boot 10.0.2.0 (2018 December upgrade to Android 9.0 Pie) - patched with Magisk 18.0

patched_boot 10.0.3.0 (2019 January update) - patched with Magisk 18.0

In case you erroneously flash those patched files directly on the phone, flash back the original boot.img via fastboot and follow the guide:

original boot.img 9.6.4.0 (2018 July update) - taken from fastboot ROM

original boot.img 9.6.6.0 (2018 August update) - taken from OTA update

original boot.img 9.6.8.0 (2018 September update) - taken from OTA update

original boot.img 9.6.9.0 (2018 October update) - taken from OTA update

original boot.img 9.6.10.0 (2018 November 1st update) - taken from OTA update

original boot.img 9.6.11.0 (2018 November 2nd update) - taken from OTA update

original boot.img 10.0.2.0 (2018 December upgrade to Android 9.0 Pie) - taken from fastboot ROM

original boot.img 10.0.3.0 (2019 January update) - taken from fastboot ROM

7. You need the original boot.img to patch. You can find it inside the official fastboot ROM zip for daisy. Check that the downloaded ROM version is the same as the "Build number" currently installed on your phone (see point 1 of this guide). If the versions are different, update (or downgrade if possible) your phone to that version. You can also download original boot.img elsewhere (for example at the point 6 of this guide), but always pick the same "Build number" of your phone.

After you get the boot.img, copy it to the phone memory (via USB or microSD, or download directly from the phone browser, as you prefer).​

8. Open the Magisk Manager app installed previously, it will ask if you want to install Magisk. Accept by tapping on "Install" > "Patch Boot Image File" and select the boot.img file that you get on the point 7 of this guide.​

9. Wait until the process completes (about 1 minute), then tap on "Close". Now in the phone memory, inside the Download directory, you should have a patched_boot.img file. Copy that file to the PC, inside the same folder where the Android platform tools are located, for our convenience.​

10. Reboot the phone in fastboot mode (as already explained in point 3 of this guide), open an administrative command prompt, move to the Android platform tools directory and then write the following command:

fastboot boot patched_boot.img

If everything works the phone should boot normally. Open Magisk Manager and it should ask to install Magisk, if not you must tap on the "Install" button. Then choose "Install" > "Direct Install (Recommended)" to install Magisk on the phone, and reboot when finished.​

11. Last step to stay safe when a new OTA update arrives: go to "Settings" > "System" > "Developer options" > and disable "Automatic system updates". From now on, you should check manually if a new OTA update is available.​

Now the installation is finished, you can use Magisk Manager to install modules and manage root permissions.

HOW TO APPLY OTA UPDATES

UPDATE 9 February 2019 It seems that with the latest Magisk (v18.1) and Magisk Manager (v7.0.0) the following procedure is working fine again. I didn't test it personally, but some users gave positive feedback.

WARNING! January 2019 Since the arrival of Android 9 Pie, the OTA update with Magisk as described in the following section, doesn't seem to work anymore. It could work, but you could also get a bootloop with the risk of losing your data.

Before upgrading from Android 8 to 9, or doing an OTA update after Android 9 you should:

- backup your data;

- remove any lockscreen password or fingerprint;

- uninstall totally Magisk and reboot.

If after doing this you get a bootloop, you could try to manually flash the vanilla boot.img via fastboot on the current slot (the same version as the last installed OTA). If you managed to fix the bootloop you can then install Magisk anew, from step 5 of this guide.

If the phone wants your PIN or password to proceed after the OTA update or after fixing the bootloop, and your PINs or passwords doesn't work, then you could have to reset the phone (or erasing the data partition, that should be the same thing), losing all your data.

Last chance if everything fails, you can flash the latest fastboot ROM from the official Xiaomi site and the phone will be working again.

IMPORTANT: OTA updates will work only if all the partitions on the smartphone are untouched. Magisk Manager can restore the original boot.img following this section of the guide, but if you tampered directly with the system partition (e.g. manually editing build.prop) or other partitions, OTA will refuse to install.

You can try to fix OTA updates without the need to flash the whole original fastboot ROM, by flashing only the tampered partitions (usually only "system") with the corresponding img file found inside the fastboot ROM zip. Check the "Troubleshooting" section of this guide for details.

12. When you know that a new OTA update is available and you want to install it, open Magisk Manager, and tap on "Uninstall" > "Restore Images" but very important: absolutely don't reboot the phone now!

Important note: Magisk Manager will restore the boot.img that was found on the phone while installing Magisk. If the boot.img was already non-vanilla (for example you flashed the boot.img with TWRP before installing Magisk), Magisk Manager will backup that modified version of boot.img, and when restored the OTA will not work, as that's not a vanilla boot.img.​

13. Close Magisk Manager and go to "Settings" > "System" > "System update" and install the OTA update. After the update is downloaded, a two-stages update will begin.​

14. When both stages of the update process completed, it will ask to restart: DON'T DO IT!. Open Magisk Manager again and tap on "Install" > "Install" > "Install to Inactive Slot (After OTA)" and after that you can tap on "Reboot".​

After the reboot you will have the updated Android version with Magisk already working.

Thanks to user [MENTION=7177145]jashancheema[/MENTION] for the Mi A1 guide and a bigger thanks to [MENTION=4470081]topjohnwu[/MENTION] for the OTA part and above all for developing Magisk.