From 867b8b7b729282c7e14e200ca277435329ebe747 Mon Sep 17 00:00:00 2001
From: liyujie <2352380935@qq.com>
Date: Thu, 28 Aug 2025 12:04:19 +0000
Subject: [PATCH] [3/4]解决USB摄像头打开相机预览界面绿屏

---
 android/hardware/interfaces/camera/device/3.4/default/ExternalCameraUtils.cpp |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/android/hardware/interfaces/camera/device/3.4/default/ExternalCameraUtils.cpp b/android/hardware/interfaces/camera/device/3.4/default/ExternalCameraUtils.cpp
old mode 100755
new mode 100644
index e25deff..1ae32d0
--- a/android/hardware/interfaces/camera/device/3.4/default/ExternalCameraUtils.cpp
+++ b/android/hardware/interfaces/camera/device/3.4/default/ExternalCameraUtils.cpp
@@ -164,6 +164,7 @@
     const int kDefaultNumStillBuffer = 2;
     const int kDefaultOrientation = 0; // suitable for natural landscape displays like tablet/TV
                                        // For phone devices 270 is better
+    const int kDefaultJpegOrientation = 0;
 } // anonymous namespace
 
 const char* ExternalCameraConfig::kDefaultCfgPath = "/vendor/etc/external_camera_config.xml";
@@ -284,10 +285,19 @@
         ret.orientation = orientation->IntAttribute("degree", /*Default*/kDefaultOrientation);
     }
 
+    XMLElement *jpegOrientation = deviceCfg->FirstChildElement("JpegOrientation");
+    if (jpegOrientation == nullptr) {
+        ALOGI("%s: no jpeg orientation specified", __FUNCTION__);
+    } else {
+        ret.jpegOrientation = jpegOrientation->IntAttribute("degree",
+            /*Default*/kDefaultJpegOrientation);
+    }
+
     ALOGI("%s: external camera cfg loaded: maxJpgBufSize %d,"
-            " num video buffers %d, num still buffers %d, orientation %d",
+            " num video buffers %d, num still buffers %d, orientation %d jpeg orientation %d",
             __FUNCTION__, ret.maxJpegBufSize,
-            ret.numVideoBuffers, ret.numStillBuffers, ret.orientation);
+            ret.numVideoBuffers, ret.numStillBuffers,
+            ret.orientation, ret.jpegOrientation);
     for (const auto& limit : ret.fpsLimits) {
         ALOGI("%s: fpsLimitList: %dx%d@%f", __FUNCTION__,
                 limit.size.width, limit.size.height, limit.fpsUpperBound);

--
Gitblit v1.6.2