Camera2 API development

I tried with make clean when i switched the branch. And i think libdroidmedia is the correct make target.

For the xa2 i needed additionally libncurses5, python2 and LC_ALL=C is required. (that is at least as far as i got). I am currently trying to build a dockerfile that includes all the requirements i needed.


I got the now for the XA2:

build with this script in ./makelib

# have jdk8 and the repo tool from android installed
export VENDOR=sony
export DEVICE=h4113
export HABUILD_DEVICE=pioneer
export FAMILY=nile
export BRANCH=8.1.0_r52
export HAVERSION="hybris-sony-aosp-"$BRANCH"_20190206"
export PORT_ARCH=aarch64
export LC_ALL=C

cd build
source build/
export USE_CCACHE=1
lunch aosp_h4113-eng
make -j$(nproc --all) droidmedia

on this docker image in docker/Dockerfile

FROM python:2.7-buster
ENTRYPOINT [ "/bin/bash" ]
RUN apt-get update && apt-get install -y \
  software-properties-common  build-essential gcc-multilib make ccache libncurses5 \
  && wget -qO - | apt-key add - \
  && add-apt-repository --yes \
  && apt-get update && apt-get install -y adoptopenjdk-8-hotspot \
  && rm -rf /var/cache/apk/*


  • Setup the repositories with repo and clone droidmedia into build/
# have jdk8 and the repo tool from android installed
cd build
export VENDOR=sony
export DEVICE=h4113
export HABUILD_DEVICE=pioneer
export FAMILY=nile
export BRANCH=8.1.0_r52
export HAVERSION="hybris-sony-aosp-"$BRANCH"_20190206"
export PORT_ARCH=aarch64
repo init -u -b $HAVERSION -m tagged-manifest.xml
repo sync -c --fetch-submodules
git clone droid-src
git clone external/droidmedia
  • write the build script to makelib and the dockerfile to docker/
  • run docker build docker/ and get the image hash
  • run docker run -it -v(pwd):/camera2api -w /camera2api <imagehash> to get into the image
  • execute bash makelib
  • find libdroidmedia in build/out/target/product/pioneer/system/lib/ (or maybe lib64 if you are on another device)
  • if this works run cd build && make clean && cd ..
  • now you can switch the branch for droidmedia and rebuild with the camera2 api
  • deploy it to /usr/libexec/droid-hybris/system/lib/ on your phone (maybe lib64 on other devices.make sure you do not mix lib and lib64 :wink:

I don’t why make droidmedia did not include the libdroidmedia target but now I was able to successfully build the lib. Thanks @thigg !

I can confirm the inverted viewfinder colors, looks fancy actually. Photos have correct color and are taken as fast as in OpenCamera :+1:

@mal A list with known open todos would be super useful or maybe even an issue for each. Feel free to dump a list here and have the community turn it into proper issues. I assume we then open PRs against the camera2 branch and merge to master once ready?


The inverted color issue sounds like a wrong pixel format, but if it was just that, it would already be corrected… Let’s hope that’s not a firmware issue that needs to be worked around…

I’m excited about the progress! I wish I had more hours in a day so I could participate in this, but unfortunately I don’t…


We can certainly create new issues on the droidmedia project, maybe prefix them all with [Camera2]. What we miss is something of a milestone or label created for that, but that’s details.

We have esr91 milestone in Issues · sailfishos/sailfish-browser · GitHub and that looks very clear to me. Maybe having milestone “camera2” for each camera2 related issue. Some food for thought.


Hi @rainemak, I fully agree that a milestone/label with “camera2” would help, however I don’t think any of us can create it. Can you or @mal create this and we’ll just use it? Thanks!


Hi @vlagged ! Created camera2 label (for colored issues) and milestone

Please use flag both camera2 label and milestone when going forward.


So, if released, Camera API 2.0 will affect all SailfishOS-Units also the Ports?

1 Like

A small status update on Camera2 support. I managed to find a fix for the viewfinder color issue. I also have almost working video recording support which does record the video and I can see the first frame of the video when playing it but because of some issue with frame timestamps all later frames are skipped. These changes are not yet in the camera2 branch because I need to cleanup the code again after the a bit ugly code that was created during debugging of the issues.

As for the question in previous comment: current plan is that Camera2 support would be available for all devices which are built on Android 7 or newer base. Community ports need to have their adaptation packages updated to get the support so schedule of that depends on each porter when they will do that after the support is finalized and merged.


I just tried the camera2 branch on my xperia 10-iii. The nice thing is, that camera usage does not interfere anymore with android. I can use android and sfos applications using the camera and it just works :slight_smile:

although the quality seems to be better in sfos…


by any chance, does anyone have camera2 built for 10iii?
i would love to not have OpenCamera and jolla-camera crash each other all the time, but not quiiite enough to undertake that build procedure

Unfortunately none of us had time to work on it the last few months so it is still not super functional (no video, no torch, no creative modes, strange exposure settings, …)


thanks. i know it’s not ready, and i was still interested in trying out the camera2 lib, to test it out, and see if it fixed the crashes in android OpenCamera.

however, after reading the issue you wrote more carefully, i see that the torch doesn’t work even outside the camera app, and you’re correct, i rely on the torch too much to use it as-is.

anyway, thanks so much for the work you folks have been doing on this!

no commits since november. has this hit an insurmountable block, or is everyone just too busy on 4.6/etc?

1 Like

As i understood it it was a private effort and not done by jolla, but maybe that changed now


I have been too busy with other work to focus on camera 2 API development. Hopefully I’ll manage to find time soon to continue with the missing pieces. There is are some a bit difficult issues to solve but nothing that couldn’t be figured out.