Android Automotive: External USB Camera

I’m trying to connect a usb camera to android automotive, but the application I created doesn’t detect it (CameraManager says there are no cameras connected).
In the system logs I found this.

01-01 00:00:09.119 209 209 I android.hardware.camera.provider@2.4-external-service: External camera provider service is starting.
01-01 00:00:09.545 210 210 I android.hardware.camera.provider@2.4-external-service: CameraProvider@2.4 external webcam service is starting.
01-01 00:00:09.575 210 210 I ExtCamUtils@3.4: loadFromCfg: load external camera config succeed!
01-01 00:00:09.575 210 210 I ExtCamUtils@3.4: loadFromCfg: device 0 will be ignored by external camera provider
01-01 00:00:09.746 209 209 I ServiceManagement: Removing namespace from process name android.hardware.camera.provider@2.4-external-service to provider@2.4-external-service.
01-01 00:00:09.746 209 209 I android.hardware.camera.provider@2.4-external-service: Registration complete for android.hardware.camera.provider@2.4::ICameraProvider/external/0.
01-01 00:00:10.434 245 245 I cameraserver: ServiceManager: 0xab2a91a0
01-01 00:00:10.449 245 245 I cameraserver: type=1400 audit(0.0:23): avc: denied { read } for name=“android.hardware.camera.provider@2.4-impl.so” dev=“mmcblk0p3” ino=325 scontext=u:r:cameraserver:s0 tcontext=u:object_r:vendor_file:s0 tclass=file permissive=1
01-01 00:00:10.451 245 245 E vndksupport: Could not load /vendor/lib/hw/android.hardware.camera.provider@2.4-impl.so from sphal namespace: dlopen failed: library “android.hardware.camera.common@1.0.so” not found.
01-01 00:00:10.451 245 245 E ServiceManagement: Failed to dlopen android.hardware.camera.provider@2.4-impl.so: unknown error
01-01 00:00:10.462 245 245 I ServiceManagement: getService: Trying again for android.hardware.camera.provider@2.4::ICameraProvider/legacy/0…
01-01 00:00:11.462 245 245 W ServiceManagement: Waited one second for android.hardware.camera.provider@2.4::ICameraProvider/legacy/0
01-01 00:00:11.463 245 245 I ServiceManagement: getService: Trying again for android.hardware.camera.provider@2.4::ICameraProvider/legacy/0…
01-01 00:00:11.609 210 210 I ExtCamHotPlug: type=1400 audit(0.0:27): avc: denied { watch } for path="/dev" dev=“tmpfs” ino=10241 scontext=u:r:hal_camera_default:s0 tcontext=u:object_r:device:s0 tclass=dir permissive=1
01-01 00:00:12.463 245 245 W ServiceManagement: Waited one second for android.hardware.camera.provider@2.4::ICameraProvider/legacy/0
01-01 00:00:12.464 245 245 I ServiceManagement: getService: Trying again for android.hardware.camera.provider@2.4::ICameraProvider/legacy/0…
09-26 11:36:00.191 370 370 I SystemServiceManager: Starting com.android.server.camera.CameraServiceProxy
09-26 11:36:00.852 370 370 W CameraService_proxy: Could not notify cameraserver, camera service not available.
09-26 11:36:00.852 370 370 I CameraService_proxy: Could not notify camera service of user switch, retrying…
09-26 11:36:00.852 370 370 D SystemServiceManager: onStartUser-0 com.android.server.camera.CameraServiceProxy took to complete: 2ms
09-26 11:36:00.871 370 484 W CameraService_proxy: Could not notify cameraserver, camera service not available.

I see two problems in your logs.

  1. a couple of AVC denied. That’s an selinux error, what you are running does not have permission to access hardware it is trying to access, including MMC and /dev (seems to be monitoring for /dev/videoX?)

  2. missing library. You should figure out what package provides that library and include it in your build.

How can I give SELinux permissions ?