Camera & Camera2 API - missing features & bugs

Yes, dropping the permission would be best.

If it’s not done, at least for custom Roms it would be best to patch Android to just ignore that permission and provide it to all apps - not sure how hard that is. Maybe such a change would make sense for Linage OS in general.

The stock FPCamera app unfortunately is still not working without crashes if integrated in custom ROMs. But it’s able to access all cameras, when installed as SYSTEM_CAMERA app. I decompiled the camera app and now I’m trying to get behind some of the causes with remote debugging in Android Studio. But that’s time intensive and the learning curve for that is quite steep …

8 Likes

So the stock FPCamera App can come around all these missing features / bugs?
Or only accessing all camera lenses?

In general - if I get that right:

  • all non-stock apps (Open Camera, GCam Ports, etc. …) have the described problems, as they use the Camera2 API and
  • there are bugs in it for the FP Camera(s) Fairphone needs to fix, right?
  • So is this a closed source component (of the phone’s firmware)?
  • What is the stock FPCamera doing differently? How does it access the Camera’s?
  • How is /e/-OS dealing with it - as there is an official partnership?

As far as I can see, this was reported a while ago and the problem is well described by @Razem in the first post.

  • Is there any way the community can push this / push Fairphone to fix this?

I imagine they have heard the chatter and are doing all they can.

/e/-OS includes a modified version of OpenCamera that is installed as part of the system and has the SYSTEM_CAMERA permission. Only with that permission it’s possible to use the Wide Angle camera. e / os / Camera · GitLab

User-installed camera apps are unable to use the wide angle camera. That’s not really a bug but was done that way by design. Not sure how common this is. On a Pixel Phone, can third party apps use auxiliary cameras?

The part that defines which camera is a system camera is closed source, unfortunately. Fairphone should change this to make everything accessible by all apps.

Another thing is that some open source Android components seem to be modified with Fairphone specific proprietary extensions (i.e. libcameraservice from camera · ks-aosp.lnx.3.0.r4-rel · CodeLinaro / la / platform / frameworks / av · GitLab). Fairphone could release that modifications as open source, but due to Apache 2.0 License there is no obligation, unfortunately. That mostly matters for custom roms.

5 Likes

I assume when many unhappy people contact them, they might work on this (faster)…so I would say #contactsupport

3 Likes

Thanks @xblax for the details.

Only point I don’t get which seems to be not answered to me is:
Does the e / os / camera have all the other issues/bugs described here apart from the possibility to use the wide angle camera?

In general to deal with that, as long as it not fixed by Fairphone:
Why not using the “e / os / camera” and transform it to a system app for now? (also for other custom roms)
I know there are people which prefer the Gcam (or the ports) in regards of the photo quality, but still, I think Open Camera is a good camera app, which fits, at least to my needs. So is there a place where one can get the “e / os / camera” as apk or do I need to create an APK on my own out of the code in GitLab (never did that up to now but I’m willing to find out)?

@yvmuell

Will do. :wink:

Hi @Smojo

Does the e / os / camera have all the other issues/bugs described here apart from the possibility to use the wide angle camera?

I have not tried e-/os/ myself. But all third party camera apps do not get access to the full 16MP resolution - that is definitely a bug. I also tried GrapheneOs Camera which uses CameraX instead of using Camera2 APIs directly - only ~12MP.

At the moment I cannot say if that is due to missing SYSTEM_CAMERA permission or not. I will try to find out.

Might also be related to another “feature” in the Camera implementation. Basically there’s a check which camera app uses the camera APIs. If it’s the stock camera app it uses a different capture pipeline.

On custom roms we could theoretically force to use the Fairphone pipelines for all apps, but for example the stock AOSP camera app crashes immediately then.

Not sure what’s the reason behind this. I found some references to other Qualcomm based phones doing the same. Don’t think that comes from Qualcomm but rather from the ODM which does the camera integration.

