[Xiaomi Mi A2 / 6X Guides, News, & Discussion] AsItLies:
********** 11/17/18 sorry to say folks, this method of enabling cam2api does not, for some reason, work with stable PIE. Looks like root is the only option now ********

**** please note, the next comment, after this guide, has some 'condensed problem solving' tips from the 10 pages of comments - if you run into problems doing the following, look at the next comment for possible solutions *****

While this might sound similar to other 'guides', it's not the same. In this guide we'll enable Cam2API, not flash anything, and not install root then later uninstall it.

And we won't do it with a 'tool', that you have no idea what it's doing behind the scenes (they have their place, but not really needed for this imho).

Also, it's not my intention to knock Magisk. It's a great rooting app, and it has a lot of additional features besides root. But when deciding to use Magisk or not, if all you want to do is enable cam2API, and use none of it's other great features, it seems like overkill to me.

Prerequisites:

1) Your version of fastboot needs to be one that recognizes 'dual slot' phones (look at the version docs if yer not sure).

2) Your device needs to be bootloader unlocked, and adb debug enabled (research that if you don't know what it means).

3) You need the latest version of Tingyichen's TWRP, which currently is twrp-3.2.3-jasmine-20181020.img

https://xdaforums.com/mi-a2/development/recovery-unofficial-twrp-recovery-mi-a2-t3825146

1) Connect the device with adb, and verify it's working with 'adb devices'. Assuming it works type:

adb reboot bootloader

2) Once in fastboot (the bootloader), find out which slot is current with:

fastboot getvar current-slot

Make a note of which slot is current.

3) If the current slot is NOT 'a', then we have to set it to 'a'. Do the following to accomplish that;

fastboot set_active a

4) With the current slot set to a, do the following command:

fastboot boot twrp.img

(or the actual name of your twrp.img if you didn't rename it to twrp.img - you don't *have* to rename it, seems most people do though.)

At this point, let the device start and go into twrp. You will have to use your 'pattern' if you have one set on the phone. Also, you do NOT have to hold vol up to boot into twrp.

5) Now we'll do the 2 (or 3 if u have Pie) commands to set cam2 enabled.

adb shell

setprop persist.camera.HAL3.enabled 1

note: only do the following command for Pie or newer versions.

setprop persist.vendor.camera.HAL3.enabled 1

exit

6) Our cam2 will be enabled the next time we reboot. So lets type this:

adb reboot bootloader

7) Now, if our original active partition was b, we have to set it back to b:

fastboot set_active b

8) Lastly, we simply reboot with:

fastboot reboot

That's it, boom, done.

Side Notes:

So why does this work? After so many have indicated TWRP didn't work for them? But it did for others? Wha Up? Simple, it seems twrp isn't very dual slot smart (and why should it be? it was originally written for single slot devices - it DOES give you an option to set the other slot active when you exit it, but all that's doing is running 'set active', nothing to do with installing it).

So I just verified this morning, even though I have cam2 working. My active slot is b, and 'fastboot boot twrp' would fail (even though others said Tingy's new version worked!). So what's different? Only thing I could think of was which slot was active. The active slot changes for ea device with updates, and thus we don't all have the same active slot!

But setting it to a, then doing boot twrp, works like a champ. setprop persist commands of course work also (I verified, even though mine are set). And simply going back to fastboot and doing reboot should avoid any trace of twrp having been used (we didn't 'flash' it, only booted it).

If anyone decides to try 'fastboot boot boot_a twrp.img', that *might* work, I didn't think to try it.

Cheers