How does vim4 android configure the camera to be rear-mounted?

Please tell me, how does vim4 android configure the camera to be rear-mounted?

thank you!

Hello @Lexus

@goenjoy will help you about this.

1 Like

@Lexus The code should default to the rear camera. If you want to change the front and rear cameras, try the following modifications:

packages/apps/Camera2$ git diff
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ac939893d..992705e4c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -169,7 +169,7 @@
     <!-- Settings screen, camera selection dialog title. Users can select a camera from the phone (front-facing or back-facing). [CHAR LIMIT=20] -->
     <string name="pref_camera_id_title">Choose camera</string>
 
-    <string name="pref_camera_id_default" translatable="false">0</string>
+    <string name="pref_camera_id_default" translatable="false">1</string>
1 Like

Thank you very much!!!

Wow, I can’t open the app after verification according to your modification today!

logcat | grep  "CAM"                                           
02-05 02:59:34.779  3362  3362 V CAM_Profiler: [  0.000ms][ui] GUARD: CameraApp onCreate() - START
02-05 02:59:34.779  3362  3362 V CAM_Profiler: [  0.000ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - START
02-05 02:59:34.780  3362  3362 V CAM_Profiler: [  1.132ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - [ 1.132ms] PreferenceManager.getDefaultSharedPreferences
02-05 02:59:34.781  3362  3362 V CAM_Profiler: [  1.865ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - [ 0.732ms] preferences.getLong
02-05 02:59:34.781  3362  3362 V CAM_Profiler: [  2.065ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - STOP
02-05 02:59:34.781  3362  3362 V CAM_Profiler: [  3.410ms][ui] GUARD: CameraApp onCreate() - [ 3.410ms] initializeTimeOfFirstRun
02-05 02:59:34.781  3362  3362 V CAM_Profiler: [  3.704ms][ui] GUARD: CameraApp onCreate() - [ 0.295ms] UsageStatistics.initialize
02-05 02:59:34.782  3362  3362 V CAM_Profiler: [  4.597ms][ui] GUARD: CameraApp onCreate() - [ 0.893ms] clearNotifications
02-05 02:59:34.783  3362  3362 V CAM_Profiler: [  4.597ms][ui] GUARD: CameraApp onCreate() - STOP
02-05 02:59:34.800  3362  3362 V CAM_QuickActivity: START onCreate: Activity = com.android.camera.CameraActivity@4738277
02-05 02:59:34.801  3362  3362 V CAM_Profiler: [  0.000ms][ui] GUARD: CameraActivity.onCreateTasks - START
02-05 02:59:34.802  3362  3362 D CAM_LocationManager: Using LegacyLocationProvider
02-05 02:59:34.811  3362  3362 D CAM_MemoryManagerImpl: Max native memory: 268 MB
02-05 02:59:34.814  3362  3362 I CAM_OneCamFtrCnfgCrtr: CaptureModule? true
02-05 02:59:34.824  3362  3362 V CAM_Profiler: [ 22.815ms][ui] GUARD: CameraActivity.onCreateTasks - [ 8.632ms] Glide.setup
02-05 02:59:34.825  3362  3362 D CAM_Camera2OneCamMgr: Getting First BACK Camera
02-05 02:59:34.827   443   443 W ServiceManager: Permission failure: android.permission.CAMERA_OPEN_CLOSE_LISTENER from uid=10052 pid=3362
02-05 02:59:34.829  3362  3362 W CAM_Camera2OneCamMgr: No back-facing camera found.
02-05 02:59:34.829  3362  3362 W CAM_Camera2OneCamMgr: No external camera found.
02-05 02:59:34.829  3362  3362 D CAM_Camera2OneCamMgr: Getting First FRONT Camera
02-05 02:59:34.831  3362  3362 V CAM_Profiler: [ 29.310ms][ui] GUARD: CameraActivity.onCreateTasks - [ 6.495ms] OneCameraManager.get
02-05 02:59:34.837   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3362
02-05 02:59:34.840   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3362
02-05 02:59:34.842  3362  3362 V CAM_Profiler: [ 40.627ms][ui] GUARD: CameraActivity.onCreateTasks - [ 2.237ms] computePictureSizes
02-05 02:59:34.862  3362  3362 W CAM_Log : Tag RoundedThumbnailView is 1 chars longer than limit.
02-05 02:59:34.922  3362  3362 I CAM_Profiler: [120.511ms][ui] GUARD: CameraActivity.onCreateTasks - [76.129ms] setContentView()
02-05 02:59:34.936  3362  3362 V CAM_Profiler: [134.453ms][ui] GUARD: CameraActivity.onCreateTasks - [13.942ms] Configure Camera UI
02-05 02:59:34.946  3362  3362 V CAM_CameraController: Closing camera
02-05 02:59:34.947  3362  3387 W CAM2PORT_AndCamAgntImp: Releasing camera without any camera opened.
02-05 02:59:34.947  3362  3362 V CAM_ModulesInfo: EnableCaptureModule = true
02-05 02:59:34.948  3362  3362 V CAM_Profiler: [  0.000ms][ui] GUARD: new CaptureModule - START
02-05 02:59:34.949  3362  3362 V CAM_Profiler: [  1.359ms][ui] GUARD: new CaptureModule - STOP
02-05 02:59:34.949  3362  3362 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7]
02-05 02:59:34.953  3362  3362 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7, com.android.camera.ButtonManager@c4d48c0]
02-05 02:59:34.953  3362  3362 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7, com.android.camera.ButtonManager@c4d48c0, com.android.camera.widget.IndicatorIconController@6d26d3e]
02-05 02:59:34.954  3362  3362 V CAM_Profiler: [152.609ms][ui] GUARD: CameraActivity.onCreateTasks - [ 4.480ms] Init Current Module UI
02-05 02:59:34.954  3362  3362 V CAM_Profiler: [  0.000ms][ui] GUARD: CaptureModule.init - START
02-05 02:59:34.954  3362  3362 D CAM_CaptureModule: init UseAutotransformUiLayout = false
02-05 02:59:34.956  3362  3362 D CAM_Camera2OneCamMgr: Getting First BACK Camera
02-05 02:59:34.957  3362  3362 W CAM_Camera2OneCamMgr: No back-facing camera found.
02-05 02:59:34.957  3362  3362 W CAM_Camera2OneCamMgr: No external camera found.
02-05 02:59:34.957  3362  3362 D CAM_Camera2OneCamMgr: Getting First FRONT Camera
02-05 03:02:47.413  3989  3989 V CAM_Profiler: [  0.000ms][ui] GUARD: CameraApp onCreate() - START
02-05 03:02:47.413  3989  3989 V CAM_Profiler: [  0.000ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - START
02-05 03:02:47.414  3989  3989 V CAM_Profiler: [  0.797ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - [ 0.797ms] PreferenceManager.getDefaultSharedPreferences
02-05 03:02:47.415  3989  3989 V CAM_Profiler: [  1.690ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - [ 0.893ms] preferences.getLong
02-05 03:02:47.415  3989  3989 V CAM_Profiler: [  1.833ms][ui] GUARD: FirstRunDetector getTimeOfFirstRun - STOP
02-05 03:02:47.415  3989  3989 V CAM_Profiler: [  2.748ms][ui] GUARD: CameraApp onCreate() - [ 2.748ms] initializeTimeOfFirstRun
02-05 03:02:47.415  3989  3989 V CAM_Profiler: [  2.952ms][ui] GUARD: CameraApp onCreate() - [ 0.204ms] UsageStatistics.initialize
02-05 03:02:47.416  3989  3989 V CAM_Profiler: [  3.558ms][ui] GUARD: CameraApp onCreate() - [ 0.606ms] clearNotifications
02-05 03:02:47.416  3989  3989 V CAM_Profiler: [  3.558ms][ui] GUARD: CameraApp onCreate() - STOP
02-05 03:02:47.427  3989  3989 V CAM_QuickActivity: START onCreate: Activity = com.android.camera.CameraActivity@4738277
02-05 03:02:47.429  3989  3989 V CAM_Profiler: [  0.000ms][ui] GUARD: CameraActivity.onCreateTasks - START
02-05 03:02:47.429  3989  3989 D CAM_LocationManager: Using LegacyLocationProvider
02-05 03:02:47.433  3989  3989 D CAM_MemoryManagerImpl: Max native memory: 268 MB
02-05 03:02:47.435  3989  3989 I CAM_OneCamFtrCnfgCrtr: CaptureModule? true
02-05 03:02:47.440  3989  3989 V CAM_Profiler: [ 11.873ms][ui] GUARD: CameraActivity.onCreateTasks - [ 4.169ms] Glide.setup
02-05 03:02:47.441  3989  3989 D CAM_Camera2OneCamMgr: Getting First BACK Camera
02-05 03:02:47.442   443   443 W ServiceManager: Permission failure: android.permission.CAMERA_OPEN_CLOSE_LISTENER from uid=10052 pid=3989
02-05 03:02:47.443  3989  3989 W CAM_Camera2OneCamMgr: No back-facing camera found.
02-05 03:02:47.444  3989  3989 W CAM_Camera2OneCamMgr: No external camera found.
02-05 03:02:47.444  3989  3989 D CAM_Camera2OneCamMgr: Getting First FRONT Camera
02-05 03:02:47.445  3989  3989 V CAM_Profiler: [ 16.386ms][ui] GUARD: CameraActivity.onCreateTasks - [ 4.513ms] OneCameraManager.get
02-05 03:02:47.450   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.450   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.453   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.453   443   443 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.453   443  1022 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.453   443  1022 W ServiceManager: Permission failure: android.permission.SYSTEM_CAMERA from uid=10052 pid=3989
02-05 03:02:47.456  3989  3989 V CAM_Profiler: [ 27.211ms][ui] GUARD: CameraActivity.onCreateTasks - [ 3.531ms] computePictureSizes
02-05 03:02:47.472  3989  3989 W CAM_Log : Tag RoundedThumbnailView is 1 chars longer than limit.
02-05 03:02:47.525  3989  3989 I CAM_Profiler: [ 96.100ms][ui] GUARD: CameraActivity.onCreateTasks - [67.720ms] setContentView()
02-05 03:02:47.536  3989  3989 V CAM_Profiler: [106.976ms][ui] GUARD: CameraActivity.onCreateTasks - [10.876ms] Configure Camera UI
02-05 03:02:47.542  3989  3989 V CAM_CameraController: Closing camera
02-05 03:02:47.544  3989  4014 W CAM2PORT_AndCamAgntImp: Releasing camera without any camera opened.
02-05 03:02:47.544  3989  3989 V CAM_ModulesInfo: EnableCaptureModule = true
02-05 03:02:47.545  3989  3989 V CAM_Profiler: [  0.000ms][ui] GUARD: new CaptureModule - START
02-05 03:02:47.546  3989  3989 V CAM_Profiler: [  1.660ms][ui] GUARD: new CaptureModule - STOP
02-05 03:02:47.547  3989  3989 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7]
02-05 03:02:47.550  3989  3989 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7, com.android.camera.ButtonManager@c4d48c0]
02-05 03:02:47.551  3989  3989 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@475faa7, com.android.camera.ButtonManager@c4d48c0, com.android.camera.widget.IndicatorIconController@6d26d3e]
02-05 03:02:47.551  3989  3989 V CAM_Profiler: [122.710ms][ui] GUARD: CameraActivity.onCreateTasks - [ 4.687ms] Init Current Module UI
02-05 03:02:47.551  3989  3989 V CAM_Profiler: [  0.000ms][ui] GUARD: CaptureModule.init - START
02-05 03:02:47.551  3989  3989 D CAM_CaptureModule: init UseAutotransformUiLayout = false
02-05 03:02:47.552  3989  3989 D CAM_Camera2OneCamMgr: Getting First BACK Camera
02-05 03:02:47.553  3989  3989 W CAM_Camera2OneCamMgr: No back-facing camera found.
02-05 03:02:47.554  3989  3989 W CAM_Camera2OneCamMgr: No external camera found.
02-05 03:02:47.554  3989  3989 D CAM_Camera2OneCamMgr: Getting First FRONT Camera

hi,
I’m a usb camera!

nice day!!!

@Lexus Then restore the above changes. Then try to modify it as follows.

common$ git diff
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 7d60dd3b0bd8..4811e6ea45ff 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -616,6 +616,8 @@ static int uvc_ioctl_querycap(struct file *file, void *fh,
 
        strscpy(cap->driver, "uvcvideo", sizeof(cap->driver));
        strscpy(cap->card, vdev->name, sizeof(cap->card));
+       strcpy(cap->card,"back");//front
+       printk("======uvc_ioctl_querycap======");
        usb_make_path(stream->dev->udev, cap->bus_info, sizeof(cap->bus_info));
        cap->capabilities = V4L2_CAP_DEVICE_CAPS | V4L2_CAP_STREAMING
                          | chain->caps;

It has been changed, but how do I know that the upper layer has configured it as front or rear?

dmesg | grep "uvc_ioctl_querycap"                                  
[    4.917737] ======uvc_ioctl_querycap======
[    4.930710] ======uvc_ioctl_querycap======
[    8.460550] ======uvc_ioctl_querycap======
[    8.461282] ======uvc_ioctl_querycap======
[   15.440853] ======uvc_ioctl_querycap======
[   15.442885] ======uvc_ioctl_querycap======

@goenjoy ,hi
I checked the hal layer and plugged in my usb camera. The default selection of the printing system is:

else {
          // Default facing external using for cts
          ALOGE("support ANDROID_LENS_FACING_EXTERNAL!");
          lensFacing = ANDROID_LENS_FACING_EXTERNAL;
          mFacingBack = 0;
I tried to configure the system property ro.vendor.camera_ Usb. faceback=true, the result cannot be opened:
hardware/amlogic/camera/v3/EmulatedFakeCamera3.cpp
/*lens facing related camera feature*/
   /*camera feature setting in /device/amlogic/xxx/xxx.mk files*/
   /*in cdd , usb camera is external facing*/
   uint8_t lensFacing = ANDROID_LENS_FACING_BACK;
   switch (mSensorType) {
       case SENSOR_USB :
        property_get("ro.vendor.camera_usb.faceback", property, NULL);
        if (strstr(property, "true")) {
                ALOGE("support ANDROID_LENS_FACING_BACK!");
          lensFacing =  ANDROID_LENS_FACING_BACK;
          mFacingBack = 1;
        } else if (strstr(property, "false")) {
          ALOGE("support ANDROID_LENS_FACING_FRONT!");
          lensFacing = ANDROID_LENS_FACING_FRONT;
          mFacingBack = 0;
        } else {
          // Default facing external using for cts
          ALOGE("support ANDROID_LENS_FACING_EXTERNAL!");
          lensFacing = ANDROID_LENS_FACING_EXTERNAL;
          mFacingBack = 0;
        }
        break;
     case SENSOR_V4L2MEDIA:
     case SENSOR_MIPI:
        property_get("ro.vendor.camera_mipi.faceback", property, NULL);
        if (strstr(property, "true")) {
            mFacingBack = 1;
            lensFacing =  ANDROID_LENS_FACING_BACK;
        } else if (strstr(property, "false")) {
            mFacingBack = 0;
            lensFacing =  ANDROID_LENS_FACING_FRONT;
        } else {
            // Default facing front
            mFacingBack = 0;
            lensFacing =  ANDROID_LENS_FACING_FRONT;
        }

@Lexus The answer to the code you showed has been given. It is estimated that you only need to add an attribute. You can verify it according to the following code:

device/khadas$ git diff
diff --git a/kvim4/kvim4.mk b/kvim4/kvim4.mk
 ifeq ($(BUILD_WITH_GAPPS_CONFIG),true)
@@ -513,4 +514,6 @@ PRODUCT_PACKAGES += \
     android.hardware.gnss@1.0-impl \
     android.hardware.gnss@1.0-service
 
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.vendor.camera_usb.faceback=true
 #add end

I tried to add this attribute, but I couldn’t open the camera.
There was no camera associated with it.
Must go lensFacing=ANDROID_ LENS_ FACING_ EXTERNAL; ??

Then you can try to modify and verify it.

case SENSOR_USB :
        property_get("ro.vendor.camera_usb.faceback", property, NULL);
        if (strstr(property, "true")) {
                ALOGE("support ANDROID_LENS_FACING_BACK!");
          lensFacing =  ANDROID_LENS_FACING_BACK;
          mFacingBack = 1;
        } else if (strstr(property, "false")) {
          ALOGE("support ANDROID_LENS_FACING_FRONT!");
          lensFacing = ANDROID_LENS_FACING_FRONT;
          mFacingBack = 0;
        } else {
          // Default facing external using for cts
          ALOGE("support ANDROID_LENS_FACING_EXTERNAL!");
          lensFacing = ANDROID_LENS_FACING_EXTERNAL;
-          mFacingBack = 0;
+          mFacingBack = 1;
        }

or

device/khadas$ git diff
diff --git a/kvim4/kvim4.mk b/kvim4/kvim4.mk
 ifeq ($(BUILD_WITH_GAPPS_CONFIG),true)
@@ -513,4 +514,6 @@ PRODUCT_PACKAGES += \
     android.hardware.gnss@1.0-impl \
     android.hardware.gnss@1.0-service
 
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.vendor.camera_usb.faceback=true
 #add end

case SENSOR_USB :
        property_get("ro.vendor.camera_usb.faceback", property, NULL);
        if (strstr(property, "true")) {
                ALOGE("support ANDROID_LENS_FACING_BACK!");
-          lensFacing =  ANDROID_LENS_FACING_BACK;
+         lensFacing =  ANDROID_LENS_FACING_EXTERNAL;
          mFacingBack = 1;
        } else if (strstr(property, "false")) {
          ALOGE("support ANDROID_LENS_FACING_FRONT!");
          lensFacing = ANDROID_LENS_FACING_FRONT;
          mFacingBack = 0;
        } else {
          // Default facing external using for cts
          ALOGE("support ANDROID_LENS_FACING_EXTERNAL!");
          lensFacing = ANDROID_LENS_FACING_EXTERNAL;
          mFacingBack = 0;
        }

hi @goenjoy ,
According to the modifications given, I have set mFaceingBack=1;

However, I use the camera with qq apk to preview. The default rear opening is black. I click the mode to switch to the front to open it.

This is my dump, display or front shot:

dumpsys media.camera

== Service global info: ==

Number of camera devices: 1
Number of normal camera devices: 1
Number of public camera devices visible to API1: 1
    Device 0 maps to "0"
Active Camera Clients:
[]
Allowed user IDs: 0

== Camera service events log (most recent at top): ==
  01-14 08:57:57 : ADD device 0, reason: (Device added)
  01-14 08:56:58 : REMOVE device 0, reason: (Device status changed from 1 to 0)
  01-14 08:56:57 : USER_SWITCH previous allowed user IDs: <None>, current allowed user IDs: 0
  01-14 08:56:54 : ADD device 0, reason: (Device added)
  01-14 08:56:51 : REMOVE device 0, reason: (Device status changed from 1 to 0)
  01-14 08:56:50 : ADD device 0, reason: (Device added)

== Camera device 0 dynamic info: ==
  Device 0 is closed, no client instance
== Camera Provider HAL legacy/0 (v2.5, remote) static info: 1 devices: ==
== Camera HAL device device@3.3/legacy/0 (v3.3) static information: ==
  Resource cost: 0
  Conflicting devices: None
  API1 info:
    Has a flash unit: false
    Facing: Front
    Orientation: 0
  API2 camera characteristics:
    Dumping camera metadata array: 85 / 85 entries, 2104 / 2104 bytes of extra data.
      Version: 1, Flags: 00000000
      android.lens.info.minimumFocusDistance (90005): float[1]
        [0.00000000 ]
      android.lens.info.hyperfocalDistance (90004): float[1]
        [0.00000000 ]
      android.lens.info.availableFocalLengths (90002): float[1]
        [-1.00000000 ]
      android.lens.info.availableApertures (90000): float[1]
        [2.79999995 ]
      android.lens.info.availableFilterDensities (90001): float[1]
        [0.00000000 ]
      android.lens.info.availableOpticalStabilization (90003): byte[1]
        [0 ]
      android.lens.info.shadingMapSize (90006): int32[2]
        [1 1 ]
      android.lens.facing (80005): byte[1]
        [EXTERNAL ]
      android.lens.info.focusDistanceCalibration (90007): byte[1]
        [UNCALIBRATED ]
      android.sensor.availableTestPatternModes (e0019): int32[1]
        [0 ]
      android.sensor.testPatternMode (e0018): int32[1]
        [OFF ]
      android.sensor.info.exposureTimeRange (f0003): int64[2]
        [1000 30000000000 ]
      android.sensor.info.maxFrameDuration (f0004): int64[1]
        [30000000000 ]
      android.sensor.info.sensitivityRange (f0001): int32[2]
        [100 1600 ]
      android.sensor.info.colorFilterArrangement (f0002): byte[1]
        [RGGB ]
      android.sensor.info.physicalSize (f0005): float[2]
        [3.20000005 2.40000010 ]
      android.sensor.info.whiteLevel (f0007): int32[1]
        [4000 ]
      android.sensor.blackLevelPattern (e000c): int32[4]
        [1000 1000 1000 1000 ]
      android.sensor.info.timestampSource (f0008): byte[1]
        [UNKNOWN ]
      android.sensor.orientation (e000e): int32[1]
        [0 ]
      android.sensor.rollingShutterSkew (e001a): int64[1]
        [0 ]
      android.flash.info.available (50000): byte[1]
        [FALSE ]
      android.flash.state (40005): byte[1]
        [UNAVAILABLE ]
      android.flash.info.chargeDuration (50001): int64[1]
        [0 ]
      android.noiseReduction.availableNoiseReductionModes (a0002): byte[1]
        [0 ]
      android.tonemap.availableToneMapModes (130005): byte[2]
        [1 2 ]
      android.tonemap.maxCurvePoints (130004): int32[1]
        [128 ]
      android.scaler.croppingType (d000d): byte[1]
        [CENTER_ONLY ]
      android.scaler.availableFormats (d0001): int32[5]
        [BLOB IMPLEMENTATION_DEFINED YV12 YCrCb_420_SP ]
        [YCbCr_420_888 ]
      android.scaler.availableRawMinDurations (d0007): int64[1]
        [33331760 ]
      android.scaler.availableStreamConfigurations (d000a): int32[56]
        [34 1920 1080 OUTPUT ]
        [34 1280 720 OUTPUT ]
        [34 720 576 OUTPUT ]
        [34 640 480 OUTPUT ]
        [34 320 240 OUTPUT ]
        [35 1920 1080 OUTPUT ]
        [35 1280 720 OUTPUT ]
        [35 720 576 OUTPUT ]
        [35 640 480 OUTPUT ]
        [35 320 240 OUTPUT ]
        [33 1920 1080 OUTPUT ]
        [33 1280 720 OUTPUT ]
        [33 640 480 OUTPUT ]
        [33 320 240 OUTPUT ]
      android.sensor.info.activeArraySize (f0000): int32[4]
        [0 0 1920 1080 ]
      android.sensor.info.pixelArraySize (f0006): int32[2]
        [1920 1080 ]
      android.scaler.availableMinFrameDurations (d000b): int64[56]
        [33 320 ]
        [240 33333333 ]
        [33 640 ]
        [480 33333333 ]
        [33 1280 ]
        [720 33333333 ]
        [33 1920 ]
        [1080 33333333 ]
        [35 320 ]
        [240 33333333 ]
        [35 640 ]
        [480 33333333 ]
        [35 720 ]
        [576 33333333 ]
        [35 1280 ]
        [720 33333333 ]
        [35 1920 ]
        [1080 33333333 ]
        [34 320 ]
        [240 33333333 ]
        [34 640 ]
        [480 33333333 ]
        [34 720 ]
        [576 33333333 ]
        [34 1280 ]
        [720 33333333 ]
        [34 1920 ]
        [1080 33333333 ]
      android.scaler.availableStallDurations (d000c): int64[56]
        [33 320 ]
        [240 33333333 ]
        [33 640 ]
        [480 33333333 ]
        [33 1280 ]
        [720 33333333 ]
        [33 1920 ]
        [1080 33333333 ]
        [35 320 ]
        [240 0 ]
        [35 640 ]
        [480 0 ]
        [35 720 ]
        [576 0 ]
        [35 1280 ]
        [720 0 ]
        [35 1920 ]
        [1080 0 ]
        [34 320 ]
        [240 0 ]
        [34 640 ]
        [480 0 ]
        [34 720 ]
        [576 0 ]
        [34 1280 ]
        [720 0 ]
        [34 1920 ]
        [1080 0 ]
      android.scaler.availableProcessedMinDurations (d0005): int64[1]
        [33331760 ]
      android.scaler.availableJpegMinDurations (d0002): int64[1]
        [33331760 ]
      android.jpeg.availableThumbnailSizes (70007): int32[8]
        [0 0 128 72 ]
        [160 120 320 240 ]
      android.jpeg.maxSize (70008): int32[1]
        [8000000 ]
      android.statistics.info.availableFaceDetectModes (120000): byte[3]
        [0 1 2 ]
      android.statistics.info.maxFaceCount (120002): int32[1]
        [8 ]
      android.statistics.info.histogramBucketCount (120001): int32[1]
        [64 ]
      android.statistics.info.maxHistogramCount (120003): int32[1]
        [1000 ]
      android.statistics.info.sharpnessMapSize (120005): int32[2]
        [64 64 ]
      android.statistics.info.maxSharpnessMapValue (120004): int32[1]
        [1000 ]
      android.statistics.hotPixelMapMode (110003): byte[1]
        [OFF ]
      android.statistics.sceneFlicker (11000e): byte[1]
        [NONE ]
      android.statistics.lensShadingMapMode (110010): byte[1]
        [OFF ]
      android.control.sceneMode (10010): byte[1]
        [FACE_PRIORITY ]
      android.control.availableSceneModes (10019): byte[1]
        [1 ]
      android.control.availableEffects (10018): byte[1]
        [0 ]
      android.control.maxRegions (1001c): int32[3]
        [0 0 0 ]
      android.control.aeAvailableModes (10013): byte[2]
        [0 1 ]
      android.control.aeAvailableTargetFpsRanges (10014): int32[16]
        [5 15 15 15 ]
        [5 20 20 20 ]
        [5 25 25 25 ]
        [5 30 30 30 ]
      android.control.awbAvailableModes (1001b): byte[6]
        [0 1 2 3 5 8 ]
      android.control.afState (10020): byte[1]
        [INACTIVE ]
      android.control.afAvailableModes (10017): byte[1]
        [0 ]
      android.control.aeAvailableAntibandingModes (10012): byte[2]
        [0 3 ]
      android.control.aeExposureCompensation (10001): int32[1]
        [0 ]
      android.control.aeCompensationStep (10016): rational[1]
        [(1 / 3) ]
      android.control.aeCompensationRange (10015): int32[2]
        [-6 6 ]
      android.scaler.availableMaxDigitalZoom (d0004): float[1]
        [1.00000000 ]
      android.control.availableVideoStabilizationModes (1001a): byte[1]
        [0 ]
      android.control.aeState (1001f): byte[1]
        [CONVERGED ]
      android.control.awbState (10022): byte[1]
        [INACTIVE ]
      android.info.supportedHardwareLevel (150000): byte[1]
        [EXTERNAL ]
      android.sync.maxLatency (170001): int32[1]
        [UNKNOWN ]
      android.request.pipelineDepth (c0009): byte[1]
        [1 ]
      android.request.pipelineMaxDepth (c000a): byte[1]
        [4 ]
      android.request.availableCapabilities (c000c): byte[1]
        [BACKWARD_COMPATIBLE ]
      android.request.partialResultCount (c000b): int32[1]
        [1 ]
      android.request.maxNumOutputStreams (c0006): int32[3]
        [0 2 1 ]
      android.colorCorrection.aberrationMode (00003): byte[1]
        [OFF ]
      android.colorCorrection.availableAberrationModes (00004): byte[1]
        [0 ]
      android.request.availableCharacteristicsKeys (c000f): int32[38]
        [4 65554 65555 65556 ]
        [65557 65558 65559 65560 ]
        [65561 65562 65563 327680 ]
        [1376256 458759 524293 589826 ]
        [655362 786444 786443 786442 ]
        [851972 851981 917529 983040 ]
        [983045 983046 983048 917518 ]
        [1179648 1179650 1507329 65572 ]
        [65573 65574 1048578 1179655 ]
        [983050 65582 ]
      android.request.availableRequestKeys (c000d): int32[61]
        [4 65554 65555 65556 ]
        [65557 65558 65559 65560 ]
        [65561 65562 65563 327680 ]
        [1376256 458759 524293 589826 ]
        [655362 786444 786443 786442 ]
        [851972 851981 917529 983040 ]
        [983045 983046 983048 917518 ]
        [1179648 1179650 1507329 65539 ]
        [65543 65547 65551 65553 ]
        [1114112 3 655360 65536 ]
        [65537 65538 65539 65541 ]
        [65543 65545 65546 65547 ]
        [65549 65550 65551 65552 ]
        [65553 262146 458755 458756 ]
        [458757 458758 851968 1114112 ]
        [65583 ]
      android.request.availableResultKeys (c000e): int32[61]
        [4 65554 65555 65556 ]
        [65557 65558 65559 65560 ]
        [65561 65562 65563 327680 ]
        [1376256 458759 524293 589826 ]
        [655362 786444 786443 786442 ]
        [851972 851981 917529 983040 ]
        [983045 983046 983048 917518 ]
        [1179648 1179650 1507329 65539 ]
        [65543 65547 65551 65553 ]
        [1114112 3 655360 65536 ]
        [65537 65538 65539 65541 ]
        [65543 65545 65546 65547 ]
        [65549 65550 65551 65552 ]
        [65553 262146 458755 458756 ]
        [458757 458758 851968 1114112 ]
        [65583 ]
      android.control.aeLockAvailable (10024): byte[1]
        [TRUE ]
      android.control.awbLockAvailable (10025): byte[1]
        [TRUE ]
      android.control.availableModes (10026): byte[3]
        [1 2 0 ]
      android.shading.availableModes (100002): byte[2]
        [1 2 ]
      android.statistics.info.availableLensShadingMapModes (120007): byte[1]
        [0 ]
      android.scaler.availableRotateAndCropModes (d0010): byte[1]
        [0 ]
      android.sensor.info.preCorrectionActiveArraySize (f000a): int32[4]
        [0 0 1920 1080 ]
      android.control.zoomRatioRange (1002e): float[2]
        [1.00000000 1.00000000 ]
== Camera HAL device device@3.3/legacy/0 (v3.3) dumpState: ==
No active camera device session instance

== Vendor tags: ==

  Dumping vendor tag descriptors for vendor with id 3854507339 
  Dumping configured vendor tag descriptors: 16 entries
    0x80000000 (aperture) with type 2 (float) defined in section android.lens
    0x80000001 (filterDensity) with type 2 (float) defined in section android.lens
    0x80000002 (focalLength) with type 2 (float) defined in section android.lens
    0x80000003 (focusDistance) with type 2 (float) defined in section android.lens
    0x80000004 (opticalStabilizationMode) with type 0 (byte) defined in section android.lens
    0x80000005 (facing) with type 0 (byte) defined in section android.lens
    0x80000006 (focusRange) with type 2 (float) defined in section android.lens
    0x80000007 (state) with type 0 (byte) defined in section android.lens
    0x80010000 (availableApertures) with type 2 (float) defined in section android.lens.info
    0x80010001 (availableFilterDensities) with type 2 (float) defined in section android.lens.info
    0x80010002 (availableFocalLengths) with type 2 (float) defined in section android.lens.info
    0x80010003 (availableOpticalStabilization) with type 0 (byte) defined in section android.lens.info
    0x80010004 (hyperfocalDistance) with type 2 (float) defined in section android.lens.info
    0x80010005 (minimumFocusDistance) with type 2 (float) defined in section android.lens.info
    0x80010006 (shadingMapSize) with type 1 (int32) defined in section android.lens.info
    0x80010007 (focusDistanceCalibration) with type 0 (byte) defined in section android.lens.info

== Camera error traces (0): ==
  No camera traces collected.

I added the print, and I did run to ANDROID_ LENS_ FACING_ EXTERNAL branch selection.

logcat | grep "support ANDROID_LENS_FACIN"     
01-14 09:34:02.965   381   484 E EmulatedCamera_FakeCamera3: support ANDROID_LENS_FACING_EXTERNAL!

@goenjoy ,hello
Excuse me, Excuse me, how can the configuration take effect to make the camera a rear camera?

@Lexus Because my code is the latest and has changed a lot of things. The latest version of the code was uploaded to github yesterday. I just verified with the vim4-android-11-64bit-v221228 version of firmware. When I plug in the USB camera and open it with the camera application that comes with the system, the default is the rear camera.

In addition, as I said before, the Android code itself opens the rear camera by default. I suspect you have reversed the front and rear.

@goenjoy

property_get("ro.vendor.camera_usb.faceback", property, NULL);
        if (strstr(property, "true")) {
                ALOGE("support ANDROID_LENS_FACING_BACK!");
          lensFacing =  ANDROID_LENS_FACING_BACK;
          mFacingBack = 1;
device/khadas$ git diff
diff --git a/kvim4/kvim4.mk b/kvim4/kvim4.mk
 ifeq ($(BUILD_WITH_GAPPS_CONFIG),true)
@@ -513,4 +514,6 @@ PRODUCT_PACKAGES += \
     android.hardware.gnss@1.0-impl \
     android.hardware.gnss@1.0-service
 
+PRODUCT_PROPERTY_OVERRIDES += \
+    ro.vendor.camera_usb.faceback=true
 #add end

I just tested it and found that there is a problem with the system’s own apk to test the rear camera.
It is normal for me to test with qq apk camera.

 dumpsys media.camera

== Service global info: ==

Number of camera devices: 1
Number of normal camera devices: 1
Number of public camera devices visible to API1: 1
    Device 0 maps to "0"
Active Camera Clients:
[]
Allowed user IDs: 0

== Camera service events log (most recent at top): ==
  01-14 13:22:29 : ADD device 0, reason: (Device added)
  01-14 11:41:20 : REMOVE device 0, reason: (Device status changed from 1 to 0)
  01-14 11:41:19 : USER_SWITCH previous allowed user IDs: <None>, current allowed user IDs: 0
  01-01 08:00:09 : ADD device 0, reason: (Device added)
  01-01 08:00:06 : REMOVE device 0, reason: (Device status changed from 1 to 0)
  01-01 08:00:06 : ADD device 0, reason: (Device added)
  01-01 08:00:06 : ADD device 0, reason: (Device added)

== Camera device 0 dynamic info: ==
  Device 0 is closed, no client instance
== Camera Provider HAL legacy/0 (v2.5, remote) static info: 1 devices: ==
== Camera HAL device device@3.3/legacy/0 (v3.3) static information: ==
  Resource cost: 0
  Conflicting devices: None
  API1 info:
    Has a flash unit: false
    Facing: Back
    Orientation: 0
  API2 camera characteristics:

What does the system apk need to change to test the rear camera?
You can execute:

dumpsys media.camera

's message to me?

@Lexus


As I said before, the Android code defaults to the rear camera. I verified that there is no problem with the apk provided by the system. If you have made the above changes, please restore it back.

You can execute:

dumpsys media.camera

's message to me?
Let me see!!!