[GUIDE] How to enable Camera2 API persistently and keep bootloader locked

Search This thread

flex1911

Recognized Developer / Retired Forum Moderator
Feb 12, 2013
998
7,535
21
Volgograd
Hello everyone. I'm pretty sure that there are a plenty of people that are rooting and unlocking their A1 just to enable Camera2 API (just like me).
But formally you can enable and make it persistent without unlocking bootloader and rooting.
Why "formally"? Because you will actually need to unlock and root during the process, but then you can relock your bootloader and forget about it until you will wipe your /data. Yes, Camera2 API will remain enabled after relocking and will persist even after OTA updates.

1. If you already didn't, unlock the bootloader and root your phone by Magisk using this guide.
2. Enable ADB in the developer settings.
3. Assuming you already have platform-tools binaries, do this in your shell/cmd:
Code:
adb shell
Now, when you are in the device shell, type this:
Code:
su
The device will probably ask about root access, grant it.
Now, when you are in the root shell, type this:
Code:
setprop persist.camera.HAL3.enabled 1
4. Reboot and make sure that Camera2 API works for you now.
5. Go to Magisk manager and completely uninstall Magisk here.
6. Reboot and make sure that your system boots properly.
7. Reboot to bootloader:
Code:
adb reboot-bootloader
8. Relock your bootloader:
Code:
fastboot oem lock

Done! Now you have permanently enabled Camera2 API without messing OTA and security measures.

THIS DOESN'T TOUCH SYSTEM FILES AT ALL AND HAS NOTHING TO DO WITH BUILD.PROP
 
Last edited:

Ammo thind

Member
Aug 15, 2017
31
2
Hello everyone. I'm pretty sure that there are a plenty of people that are rooting and unlocking their A1 just to enable Camera2 API (just like me).
But formally you can enable and make it persistent without unlocking bootloader and rooting.
Why "formally"? Because you will actually need to unlock and root during the process, but then you can relock your bootloader and forget about it until you will wipe your /data. Yes, Camera2 API will remain enabled after relocking and will persist even after OTA updates.

1. If you already didn't, unlock the bootloader and root your phone by Magisk using this guide.
2. Enable ADB in the developer settings.
3. Assuming you already have platform-tools binaries, do this in your shell/cmd:
Code:
adb shell
Now, when you are in the device shell, type this:
Code:
su
The device will probably ask about root access, grant it.
Now, when you are in the root shell, type this:
Code:
setprop persist.camera.HAL3.enabled 1
4. Reboot and make sure that Camera2 API works for you now.
5. Go to Magisk manager and uninstall Magisk here.
6. Reboot to bootloader:
Code:
adb reboot-bootloader
7. Relock your bootloader:
Code:
fastboot oem lock

Done! Now you have permanently enabled Camera2 API without messing OTA and security measures.
Is it true

Sent from my Mi A1 using Tapatalk
 

AridaneAM

Senior Member
Oct 27, 2017
83
369
Have you tried it? When updating the OTA build.prop in system is not rewrited? What is the difference with replace build.prop in twrp? When I tried it the OTA didn't upload because the edited system partition.

Enviado desde mi Mi A1 mediante Tapatalk
 

Ammo thind

Member
Aug 15, 2017
31
2
Hello everyone. I'm pretty sure that there are a plenty of people that are rooting and unlocking their A1 just to enable Camera2 API (just like me).
But formally you can enable and make it persistent without unlocking bootloader and rooting.
Why "formally"? Because you will actually need to unlock and root during the process, but then you can relock your bootloader and forget about it until you will wipe your /data. Yes, Camera2 API will remain enabled after relocking and will persist even after OTA updates.

1. If you already didn't, unlock the bootloader and root your phone by Magisk using this guide.
2. Enable ADB in the developer settings.
3. Assuming you already have platform-tools binaries, do this in your shell/cmd:
Code:
adb shell
Now, when you are in the device shell, type this:
Code:
su
The device will probably ask about root access, grant it.
Now, when you are in the root shell, type this:
Code:
setprop persist.camera.HAL3.enabled 1
4. Reboot and make sure that Camera2 API works for you now.
5. Go to Magisk manager and uninstall Magisk here.
6. Reboot to bootloader:
Code:
adb reboot-bootloader
7. Relock your bootloader:
Code:
fastboot oem lock

Done! Now you have permanently enabled Camera2 API without messing OTA and security measures.
Editing prop file will make sure that there is no ota

Sent from my Mi A1 using Tapatalk
 

flex1911

Recognized Developer / Retired Forum Moderator
Feb 12, 2013
998
7,535
21
Volgograd
Have you tried it? When updating the OTA build.prop in system is not rewrited? What is the difference with replace build.prop in twrp? When I tried it the OTA didn't upload because the edited system partition.

Enviado desde mi Mi A1 mediante Tapatalk

persist props are being stored in /data/property, so it doesn't touch build.prop at all.
 

black_arashi

Senior Member
Jul 26, 2013
53
144
Hello,

