• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

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

Search This thread

met67

Senior Member
Apr 16, 2007
209
35
As i get it "fastboot boot patched_boot.img" will already boot rooted boot.img so i dont need to intall magisk at all?

Yes, you are right!
I just enabled HAL3 & EIS by unlocking the bootloader, booting from patched_boot.img with Magisk Manager installed, setting the persistent properties and relocking the bootloader.

Great work!
 

Gingernut78

Senior Member
Sep 17, 2011
585
212
Thanks for this.

I saved on the root step as you don't actually need it.

Boot to fastboot
Unlock bootloader
Fastboot boot to TWRP
Once in TWRP go to advanced and manually type in the setprop commands you want
Reboot to bootloader and relock
Done

Tested and working
 
  • Like
Reactions: zamuz27 and gekko69

RavinduSha

Senior Member
Thank you for your hard work. I have a couple of questions though. Please advise.

1. If we enable Camera2 API and EIS by your method, will these functions work with Mi Stock camera or do we need to use Google Camera ?
2. Can any version of Google Camera be used with these functions or should we use a specific version?
You can still use your Stock camera without any problem and GCam also.
 

flex1911

Recognized Developer / Retired Forum Moderator
Feb 12, 2013
999
7,534
19
Volgograd
Yes, you are right!
I just enabled HAL3 & EIS by unlocking the bootloader, booting from patched_boot.img with Magisk Manager installed, setting the persistent properties and relocking the bootloader.

Great work!

Yeah, it is even easier to do it like this. I just made it slightly more complicated to make sure that it applies properly and persists.
 

riccetto80

Senior Member
Jul 13, 2013
322
60
i applied the 2 command without root with magisk, just used the patched_boot.img, apply the 2 command (hal3 and image stabilization), rebooted, relocked the bootloader.

gcam seems to work fine, and image stabilization can be selected!!!

only issue is: gcam hdr really use a lot of battery!!! (9% with 13minuts screen usage while i was doing 20/25 photos and a video) i have white dots in some conditions on photo, while on with xiaomy cam software i dont have this dots at all.
(dots disappear if i choose portrait mode, nice)

anyway your method work, gg man!

also, no lag on xiaomi camera, work as before!!!!

GG topic starter!!!
 
Last edited:
  • Like
Reactions: hartej4

hartej4

Member
Jul 27, 2007
6
1
i applied the 2 command without root with magisk, just used the patched_boot.img, apply the 2 command (hal3 and image stabilization), rebooted, relocked the bootloader.

gcam seems to work fine, and image stabilization can be selected!!!

only issue is: gcam hdr really use a lot of battery!!! (9% with 13minuts screen usage while i was doing 20/25 photos and a video) i have white dots in some conditions on photo, while on with xiaomy cam software i dont have this dots at all.

anyway your method work, gg man!

also, no lag on xiaomi camera, work as before!!!!

GG topic starter!!!
Plz can you explain in step by step process
 

riccetto80

Senior Member
Jul 13, 2013
322
60
ISSUE: seems to f*uk up big time naptime, i used naptime without root.

after i used the patched_boot.img naptime crashed, after i finished use it and apply the 2 command, reboot and closed again the bootloader, naptime didn't crash anymore, but dont work anymore as intended.

i tryed to uninstall and reinstall and re-apply the 2 adb command naptime need to work without root.

still behave strangely.

i will update this post as soon i understand what is happening.

---------
seems naptime start again to work as intended, after a uninstall/reinstall + permission gave again + restart.

so, lesson learn: if you want apply the method of this topic, and you run naptime or another similar app (greentime, force doze and so on) who work without root using couple of adb command, uninstall it/disable it before "temporarily root" the device or naptime or similar app will misbehave and will keep to misbehave even after you lock again the bootloader.


ANOTHER STRANGE THINGS I NOTICE:
Now in my app list some app have a voice, a voice before dont exist:
-advance: Allow modify system settings

is this normal?
 
Last edited:

Onkar Ingale

Member
Feb 5, 2018
10
2
Help

When I installed the magisk then followed the all instructions but as I uninstall magisk I see my build.prop empty and as camera2api doesn't work and as I install magisk, build prop Appears and it starts working
Please help me
 

giovaorama

Senior Member
Jul 6, 2013
192
62
Obviously unlocking/locking the bootloader will wipe the data partition, right?
It uses to work like this in Nexus and Pixel phones.

Inviato dal mio LG-V500 utilizzando Tapatalk
 

sooti

Recognized Developer
Jan 26, 2012
2,465
6,680
I did everything as you said. The phone worked perfectly fine until I've done the last step. After I relocking the phone, it stuck on fastboot screen. It's not rebooting and the CMD is not showing the device. What should I do?

Obviously unlocking/locking the bootloader will wipe the data partition, right?
It uses to work like this in Nexus and Pixel phones.

Inviato dal mio LG-V500 utilizzando Tapatalk
Guys the OP left out a very important step, flash stock boot.img, if you have TWRP or made any changes to boot.img/system.img the device won't boot, after locking the device you will get a black screen and go to 9008 mode, you will have to hold power + volume down to go to fastboot and then unlock again and flash stock boot, after that you can lock again
steps:
1. Reboot to fastboot by holding power + volume down for 5-10 seconds
2. oem fastboot unlock
3. fastboot flash boot_a (or boot_b if that's what you device is set to) [boot.img]
4. fastboot oem lock
5. fastboot reboot
When I installed the magisk then followed the all instructions but as I uninstall magisk I see my build.prop empty and as camera2api doesn't work and as I install magisk, build prop Appears and it starts working
Please help me


---------- Post added at 03:59 PM ---------- Previous post was at 03:58 PM ----------

Obviously unlocking/locking the bootloader will wipe the data partition, right?
It uses to work like this in Nexus and Pixel phones.

Inviato dal mio LG-V500 utilizzando Tapatalk

No, the Xiaomi a1 does not touch the data when unlocking/locking bootloader
 
  • Like
Reactions: giovaorama

Onkar Ingale

Member
Feb 5, 2018
10
2
You didn't read my problem

Guys the OP left out a very important step, flash stock boot.img, if you have TWRP or made any changes to boot.img/system.img the device won't boot, after locking the device you will get a black screen and go to 9008 mode, you will have to hold power + volume down to go to fastboot and then unlock again and flash stock boot, after that you can lock again
steps:
1. Reboot to fastboot by holding power + volume down for 5-10 seconds
2. oem fastboot unlock
3. fastboot flash boot_a (or boot_b if that's what you device is set to) [boot.img]
4. fastboot oem lock
5. fastboot reboot


---------- Post added at 03:59 PM ---------- Previous post was at 03:58 PM ----------



No, the Xiaomi a1 does not touch the data when unlocking/locking bootloader

You didn't get the problem please observe once again
 

harshu0101

Senior Member
Apr 17, 2013
210
53
Mumbai
Guys the OP left out a very important step, flash stock boot.img, if you have TWRP or made any changes to boot.img/system.img the device won't boot, after locking the device you will get a black screen and go to 9008 mode, you will have to hold power + volume down to go to fastboot and then unlock again and flash stock boot, after that you can lock again
steps:
1. Reboot to fastboot by holding power + volume down for 5-10 seconds
2. oem fastboot unlock
3. fastboot flash boot_a (or boot_b if that's what you device is set to) [boot.img]
4. fastboot oem lock
5. fastboot reboot


---------- Post added at 03:59 PM ---------- Previous post was at 03:58 PM ----------



No, the Xiaomi a1 does not touch the data when unlocking/locking bootloader

I thought when you completely uninstall magisk stock boot.img will be restored. Is that wrong?
 

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.