How to Enable Camera2 API on Xiaomi Mi A1 without Permanently Rooting it

Enable Camera2 API on Xiaomi Mi A1 running Android Pie without Root

Android Pie update for Xiaomi Mi A1 was released a while back and our users have asked us if they can enable Camera2 API on their Mi A1 after on Android Pie. To answer the question, I will show you in this post how to easily enable Camera2 API on Xiaomi Mi A1 without permanently rooting it. The instructions will work regardless of the Android version installed on your phone. Furthermore, links have also been provided below to download the latest Google Camera Port for your Xiaomi Mi A1.

The Xiaomi Mi A1 is the company’s first smartphone featuring the Android One program. Being a part of the program means that the device offers guaranteed updates. Be it a major Android version release or monthly security patches. Talking about the software, the phone incorporates the stock AOSP firmware which is free from the majority of OEM bloatware. If you try installing the Google Camera Port on your Mi A1, you will probably fail due to the lack of Camera2 API support.¬†Despite being based on stock Android, the Mi A1 still doesn’t offer direct support for Camera2API on Android Pie or Oreo.

If you have rooted your Mi A1, you can easily enable the API by making a few build.prop edits or via a Magisk module. In the case of the former, you would mount and write the /system partition, which will ultimately break the possibility of installing OTA updates on your rooted phone via Magisk. So, if you do not want to root, you can still enable camera2 API on your Xiaomi Mi A1 quite easily.

The process that has been listed below will first require you to boot Magisk Patched Boot Image to temporarily root your phone. Once your Mi A1 boots into the OS, you can simply use a Terminal Emulator to enable Camera2 API by executing a few simple commands. Since you will be rooting the phone temporarily, you will still be able to take OTA updates after following this method, so stay out of worries.

Also read: How to Hard Reset Xiaomi Mi A1 to Factory Settings (2 Methods)

Table of Contents

Downloads

Below are the download links for stock and patched boot images for Xiaomi Mi A1 running Android Pie. We have also provided the stock boot image for the corresponding firmware. It shall help you unroot your phone in case you mistakenly flash the patched boot permanently.

V10.0.24.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.23.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.22.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.21.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.20.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.19.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.18.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.17.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.16.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.15.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.14.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.13.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.12.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.11.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.10.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.9.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.8.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.5.0.PDHMIXM Stock Boot Image Patched Boot Image
V10.0.4.0.PDHMIXM Stock Boot Image Patched Boot Image

Instructions to Enable Camera2API on Xiaomi Mi A1

In order to temporarily boot the patched boot image on your Mi A1, you must first install Android platform-tools on your PC and unlock the bootloader of your Xiaomi Mi A1 (Note: Unlocking the bootloader will wipe all the data on your phone, so make sure that you take a complete backup first). If you already have the bootloader unlocked, nothing will be wiped using this method.

I have personally tested this method on a Xiaomi Mi A1 running the latest Android Pie firmware. Although, it will work on older Android versions too. Just make sure that you download the patched boot image corresponding to the software build number installed on your phone.