I doubt that this will work with funtional OTA, modificating the build.prop it's modificate system, so it should't have working OTA. If we use Magisk and the modules to enable camera2api and hal3 it's because it doesn't modify system. Anyway, if someone try it and corroborate it work great with OTA, I will retract my self.

Regards
 

flex1911

Recognized Developer / Retired Forum Moderator
Feb 12, 2013
998
7,535
21
Volgograd
Hello,

I doubt that this will work with funtional OTA, modificating the build.prop it's modificate system, so it should't have working OTA. If we use Magisk and the modules to enable camera2api and hal3 it's because it doesn't modify system. Anyway, if someone try it and corroborate it work great with OTA, I will retract my self.

Regards

As I stated above, it doesn't modificate any system files at all.
 

Haizum74

Senior Member
Aug 6, 2010
458
63
Capital of Yorkshire
I am currently waiting for delivery of my Mi A1 (hopefully today) and will give this a go and report back.

For people questioning this, build.prop is only one of a number of read only files that are used when setting up after reboot so I can see why this would potentially work. Not a dev myself, but understand the basics.


PS Its modify not modificate ;)
 

unixbrain

Member
Nov 16, 2008
15
6
It works but before locking back the bootloader you must let Android to boot the system.
If you lock the bootloader just after uninstalling Magisk it will end up with a "System has been destroyed" error
 

flex1911

Recognized Developer / Retired Forum Moderator
Feb 12, 2013
998
7,535
21
Volgograd
The OP heading reads "How to enable HAL3 without unlocking and root". Then, in the post you are telling people to Unlock and Root via Magisk !

What's going on ?

Anyway, if someone knows how to Magisk and root, then for sure, he or she would know how to use a simple magisk module to enable HAL3.

You probably didn't get the point at all.
 

Rajeev

Recognized Contributor
Nov 24, 2012
16,307
26,534
Chennai , I N D I A
Xiaomi 13 Pro
The OP heading reads "How to enable HAL3 without unlocking and root". Then, in the post you are telling people to Unlock and Root via Magisk !

What's going on ?

Anyway, if someone knows how to Magisk and root, then for sure, he or she would know how to use a simple magisk module to enable HAL3.

Whats going on with u too? Why quoting the full damn OP?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 80
    Hello everyone. I'm pretty sure that there are a plenty of people that are rooting and unlocking their A1 just to enable Camera2 API (just like me).
    But formally you can enable and make it persistent without unlocking bootloader and rooting.
    Why "formally"? Because you will actually need to unlock and root during the process, but then you can relock your bootloader and forget about it until you will wipe your /data. Yes, Camera2 API will remain enabled after relocking and will persist even after OTA updates.

    1. If you already didn't, unlock the bootloader and root your phone by Magisk using this guide.
    2. Enable ADB in the developer settings.
    3. Assuming you already have platform-tools binaries, do this in your shell/cmd:
    Code:
    adb shell
    Now, when you are in the device shell, type this:
    Code:
    su
    The device will probably ask about root access, grant it.
    Now, when you are in the root shell, type this:
    Code:
    setprop persist.camera.HAL3.enabled 1
    4. Reboot and make sure that Camera2 API works for you now.
    5. Go to Magisk manager and completely uninstall Magisk here.
    6. Reboot and make sure that your system boots properly.
    7. Reboot to bootloader:
    Code:
    adb reboot-bootloader
    8. Relock your bootloader:
    Code:
    fastboot oem lock

    Done! Now you have permanently enabled Camera2 API without messing OTA and security measures.

    THIS DOESN'T TOUCH SYSTEM FILES AT ALL AND HAS NOTHING TO DO WITH BUILD.PROP
    10
    Hello,

    I doubt that this will work with funtional OTA, modificating the build.prop it's modificate system, so it should't have working OTA. If we use Magisk and the modules to enable camera2api and hal3 it's because it doesn't modify system. Anyway, if someone try it and corroborate it work great with OTA, I will retract my self.

    Regards

    As I stated above, it doesn't modificate any system files at all.
    8
    Have you tried it? When updating the OTA build.prop in system is not rewrited? What is the difference with replace build.prop in twrp? When I tried it the OTA didn't upload because the edited system partition.

    Enviado desde mi Mi A1 mediante Tapatalk

    persist props are being stored in /data/property, so it doesn't touch build.prop at all.
    6
    I clicked on this thread reading "Enable Camera 2 Api without Rooting" - and when read the OP, reminded me of Casey Neistat like Clickbaiting ;). That's why i commented.

    Sorry if you all didn't like it. :)
    The OP is a guy who has just given everyone a simple and concise way of having arguably the best feature of this phone enabled without having to keep root on the phone and you are trying to make a song and dance over phrasing.

    The importance of this method is undeniable where security is a needed feature on a phone.
    4
    After applying the property as mentioned in the OP, is there a lag when opening the camera or not?
    Thanks!

    No, it doesn't. Camera lags when opening because of root, not because of HAL3.