How to Enable Persistent Camera2 API on Xiaomi Mi A2 Across Reboots

Xiaomi Mi A2 device owners who have rooted their device and enabled Camera2 API may find that it does not remain consistently enabled across reboots. In this guide we will show you a simple method, using a few ADB commands, to lock down the Camera2 API to a persistent state, so that it will always be enabled.

After following this guide, you can also un-root your Xiaomi Mi A2 and install a modded GCam app, for example, and Camera2 API will still be enabled.

Before you begin, there are a few things to be aware of. This method will not touch your /system partition, so you can continue to install OTAs (assuming you unroot or follow a rooted OTA update procedure). This method also does not require a modified boot partition, so you can keep your bootloader locked. The Camera2 API will still be enabled after OTA updates, best of all.

This method however does require temporary root access – so if your Xiaomi Mi A2 is not rooted, you should see Appual’s root guide for this device. And if you do not follow our instructions exactly pertaining to the temporary unlock procedure, you can (and probably will) lose all of your data.

Requirements:

First you need to enable Developer Options on your Xiaomi Mi A2 (Settings > System > About Phone > tap Build Number 7 times until Developer Mode is unlocked).

Now go into Settings > Developer Options, and enable ADB (USB Debugging) and Bootloader Unlock.

Now connect your Xiaomi Mi A2 to your PC via USB, and launch an ADB terminal (hold Shift + right click inside your main ADB folder, and select “Open a command window here”).

In the ADB terminal, type ‘adb devices’. This will open a prompt on your device to accept the pairing between ADB and your phone, so confirm the pairing dialogue.

Now turn off your device completely, and reboot it by holding Power + Volume Down, but do not release Volume Down key. This should boot your Xiaomi Mi A2 into Fastboot Mode, where we can continue to send ADB commands to the phone.

In the ADB terminal, type: fastboot oem unlock

Now copy the patched_boot.img to your main ADB folder on your PC, and type into ADB terminal: fastboot boot patched_boot.img

Now reboot your Xiaomi Mi A2, and download Magisk Manager – you don’t need to install Magisk itself, just the Magisk Manager app.

Now launch the ADB terminal on your PC again, and type:

Adb shell

Su

Setprop persist.camera.HAL3.enabled 1

Setprop persist.camera.eis.enabled 1

Now turn off your device again, then reboot into Fastboot Mode (Power + Volume Down while holding Volume Down continuously). Do not let go of the Volume Down button at any point – yes, you will need to type ADB commands with 1 hand.

If you release the Volume Down button, your Xiaomi Mi A2 will perform a factory reset – your entire data partition will be erased.

Then in the ADB terminal, type: fastboot oem lock

This will re-lock your bootloader, of course. And then you can type: fastboot reboot

Release the volume down button only after the phone starts to reboot into the Android system!

Now you can install GCam with Camera2 API persistently enabled.

In order to fix the front camera issue with modified GCam, just go into Gcam settings and enable “Camera.Enable_Hwhdr” from Developer Settings.

Tags

Kamil Anwar


A former British Computer Society Member with over 9 years of experience Configuring, Deploying and Managing Switches, Firewalls and Domain Controllers also an old-school still active on FreeNode.

Expert Tip

How to Enable Persistent Camera2 API on Xiaomi Mi A2 Across Reboots

If the issue is with your Computer or a Laptop you should try using Reimage Plus which can scan the repositories and replace corrupt and missing files. This works in most cases, where the issue is originated due to a system corruption. You can download Reimage by clicking the Download button below.

Download Now

I'm not interested

Close