remote-android / redroid-doc

redroid (Remote-Android) is a multi-arch, GPU enabled, Android in Cloud solution. Track issues / docs here
4.11k stars 295 forks source link

can't connect camera to redroid #174

Closed ArtBreguez closed 2 years ago

ArtBreguez commented 2 years ago

I'm trying to connect my usb camera via usb-redirector, i got the webcam data

Bus 001 Device 006: ID 1b3f:2247 Generalplus Technology Inc. GENERAL WEBCAM

started the usbredirector service

sudo usbredirserver -p 7700 1b3f:2247

and started the container as:

docker run -itd --rm --memory=4g --cpus="2" --memory-swappiness=0 --privileged \ --pull always \ -v ~/data4444:/data \ -p 1111:5555 \ -e EXTRA="-chardev socket,id=usbredirchardev1,port="7700",host="172.17.0.1" -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=ehci.0,debug=4" \ redroid/redroid:12.0.0-latest \ redroid.gpu.mode=guest \ redroid.width=720 \

but i cant get the camera working https://files.slack.com/files-pri/T020NHT0ZS7-F03K6S2TG5R/captura_de_tela_2022-06-10_a__s_15.13.07.png

here the logs

beyond0:/ # logcat | grep camera 06-10 17:37:24.177 0 0 I init : Command 'copy /dev/cpuset/cpus /dev/cpuset/camera-daemon/cpus' action=init (/system/etc/init/hw/init.rc:349) took 0ms and failed: Could not read input file '/dev/cpuset/cpus': open() failed: No such file or directory 06-10 17:37:24.177 0 0 I init : Command 'copy /dev/cpuset/mems /dev/cpuset/camera-daemon/mems' action=init (/system/etc/init/hw/init.rc:350) took 0ms and failed: Could not read input file '/dev/cpuset/mems': open() failed: No such file or directory 06-10 17:37:24.827 0 0 I init : starting service 'cameraserver'... 06-10 17:55:16.516 0 0 I init : Parsing file /system/etc/init/cameraserver.rc... 06-10 17:55:16.662 0 0 I init : Command 'copy /dev/cpuset/cpus /dev/cpuset/camera-daemon/cpus' action=init (/system/etc/init/hw/init.rc:349) took 0ms and failed: Could not read input file '/dev/cpuset/cpus': open() failed: No such file or directory 06-10 17:55:16.662 0 0 I init : Command 'copy /dev/cpuset/mems /dev/cpuset/camera-daemon/mems' action=init (/system/etc/init/hw/init.rc:350) took 0ms and failed: Could not read input file '/dev/cpuset/mems': open() failed: No such file or directory 06-10 17:55:17.139 0 0 I init : starting service 'cameraserver'... 06-13 11:58:28.690 0 0 I init : Parsing file /system/etc/init/cameraserver.rc... 06-13 12:08:24.696 0 0 I init : Parsing file /system/etc/init/cameraserver.rc... 06-13 12:08:24.839 0 0 I init : Command 'copy /dev/cpuset/cpus /dev/cpuset/camera-daemon/cpus' action=init (/system/etc/init/hw/init.rc:349) took 0ms and failed: Could not read input file '/dev/cpuset/cpus': open() failed: No such file or directory 06-13 12:08:24.839 0 0 I init : Command 'copy /dev/cpuset/mems /dev/cpuset/camera-daemon/mems' action=init (/system/etc/init/hw/init.rc:350) took 0ms and failed: Could not read input file '/dev/cpuset/mems': open() failed: No such file or directory 06-13 12:08:25.213 0 0 I init : starting service 'cameraserver'... 06-13 12:16:45.584 0 0 I init : Parsing file /system/etc/init/cameraserver.rc... 06-13 12:16:45.731 0 0 I init : Command 'copy /dev/cpuset/cpus /dev/cpuset/camera-daemon/cpus' action=init (/system/etc/init/hw/init.rc:349) took 0ms and failed: Could not read input file '/dev/cpuset/cpus': open() failed: No such file or directory 06-13 12:16:45.731 0 0 I init : Command 'copy /dev/cpuset/mems /dev/cpuset/camera-daemon/mems' action=init (/system/etc/init/hw/init.rc:350) took 0ms and failed: Could not read input file '/dev/cpuset/mems': open() failed: No such file or directory 06-13 12:16:56.634 108 108 I cameraserver: ServiceManager: 0x79e1ba81ac10 06-13 12:16:56.686 108 108 I cameraserver: Waiting for activity service 06-13 12:16:59.391 340 340 W PackageSettings: Missing permission state for package: com.android.cameraextensions 06-13 12:16:59.609 108 108 I cameraserver: Waiting for sensor privacy service 06-13 12:16:59.695 108 108 I HidlServiceManagement: Registered android.frameworks.cameraservice.service@2.2::ICameraService/default 06-13 12:16:59.698 108 108 I CameraService: CameraService pinged cameraservice proxy 06-13 12:16:59.700 108 108 I cameraserver: ServiceManager: 0x79e1ba81ac10 done instantiate 06-13 12:16:59.957 340 340 I SystemServiceManager: Starting com.android.server.camera.CameraServiceProxy 06-13 12:16:59.958 340 340 I SystemServerTiming: OnBootPhase_200_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.158 340 340 I SystemServerTiming: OnBootPhase_480_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.168 340 340 I SystemServerTiming: OnBootPhase_500_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.245 340 340 I SystemServerTiming: OnBootPhase_520_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.255 340 388 I SystemServerTimingAsync: InitThreadPoolExec:Update app-ops uidState in case package com.shenyaocn.android.usbcamera changed 06-13 12:17:00.255 340 388 D SystemServerInitThreadPool: Started executing Update app-ops uidState in case package com.shenyaocn.android.usbcamera changed 06-13 12:17:00.255 340 388 D SystemServerInitThreadPool: Finished executing Update app-ops uidState in case package com.shenyaocn.android.usbcamera changed 06-13 12:17:00.504 340 340 I SystemServerTiming: OnBootPhase_550_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.613 340 340 I SystemServerTiming: OnBootPhase_600_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.627 340 340 I SystemServerTiming: ssm.onStartUser-0_com.android.server.camera.CameraServiceProxy 06-13 12:17:00.628 340 340 V StorageManagerService: Package com.android.camera2 does not have legacy storage 06-13 12:17:00.628 340 340 V StorageManagerService: Package com.android.cameraextensions does not have legacy storage 06-13 12:17:00.628 340 340 V StorageManagerService: Package com.shenyaocn.android.usbcamera has legacy storage 06-13 12:17:01.585 340 719 I ActivityManager: ntv ?? 11118: cameraserver (pid 108) native 06-13 12:17:02.938 479 479 I CameraManagerGlobal: Connecting to camera service 06-13 12:17:03.458 479 479 D QSTileHost: Creating tile: cameratoggle 06-13 12:17:03.458 479 479 D QSTileHost: Destroying not available tile: cameratoggle 06-13 12:17:03.512 340 360 I ActivityManagerTiming: OnBootPhase_1000_com.android.server.camera.CameraServiceProxy 06-13 12:17:03.585 340 366 I SystemServerTimingAsync: ssm.onUnlockingUser-0_com.android.server.camera.CameraServiceProxy 06-13 12:17:03.687 340 366 I SystemServerTimingAsync: ssm.onUnlockedUser-0_com.android.server.camera.CameraServiceProxy 06-13 12:17:04.907 340 367 I ActivityManager: Start proc 1135:com.android.camera2/u0a55 for broadcast {com.android.camera2/com.android.camera.SetActivitiesCameraReceiver} 06-13 12:17:04.917 1135 1135 W android.camera: Unexpected CPU variant for X86 using defaults: x86_64 06-13 12:17:05.113 1135 1135 V GraphicsEnvironment: ANGLE Developer option for 'com.android.camera2' set to: 'default' 06-13 12:17:05.113 1135 1135 V GraphicsEnvironment: ANGLE GameManagerService for com.android.camera2: false 06-13 12:17:05.189 1135 1135 I CAM_SetActivitiesCamera: number of camera: 0 06-13 12:17:07.298 340 367 I ActivityManager: Start proc 1355:com.shenyaocn.android.usbcamera/u0a72 for broadcast {com.shenyaocn.android.usbcamera/com.shenyaocn.android.usbcamera.BootReceiver} 06-13 12:17:07.498 1355 1355 V GraphicsEnvironment: ANGLE Developer option for 'com.shenyaocn.android.usbcamera' set to: 'default' 06-13 12:17:07.502 1355 1355 V GraphicsEnvironment: ANGLE GameManagerService for com.shenyaocn.android.usbcamera: false 06-13 12:17:07.588 1355 1379 W Ads : Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.measurement.DynamiteMeasurementManager" on path: DexPathList[[zip file "/data/app/~~JCYHcgkmEp7DxH5DZrtg4w==/com.shenyaocn.android.usbcamera-DVO5WP6nNBa725jdJSNgVQ==/base.apk"],nativeLibraryDirectories=[/data/app/~~JCYHcgkmEp7DxH5DZrtg4w==/com.shenyaocn.android.usbcamera-DVO5WP6nNBa725jdJSNgVQ==/lib/x86_64, /data/app/~~JCYHcgkmEp7DxH5DZrtg4w==/com.shenyaocn.android.usbcamera-DVO5WP6nNBa725jdJSNgVQ==/base.apk!/lib/x86_64, /system/lib64]] 06-13 12:17:07.690 1355 1383 I FA : adb shell setprop debug.firebase.analytics.app com.shenyaocn.android.usbcamera 06-13 12:17:07.703 1355 1383 W GooglePlayServicesUtil: com.shenyaocn.android.usbcamera requires the Google Play Store, but it is missing. 06-13 12:17:08.384 340 646 I ActivityManager: Killing 1135:com.android.camera2/u0a55 (adj 975): empty #17 06-13 12:18:22.749 108 108 E CameraService: cameraIdIntToStrLocked: input id 0 invalid: valid range (0, 0) 06-13 12:18:22.749 108 108 I CameraService: CameraService::connect call (PID -1 "com.whatsapp", camera ID ) and Camera API version 1 06-13 12:18:22.749 108 108 E CameraService: validateClientPermissionsLocked: Invalid camera id , skipping 06-13 12:18:22.749 1386 2169 W CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '3: validateClientPermissionsLocked:1202: No camera device with ID ""found while trying to query device kind' 06-13 12:18:24.896 108 108 E CameraService: cameraIdIntToStrLocked: input id 0 invalid: valid range (0, 0) 06-13 12:18:24.896 108 108 I CameraService: CameraService::connect call (PID -1 "com.whatsapp", camera ID ) and Camera API version 1 06-13 12:18:24.896 108 108 E CameraService: validateClientPermissionsLocked: Invalid camera id , skipping 06-13 12:18:24.896 1386 2169 W CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '3: validateClientPermissionsLocked:1202: No camera device with ID ""found while trying to query device kind' 06-13 12:18:26.115 108 1402 E CameraService: cameraIdIntToStrLocked: input id 0 invalid: valid range (0, 0) 06-13 12:18:26.115 108 1402 I CameraService: CameraService::connect call (PID -1 "com.whatsapp", camera ID ) and Camera API version 1 06-13 12:18:26.115 108 1402 E CameraService: validateClientPermissionsLocked: Invalid camera id , skipping 06-13 12:18:26.115 1386 2169 W CameraBase: An error occurred while connecting to camera 0: Status(-8, EX_SERVICE_SPECIFIC): '3: validateClientPermissionsLocked:1202: No camera device with ID ""found while trying to query device kind'

