Android P camera error

Hello,
I’m working with a camera on hikey android P, I get this errors as follow, who can help me?

I CameraProviderManager: Connecting to new camera provider: legacy/0, isRemote? 1
I CameraProviderManager: Enumerating new camera device: device@3.2/legacy/0
I CameraProviderManager: Enumerating new camera device: device@3.2/legacy/1
I CameraProviderManager: Camera provider legacy/0 ready with 2 camera devices
I CameraHardwareInterface: Opening camera 0
E CameraHardwareInterface: initialize: openSession failed! No such file or directory (-2)
E CameraFlashlight: connectCameraDevice: initializing camera 0 failed
I CameraHardwareInterface: Destroying camera 0
E CameraFlashlight: findFlashUnits: failed to check if camera 0 has a flash unit. No such file or directory (-2)

Thanks&Kind regards.

What camera are you using (USB?) and what modification did you apply to the build to enable this camera?

Hi Loic,
Thanks in advance.
I used a USB camera, my AOSP version is P and security patch is October 5, 2017.
I found the camera service was running well, I have no idea what caused this error:
CameraHardwareInterface: initialize: openSession failed! No such file or directory (-2)
I think if this error is fixed, the camera will be OK.

Kind regards.

Hi Loic,

status_t CameraHardwareInterface::initialize(sp manager) {
ALOGI(“Opening camera %s”, mName.string());
status_t ret = manager->openSession(mName.string(), this, &mHidlDevice);
if (ret != OK) {
ALOGE("%s: openSession failed! %s (%d)", FUNCTION, strerror(-ret), ret);
}
return ret;
}

What caused this function cannot be implemented?

Kind regards.

So i’m pretty sure AOSP doesn’t support usb camera out of the box. you will need to create a usb camera hal (i’m not sure if aosp has usb camera hal in source) and enable v4l2 in kernel which i know is disabled by default.
These are the minimum steps required afaik.

Correct, AFAIK, there is ongoing effort to support V4l2 interface and so USB camera, i’ll check tthat.

So the android-x86 project already has that enable. I never got around to look into that.

Hi Loic & ric96,
How to fix AOSP build error as this :

[ 0% 1/56722] build out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
FAILED: out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
/bin/bash -c “(rm -f out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows ) && (ASAN_OPTIONS=detect_leaks=0 out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/policy.conf )”
device/linaro/hikey/sepolicy/hostapd.te:4:ERROR ‘unknown type hostapd’ at token ‘;’ on line 45529:

hostapd no longer directly accesses /data outside /data/vendor.

typeattribute hostapd data_between_core_and_vendor_violators;
checkpolicy: error(s) encountered while parsing configuration
out/host/linux-x86/bin/checkpolicy: loading policy configuration from out/target/product/hikey970/obj/ETC/sepolicy_neverallows_intermediates/policy.conf
13:17:01 ninja failed with: exit status 1

Thanks & kind regards

‘hostapd’ does not seem to be a defined selinux/sepolicy type in your setup, usually it’s define in

https://android.googlesource.com/platform/system/sepolicy/+/ad3cb39/hostapd.te

Loic, your meaning is using this file instead of ‘device/linaro/hikey/sepolicy/hostapd.te’ ?

Kind regards.

I’m guessing that you are trying to build AOSP as per the device documentation, which means that this is the source of your device repository;

Am I correct?

If so, then it looks like that device repository is based off of the hikey[/960] repository, and in particular, its a pretty old fork of that. You would probably be well advised to follow the evolution of the hikey[/960] repository and apply similar changes to your 970.

For example;
The hostapd.te file was DELETED from the hikey[/960] repository.
https://android.googlesource.com/device/linaro/hikey/+/5ea6bb3d6cca3ab43edf62bb31d39dfbd8aee625^!/#F0

Thank you, doitright,
Let me have a try.
Kind regards