Now to enable Camera2 API on your Xiaomi Mi A1, follow the instructions below.

  1. Download the Magisk patched boot image for Xiaomi Mi A1.
  2. Copy the downloaded image file to the folder where the ADB/Fastboot binaries are present (e.g. C:/username/platform-tools).
  3. Hold the SHIFT key and right-click on an empty space inside the folder.
  4. Select the ‘Open PowerShell window here’ option.
  5. Power off your Xiaomi Mi A1 completely.
  6. Now hold the Volume Down and Power buttons together to enter Fastboot Mode.
    Enable Camera2 API on Xiaomi Mi A1 - Boot into Fastboot Mode
    Fastboot Mode on Xiaomi Mi A1
  7. Connect your phone to the PC using the USB cable.
  8. Enter the following command to temporarily boot the Magisk patched boot image on your Mi A1:
    fastboot boot boot-image-filename.img
  9. Make sure to replace ‘boot-image-filename.img‘ with the actual filename. For example, if you’re on the firmware with V10.0.21.0 build number, the command should be:
    fastboot boot patched_boot_V10.0.21.0_mi_a1.img
    Enable Camera2 API on Xiaomi Mi A1 - Temporarily Boot Patched Boot Image
  10. Just as the command is entered, your Mi A1 should boot into the OS with temporary root with Magisk.
  11. Right now, only the Magisk Manager stub is installed on your phone. In order for Magisk to work and to grant superuser permissions, you must first install full Magisk Manager.
  12. Simply go to the phone’s app drawer and launch Magisk Manager app (In case the app doesn’t show up, download the latest APK from here and install it on your phone).
  13. Select “Yes” when prompted to upgrade to full Magisk Magisk Manager and follow the on-screen instructions.
    Upgrade to Full Magisk Manager on your Xiaomi Mi A1 when prompted
  14. Once Magisk Manager is fully installed, download and install Termux (Terminal Emulator for Android) on your Mi A1.
  15. Once installed, launch Termux and enter the following command:
    su
  16. Grant superuser permissions to the Termux app when prompted.
  17. Finally, enable Camera2 API on Xiaomi Mi A1 running Android Pie by entering the following commands:
    setprop persist.camera.HAL3.enabled 1
    
    setprop persist.vendor.camera.HAL3.enabled 1
    
    setprop persist.camera.stats.test 5
    
    setprop persist.vendor.camera.stats.test 5
  18. Further, enter the following command to enable EIS (Electronic Image Stabilization) on Mi A1:
    setprop persist.camera.eis.enable 1

    Enable Camera2 API on Xiaomi Mi A1 - Enter Command in Terminal Emulator

  19. Once the command executes without any errors, close Termux and reboot your phone. When your phone reboots, Magisk Manager should vanish and your Mi A1 should be unrooted.

For further confirmation, you can also check Camera2 API support using an app. With the API enabled, you can now go ahead and install Google Camera Port on your Mi A1.

Download Google Camera Port for Xiaomi Mi A1

XDA RD joeyhuab created a dedicated thread on the forums to share the latest working Google Camera Ports for Xiaomi Mi A1. Below are some of the GCam ports shared by different users on that thread. Note that each version may have bugs of there own. Rest assured, these are the most stable ports available for the device as confirmed by the XDA users who shared them.

Note: For Wyroczen’s version, you will need to install the DotFix module on your rooted device. If your Mi A1 isn’t rooted, then go to Google Camera app “Settings” > “Advanced” > “Lab” and disable “mi a1 dot related fixes”. Also, switch “raw_sensor” to “raw10”. This shall help prevent pink/purple tinted photos.

If you’re not satisfied with the provided ports, you can try and find the perfect one for you from here. Finding the perfect GCam Port for any device is hard. If you have found a better port, then please let us know in the comments. It would help other users who are looking for it.

You have just succeeded to enable Camera2 API on your Xiaomi Mi A1 without root. If you have any questions regarding the method listed above, please feel free to leave a comment.