zhouziyang commented 2 years ago

take a look at https://source.android.com/devices/camera/external-usb-cameras and https://android.googlesource.com/platform/hardware/libhardware/+/master/modules/camera/3_4/ (not maintained by Android) you need implement related Camera HIDL service.

ArtBreguez commented 2 years ago

can i implement into redroid built image or i'll need to do it when building redroid from aosp?

ArtBreguez commented 2 years ago

I just made the changes on redroid.mk, it should look something like this?

# Copyright (C) 2013 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PRODUCT_MANUFACTURER := redroid

#$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk)

$(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)

# no kernel involved
PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS := false

PRODUCT_USE_DYNAMIC_PARTITION_SIZE := true
**USE_CAMERA_V4L2_HAL := true**
PRODUCT_BUILD_CACHE_IMAGE := false
PRODUCT_BUILD_ODM_IMAGE := false
PRODUCT_BUILD_PRODUCT_IMAGE  := false
PRODUCT_BUILD_PRODUCT_SERVICES_IMAGE := false
PRODUCT_BUILD_RAMDISK_IMAGE := false
PRODUCT_BUILD_SUPER_PARTITION := false
PRODUCT_BUILD_SYSTEM_OTHER_IMAGE := false
PRODUCT_BUILD_USERDATA_IMAGE := false
PRODUCT_BUILD_VBMETA_IMAGE := false
PRODUCT_BUILD_VENDOR_IMAGE := true
ifeq ($(BUILD_VENDOR_ONLY), true)
PRODUCT_BUILD_SYSTEM_IMAGE := false
else
PRODUCT_BUILD_SYSTEM_IMAGE := true
endif