Here is a discussion in German that indicates that with #leos the wide angel lense is accessible e.g. with BigKaka Gcam port and the statement is “it works because its a GSI ROM based on PHH Treble with treble settings phhusson. The advantage of GSIs is that they use the standard kernel what allows to use all OEM funtions…” (no idea if this is correct or what it really means but maybe it helps to troubleshoot this).

3 Likes

I’ve had a look at that before, but still couldn’t make wideangle work on non stock, not even for the FPCamera (then again, not a developer, just randomly trying things… ).

For people who want to take a look, the settings app is here, relevant code likely here:

MiscSettings.multiCameras -> {
    val value = sp.getBoolean(key, false)

    safeSetprop("persist.sys.phh.include_all_cameras", if(value) "true" else "false")
    if (value ||
            SystemProperties.get("vendor.camera.aux.packagelist", null) == null ||
            SystemProperties.get("camera.aux.packagelist", null) == null) {
        safeSetprop("vendor.camera.aux.packagelist", if (value) "nothing" else null)
        safeSetprop("camera.aux.packagelist", if (value) "nothing" else null)
        safeSetprop("ctl.restart", "vendor.camera-provider-2-4")
        safeSetprop("ctl.restart", "camera-provider-2-4")
        safeSetprop("ctl.restart", "cameraserver")
    }
}
MiscSettings.forceCamera2APIHAL3 -> {
    val value = sp.getBoolean(key, false)
    val defValue = "0"
    val newValue = if (value) "1" else defValue

    if (value ||
            SystemProperties.get("persist.vendor.camera.HAL3.enabled", defValue) != newValue ||
            SystemProperties.get("persist.vendor.camera.eis.enable", defValue) != newValue) {
        safeSetprop("persist.vendor.camera.HAL3.enabled", newValue)
        safeSetprop("persist.vendor.camera.eis.enable", newValue)
        Log.d("PHH", "forced Camera2API HAL3 to $value")
        // Restart services
        safeSetprop("ctl.restart", "vendor.camera-provider-2-4")
        safeSetprop("ctl.restart", "camera-provider-2-4")
    }
}
2 Likes

Thanks @yvmuell interesting infos.

Had to update myself about this topic (Treble) again.

  • DSI - Generic System Image
  • Phhusson is a developer

