While trying to figure out the problems with video recordings (which were resolved – Praise God!) on the SGH-M919 AOKP Marshmallow ROM, I learned a lot of great things about Android’s camera systems. Not the least of which was how to enable or disable camera and camera2 api’s.

Android has a built in api that handles camera requests. To be more accurate, Android currently has 2. Originally, Android used the camera api, which had a handler that was built into Android, under the source code, and controlled by camera, nested in “packages/apps/camera”. Later, Android phones stated to come with better cameras with more functions, so the camera2 api was built, and controlled from camera2, nested in “packages/apps/camera2”. What exactly is different between the two, I am not sure. Needless to say camera2 has more functionality with modern cameras.

However, despite having more functionality, what I did find is that Android, all the way up to Marshmallow, still has the old built in camera api. What I also found, though, is that it isn’t used anymore. That’s right, if your rom/source/etc. comes with Camera2, that is what the system calls on to handle the camera for things like photos, video recording, skype, etc.

In my travels and trial, though, I also learned that you can “turn on” the old camera api, and “turn off” the new camera2 api, but building and not building the appropriate packages. Most of the roms I deal with still have “packages/apps/camera” there, but the contents are edited or missing so it will not build. I successfully built the old camera api controller by downloading this and putting it in the “packages/apps/camera” folder.

https://github.com/AOKP/packages_apps_Camera/tree/ics

After unzipping it and placing those files in that folder, I then had to edit the “packages/apps/camera2/Android.mk” file like so:

[CODE]
LOCAL_PATH := $(call my-dir)

# leaving the makefile emtpy to prevent the build
# system from traversing the project
[/CODE]

Another option is to delete the camera2 folder entirely, but you may need it later. You can also rename the Android.mk files in the camera2 folder to Android.bak instead. Any of these options will work. In either event, after compiling my ROM, the camera2 app did not get built, so, using OpenCamera, it then worked as before, but with the old camera api! To be honest, I didn’t take too much time for comparisons, but I couldn’t tell the difference in the photo quality. Then again, my phone is a bit older, and perhaps only brand new phones will have cameras that this would actually make a difference.

Linux – keep it simple.

One Reply to “Enabling the old Camera api and apps in Android 5 and up”

Leave a Reply

Your email address will not be published. Required fields are marked *