How to Enable Camera2 API Persistently on Xiaomi Mi A2 Lite and Keep Bootloader locked

Google camera port or the Gcam is something that has more or less taken over the stock camera on most smartphones. Yes, these are not the official replacements for the stock camera applications provided by the OEMs. However, the development of the Google Camera Port or the Gcam provides better image processing capabilities as compared to the stock camera application. In this post, we will share a guide on how to enable Camera2 API persistently on Xiaomi Mi A2 Lite and keep the bootloader locked. This means that this procedure does not require access to your device’s system partition or have an unlocked bootloader.

Gcam is available for most smartphones and with passing time, new features are also being added like the Night Sight mode, HDR+, etc. These features allow us to take advantage of the Google Pixel camera, which is the best smartphone camera, period. Besides, it also gives us an idea of how the image processing capabilities can change the quality of the image taken from a smartphone. Xiaomi is known for providing powerful specs at a fairly low price as compared to others, however, the quality of the camera is still debatable. Moreover, Xiaomi devices were or at present, not known for their camera performance. But, you can take advantage of the Gcam or the Google camera port and install then on your Xiaomi device and improve the image-taking experience. So, without any further ado, let us get straight into the article itself;

What is Camera2 API?

Now, if you are a fan of Gcam or the Google Camera Port then, you need to enable the Camera2 API on your device. Almost all the OEMs have the Camera2 API enabled on their smartphones. However, even though the Xiaomi phones run on stock Android, the Xiaomi Mi A2 Lite does not support the Camera2 API. And, in order to install and run the Gcam or the Google camera port on the Xiaomi Mi A2 Lite smartphone, you need to enable the Camera2 API.

Moreover, it is pretty easy to enable the Camera2 API on the Xiaomi device if you have a rooted device but, in this post, we will guide you how to enable Camera2 API on the Xiaomi Mi A2 Lite device without needing an unlocked bootloader. But, keep in mind that you need to have temporary root access to your device in order to enable the Camera2 API on the Xiaomi Mi A2 Lite. For those, who did not understand what is temporary access to root, please follow this guide and you will be able to enable the Camera2 API pretty easily.

Advantages and Disadvantages of this method


  • This mod does not touch your system partition which means, you can install OTAs without doing anything
  • This mod does not require a modified boot partition and you can keep your bootloader locked
  • The Camera2 API will still be enabled after OTAs


  • Note that it still needs a temporary root access
  • If you are not careful with the temporarily unlock procedure, all your data will be lost

Download Links

Steps to Enable Camera2 API Persistently on Xiaomi Mi A2 Lite

Note that if you are not careful with the temporary unlock procedure, all your data will be lost. So, make sure to make a complete backup of the data on your device.
  1. Firstly, download and install the ADB and Fastboot tools from the above download section on your PC.
  2. Now, download the Patched Boot image file from the download section above and extract it.
  3. You need to enable the Developer Options on your Xiaomi Mi A2 device. To do this, go to Settings>>System>>About Phone>>tap 7 times on the Build Number till you see a toast message “You are now a developer”.
  4. Connect your device to the PC and give your PC the permission to ADB.
  5. Now, turn OFF your device.
  6. Reboot the device by pressing the Power + Volume Down button combination.
  7. You need to copy the contents of the Patched Boot image to the folder where you have extracted the ADB and Fastboot tools.
  8. Open a command prompt and run the below command;
    fastboot oem unlock
    fastboot boot patched_boot_file_name.img

    (make sure to change the “patched_boot_file_name.img” with the actual name of the patched boot image file)
  9. Download the Magisk Manager APK from the download section above. You just need to directly install the application on your Xiaomi Mi A2 Lite device.
  10. Now, on the command prompt, enter the below commands to enable the Camera2 API;
    adb shell
    setprop 1
    setprop 1
  11. Once you have entered the above-mentioned commands one by one, then just turn OFF your device.
  12. Now, you need to Reboot your device by pressing the Power + Volume Down buttons together. Keep pressing the button while your device is rebooting.
  13. Now, again on the command prompt, run the below commands (keep pressing the Volume down button);
    fastboot oem unlock
    fastboot reboot
  14. Then release the Volume down button while the phone reboots.
  15. Download the Gcam from the above download link.
  16. Open the Gcam application. Now, to fix the front camera issue in the Gcam, you need to enable “camera.enable_hwhdr” from the Developer Settings.

That’s it! you have enabled the Camera2 API on your Xiaomi Mi A2 Lite smartphone. If your device gets detected in the ADB but not in Fastboot then, reboot in Fastboot mode, open device manager and search for the android device and hit update drivers.

Recommended Settings

Below are the recommended settings that you can use the Google camera port or Gcam port;

Go to Settings>>Advanced:

  • Base:
    • Interface Style: Pixel 3
    • Config: Auto
    • Back Camera: Pixel 3 XL
    • Front Camera: Nexus 6P
  • Libs: Stock by Eszdman v3

Quick Specs Review of the Xiaomi Mi A2 Lite

The Xiaomi Mi A2 Lite smartphone is powered by the Qualcomm Snapdragon 625 2.0 GHz processor which is paired with 3/4 GB of RAM. It runs on the latest Android 9 Pie and has Adreno 506 GPU. The device comes with 32/64GB of internal storage. Moreover, the device also offers to expand the storage capacity to 256GB via a microSD card. In the front, the device has a Full HD+ LCD 5.84-inch display with a notch. It packs a resolution of 1080×2280 and with 432 PPI.

The device sport a dual-camera set-up at the back with 12MP (f/12.2)+ 5MP (depth sensor) shooters. And, in the front, you get a single 5MP camera with an f/2.0 aperture. Some of the features of the camera of Xiaomi Mi A2 Lite are AI Portrait mode, Depth Mode, Beautify 4.0, and face recognition as well. Moreover, the device has a back-mounted fingerprint sensor. The Xiaomi Mi A2 Lite packs a battery capacity of 4000mAh.

So, there you have it from my side in this post. Hope you guys were successful in enabling the Camera2 API on the Xiaomi Mi A2 Lite smartphone. Let us know in the comments below if you faced any difficulties or issues while following any of the above-mentioend steps. Until the next post…Cheers!


  1. This sounds great. But what’s the purpose of the Magisk Manager App?

    Since you seemed to unlock the bootloader, can you then re-lock the bootloader and still have Camer2 API enabled?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.