So the project exist since Android 8 - Oreo (https://apilevels.com/).
So do all the custom roms (except #leos) still skip / ignore it?

I think the relevant code in that GSI rom is that change here:

If the property is enabled it then treats the camera as public and ignores that the HAL flagged the camera as system only.

I tried various Camera Apps and patched them to have SYSTEM_CAMERA permission (GrapheneOs, Camera2 Api Prober, Open Camera). Only Open Camera then detects the Wide Angle Camera, for the other apps there appears to be no change.

Open Camera can use the full 4000x3000 resolution, even without SYSTEM_CAMERA permission.

In the Android documentation I found this:

Starting from API level 29:

Some or all physical cameras may not be independently exposed to the application, in which case the physical camera IDs will not be available in CameraManager.getCameraIdList(). But the application can still query the physical cameras’ characteristics by calling CameraManager.getCameraCharacteristics(String).

Maybe the wide angle lens is not exposed at all via Camera2? But OpenCamera somehow detects it, which the other apps can’t.

Also interesting: in OpenCamera 4000x3000 resolution is listed as not “Burst” capable. So maybe the other apps only request burst capable modes?

Unless Fairphone improves how Cameras and Modes are exposed it’s probably our best option to get the Stock camera fully functional on custom roms.

7 Likes

Edited the last post because it was not fully correct: With SYSTEM_CAMERA permission Open Camera v1.50.1 appears to be fully functional, even in Camera2 mode it can access the Wide Angle Lens and full resolution.

It’s accessed in the UI differently than in Legacy API Mode which got me confused.

3 Likes

You are completely right, that’s the more relevant part of code. I was referring to the code in the settings app that lets you toggle it (which didn’t get me very far with my own experiments).
Interestingly enough, the commit you linked is dated July 16th, but we have reports of a working wide-angle lens on LeOS from June, so as always with Camera2, it’s complicated :man_shrugging:

That’s probably the best interim solution, but you seem to make great progress here, keep up the good work :smiley:

I think that’s because for each release they rebase their changes onto the upstream repo. There are older versions of that commit around:

2 Likes

Makes sense, my bad :see_no_evil:

@xblax

+1


Dump question from someone less experienced than you guys:
How to you “patch” the camera apps?
Where exactly is the SYSTEM_CAMERA permission set? Or is this equal to install the Camera Apps as system app? EDIT: source.android.com - docs - system-cameras

Open Camera can use the full 4000x3000 resolution, even without SYSTEM_CAMERA permission.

4000x3000 is 12MP (and yes Open Camera shows this as max resolution, also without modification/patching or after a normal installation), while the cameras have 48MP in the specs - afaiu.
Or is this the “Pixel Binning” I read about (best of 4 Pixels will be taken), which reduces the 48-Megapixel-photos to 12 Megapixel?

(default Camera of CalyxOS - package com.android.camera2 - also shows 12MP as max resolution :thinking: but I only see one back camera in settings.)

After these facts, why it the overall interim conclusion to use the Stock camera or make it working?

The 12MP resolution (4000x3000) is accessible when using the old camera API. When using Camera2, it tops at 3952x1824 for some unknown reason. The primary sensor (IMX582) is actually capable of taking 48MP (8000x6000) photos, as seen in the stock camera app. The same applies to the selfie camera (IMX576), which is capable of taking 24MP (5760×4312) photos. The ultra-wide sensor is advertised as 48MP (I can’t find the exact sensor number), but I guess it uses binning, so you can’t really get a 48MP photo out of it, only 12MP.

The permission must be declared in the AndroidManifest.xml of the APK. This is where existing APKs need to be patched or compiled with the change. See

Then the app must be installed in /system/priv-app (or on the vendor partition). It must also be granted the system camera in /system/etc/permissions. For the stock camera we add privapp-permissions-com.fp.camera.xml

<?xml version="1.0" encoding="utf-8"?>
<permissions>
    <privapp-permissions package="com.fp.camera">
        <permission name="android.permission.SYSTEM_CAMERA"/> 
    </privapp-permissions>
</permissions>

And last the camera package name must also be whitelisted in vendor.camera.aux.packagelist property. It’s easier to disable that property so that it’s empty. Then all apps are allowed if they fulfill the other requirements …

Camera2 from AOSP shows 12MP in the settings, but the captured image is not. I didn’t try modify if for SYSTEM_CAMERA permission. Also don’t know if it supports aux cameras at all.

I believe 12MP is the intended native resolution of the sensor. The “high res” 48mp images are probably only available in a special capture mode. Afaik that is a function of the Qualcomm camera HAL but the camera Apps need special support for it.

Because it implements all the features like High Res, Timelapse, Slomo etc and it can be extracted from the stock images like the other blobs. Usability is easier than for OpenCamera. Also I think it’s probably the best baseline for custom ROMs to see what features are working and which are not.

2 Likes

A post was merged into an existing topic: FP4 Stock Camera app on /e/ or Iodé

Answer by fairphone:


I will be unable to provide you further help regarding alternative/custom OS, but you can find some tips on … → links to the FP Forum and the e Forum for Fairphones …

We will take your feedback into consideration for our future developments.

We appreciate your response as it is very helpful for us and it gives a good insight into the wishes and needs of our community.

Thats it → pretty much a standard response, but I think it doesn’t make sense to bother them further, as they are already aware of the problem and they just got another feedback from a user who would like to get this fixed. → which is/was the intention here.

2 Likes