Comments

  1. Charan, I have added the latest stock and patched boot images for the V10.0.24.0 update.

  2. Hi, thanks for the VERY informative tutorial. Just a couple of doubts: how do we know if we have flashed the root version permanently? And as you have already uploaded the stock boot images, how do you flash that if we have mistakenly flashed the patched version permanently? (I’m asking this because I want to be completely safe in this method and also I’m a TOTAL newbie in these things and this is my first ever venture, and it’s very scary, not knowing what might happen at an time.)

    1. Thank you Navneeth for the kind words.

      The quickest way to differentiate between a permanent flash and a temporary boot is the command itself.

      In this tutorial, we are using the ‘fastboot boot’ command, which basically just boots the phone with the directed partition image (a patched boot image in this case).

      On the other hand, when you “flash” something, the command uses the ‘fastboot flash’ syntax. For example, if you were to flash the patched boot image, the command would be: fastboot flash boot boot.img (Here ‘boot.img’ would be the actual filename of the boot image).

      TL;DR – As long as you use the ‘fastboot boot’ command as instructed, your phone will automatically be unrooted on the next reboot.

  3. Yes, you will need the patched boot image for V10.0.24.0. I am in midst of extracting, patching and uploading it. Just hold on for a while.

  4. Hi Dhananjay, where can I find the patched boot image for august 2020 update (V10.0.24.0) ?
    Thanks.

  5. Hello!

    I am not trying to enable Camera2api, but solving an issue with the volume of the speaker during calls, it is really low.
    I need to edit “root”\system_root\system\vendor\etc\mixer_paths_m tp_global.xml”.

    Will this way work for this and make it permanent?

    Thanks.

    1. Yes, it will work. But when you unroot (i.e. reboot the phone), it might end up in a bootloop because the /system partition was modified.

      If performing the fix is really something you need to do, then I suggest you root the phone.

  6. Tobias, I have added the stock boot for the August 2020 update with V10.0.24.0.PDHMIXM build number.

  7. Hi Gaurav. Stock and Patched boot images for the July update (V10.0.23.0) have been added. Please check now.

  8. Hi Ali. If you still need it, I have just uploaded and added the V10.0.22.0 boot images to the post.

  9. Hi Helvin. I haven’t been able to capture the OTA URL or get a direct link to the 10.0.22.0 full ROM/fastboot.

    Though I have found something. I am currently downloading it and will reply back if I add the boot images.

  10. Hi Ali. For now, I do not have my hands on the OTA package of the June 2020 update. As soon as I do, I will extract the boot image and upload it.

  11. Hi Lanang. Have you tried installing a different port? If all the ports crash, it means that camera2 API wasn’t successfully enabled. To confirm the same, please check this post.

  12. Hi Nanda. Yes, the phone will have root permissions, but only temporarily. Since you will only temporarily boot the phone with the patched (rooted) boot image, it will only stay rooted until the next reboot, as mentioned in the instructions.

  13. Hi Chaki. I have added the download links for the stock and patched boot images for the March 2020 security update. Please refresh the page and check again.

  14. Hi Hadi. I have just added them, along with a couple of new ports from various developers like marlin-ku and overwhelmer.

    1. hi, thanks for the file, it really work on my cousin’s mia1, now he can easily install any gcam version out there, haha

      god bless you!

  15. Hi CasaLiro. I have added the patched and stock boot images for the January 2020 update. Please refresh the page and check again.

  16. Hi Ikhsan, if your phone’s bootloader is already unlocked, then no, this process will not wipe any data stored on the phone.

  17. Bro thanks i could not found a single thread about installing (Pie Dec 19) Gcam for Mi A1 including XDA and may be its because of the Mi A1 is getting old and developers have switched to another device.
    But anyhow ton of thanks as i installed successfully Gcam with temporary root having no issue in instillation process , i am on pie December security update and now having camera2api enabled in my Mi A1.

    Thanks and keep it up.

    1. Hi Ibrar. Thank you so much for your appreciation. It means a lot to me.

    1. Hi! When I type in “fastboot boot boot-image-filename.img” it says no such file in directory. What do I do?

    2. Hi Allan. You need to replace “boot-image-filename.img” with the actual filename of the patched boot image.

      For example, if you’re using the November patched boot image, the command should be:
      .\fastboot boot patched_boot_10.0.15.0_mi_a1.img

      I hope it clarifies.

  18. Hi Cristian. I have uploaded the November 2019 stock and patched boot images. Please check now.

    1. Hey bro i used latest November security patched boot image… everything ok but when I reboot my phone magisk says magisk not install I have to fastboot the image file after reboot pleas help

    2. Hi Khabir. By using this method, your phone is only temporarily rooted, until you reboot. A reboot will unroot your phone.

      After booting with the corresponding patched boot image, you will need to use Termux to execute the above-stated commands.

  19. hi
    I have done it. it’s working nice.
    thanks for your post.
    the only thing I need to confirm is magisk Manager is still on my phone after rebooting. I should remove it or not

    1. Hi Jignesh. Please, open Magisk Manager, it should show that Magisk is not installed. If so, then you can safely remove the app.

      P.S. Thanks for your appreciation. I am glad it was helpful to you.

  20. Great! You’re welcome Shrnjay. And apologies for the previous boot images that caused the issues.

    1. Hi, thank you for guide
      Do you know if there is the rom patched of nomvember update?

  21. Hi Shrnjay. I have reuploaded the new images, and they have been confirmed to be working. Please try downloading it once again, and then use the “fastboot boot patched_boot_10.0.14.0_mi_a1.img” to temporarily boot your phone with Magisk root.

  22. I wanna know after doing all of these above steps my bootloader is still unlocked, because there wasn’t any instruction given to lock the bootloader so should i lock it, or not? will it brick my phone or it’s safe to lock it?

    1. Hi Praneet. Yes, the bootloader will still be unlocked and it needs to be kept that way. If you lock the bootloader, the Camera2 API will be disabled. Locking is possible, and should not brick your phone. But if you want Camera2 API, you must keep it unlocked. And don’t worry, neither an unlocked bootloader or the Camera2 API modifications will prevent you from taking and installing OTA updates on your phone.

    2. @Dhananjay, you are wrong. I have enabled Camera 2 API then I locked bootloader without losing any data and using Gcam after locking the bootloader.

    3. Hi Samuel. Thanks for correcting me. I don’t own the device anymore, but the same unlocking trick (without wiping user data) stopped working for the Mi A1 months ago.

      Even if it works, I wouldn’t suggest locking the bootloader. That’s because once you update your phone with a future security patch, you will need to re-perform the procedure to enable Camera2 API. For which, you will again need to unlock the phone’s bootloader.

      I personally find it quite redundant, following the whole unlocking, enabling camera2 API, and re-locking bootloader again, and again, every month.

      Unless someone is skeptical about their device’s security with an unlocked bootloader

    1. Hi Ayrton. First of all, your Mi A1 should be running Android 10 to be able to use the Pixel 4 camera port (Google Camera 7.0 or above).

      Try downloading the first two ports available here. One is of Google Camera v7.0.009, while the other is of v7.1.019. Give them both a try and see which works the best for you. For the v7.0.009 port, you will also need to load the config file, which could be found here.

      Also, do let us know which version works best so that we can update the post with the link to that version as well.

  23. Hi Strider. Must be some issue with Mediafire. Please try these links if you’re still on the August 2019 update. On the other hand, Patched and Stock boot images for consecutive September and October updates are now live.

  24. Hi Parag. Once I get hands on the full OTA package or fastboot image of the September update, I will surely upload and post the boot images as soon as possible.

    1. Hi Mahesh. For two major reasons:
      1) If a user accidentally flashes the patched boot image instead of temporarily booting it.
      2) In case a user faces an issue while installing the OTA updates.

  25. Hi. Which firmware build number is currently installed on the phone? Also, please state the device name, is it the Mi A2 or the Mi A2 Lite?

  26. Hi Zack. The May Patched Boot is now available. And never use a patched/stock boot of another software version.

  27. Can I use the command “Disable” instead of enable to disable or restore the settings as previous.

    1. There’s nothing like disable. It is a property name. In order to disable it, just set its value to “0”. The following commands will help you understand what I am trying to explain:

      setprop persist.camera.HAL3.enabled 0

      setprop persist.camera.eis.enable 0

    2. I already finished all the step but when i open the gcam its force close…i have try 4 gcam including given gcam.

Leave a Reply

Comment Policy: We welcome relevant and respectable comments. Only input your real first name and valid email address if you want your comment to appear. Read our comment policy fully before posting a comment.