PRODUCT_SHIPPING_API_LEVEL := 30

AUDIOSERVER_MULTILIB := first

# ?
PRODUCT_PROPERTY_OVERRIDES += \
    ro.radio.noril=yes
    **ro.hardware.camera=v4l2**

PRODUCT_PROPERTY_OVERRIDES += \
    debug.sf.nobootanimation=1

PRODUCT_PACKAGES += \
    binder_alloc \
    hwcomposer.redroid \
    gralloc.gbm \
    gralloc.redroid \
    libEGL_swiftshader \
    libGLESv1_CM_swiftshader \
    libGLESv2_swiftshader \
    vulkan.pastel \
    ipconfigstore \
    **camera.v4l2**

PRODUCT_PROPERTY_OVERRIDES += \
    ro.kernel.qemu=1 \
    ro.hardware=redroid \
    ro.sf.lcd_density=320 \
    persist.sys.fuse=1 \
    **ro.hardware.camera=v4l2**

# disable ueventd coldboot for performance
PRODUCT_PROPERTY_OVERRIDES += \
    ro.cold_boot_done=true \

# Phone App required
PRODUCT_PACKAGES += \
    rild

# WiFi required by SystemUI
PRODUCT_PACKAGES += \
    android.hardware.wifi@1.0-service

PRODUCT_COPY_FILES += \
    frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml \

# required HIDL
PRODUCT_PACKAGES += \
    audio.r_submix.default \
    android.hardware.audio.service \
    android.hardware.audio@6.0-impl \
    android.hardware.audio.effect@6.0-impl \
    android.hardware.drm@1.3-service-lazy.clearkey \
    android.hardware.gatekeeper@1.0-service.software \
    android.hardware.graphics.allocator@2.0-service \
    android.hardware.graphics.allocator@2.0-impl \
    android.hardware.graphics.mapper@2.0-impl-2.1 \
    android.hardware.graphics.composer@2.1-service \
    android.hardware.graphics.composer@2.1-impl \
    android.hardware.health@2.1-service \
    android.hardware.health@2.1-impl \
    android.hardware.keymaster@3.0-service \
    android.hardware.keymaster@3.0-impl \
    power.default \
    android.hardware.power-service.example \
    android.hardware.power.stats@1.0-service.mock \

PRODUCT_SOONG_NAMESPACES += frameworks/av/services/audiopolicy/config
# audio policy
PRODUCT_PACKAGES += \
    audio_policy_configuration.xml \
    r_submix_audio_policy_configuration.xml \
    audio_policy_volumes.xml \
    default_volume_tables.xml \
    primary_audio_policy_configuration.xml \
    surround_sound_configuration_5_0.xml \

PRODUCT_COPY_FILES += \
    device/generic/goldfish/camera/media_profiles.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml \
    device/generic/goldfish/camera/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \
    frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_audio.xml \
    frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_telephony.xml \
    frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_video.xml \
    frameworks/av/media/libeffects/data/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \
    frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml \
    frameworks/native/data/etc/android.software.autofill.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.autofill.xml \
    $(LOCAL_PATH)/gpu_config.sh:$(TARGET_COPY_OUT_VENDOR)/bin/gpu_config.sh \
    $(LOCAL_PATH)/init.redroid.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.redroid.rc \

$(call inherit-product, frameworks/native/build/phone-xhdpi-6144-dalvik-heap.mk)

$(call inherit-product-if-exists, product.mk)

$(call inherit-product, device/redroid-prebuilts/prebuilts.mk)

just placed ** on lines I added to make easy the visualization:

_USE_CAMERA_V4L2_HAL := true PRODUCT_PACKAGES += camera.v4l2 PRODUCT_PROPERTYOVERRIDES += ro.hardware.camera=v4l2

ArtBreguez commented 2 years ago

I was able to work the USB camera implementing the v4l2 with the links suggested by @zhouziyang Thanks a lot!

https://i.imgur.com/T5jDnsa.png

Now I'll try to use the USB camera as camera 0 (back camera)

dreamflasher commented 1 year ago

@ArtBreguez Would you be so kind as to document how you were able to achieve this?

TamaMcGlinn commented 9 months ago

@ArtBreguez's changes appear to be based on the May 2022 commit ce0a4fd of device_redroid, as that is the only commit in the repo where the changes would correspond to the lines marked with asterisks.