OSDN Git Service

Fix property hal.camera.0 has no effect issue oreo-x86 pie-x86 q-x86 android-x86-7.1-r4 android-x86-8.1-r5 android-x86-8.1-r6
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 5 May 2020 02:01:40 +0000 (10:01 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 5 May 2020 02:01:40 +0000 (10:01 +0800)
There is a logical error that prevents hal.camera.0 from working
if /dev/video1 exists.

Reported-by: NovHak <novhak@gmail.com>
CameraFactory.cpp

index ccd66ad..3d36bef 100644 (file)
@@ -141,10 +141,12 @@ void CameraFactory::parseConfig(const char* configFile)
         char camera_node[] = "/dev/video0";
         char camera_prop[] = "hal.camera.0";
         char prop[PROPERTY_VALUE_MAX] = "";
+        bool no_prop = true;
         while (camera_node[10] <= '9' && mCameraNum < 3) {
             if (!access(camera_node, F_OK)) {
                 int facing = mCameraNum, orientation = 0;
                 if (property_get(camera_prop, prop, "")) {
+                    no_prop = false;
                     sscanf(prop, "%d,%d", &facing, &orientation);
                     ALOGI("%s got facing=%d orient=%d from property %s", __FUNCTION__, facing, orientation, camera_prop);
                 }
@@ -154,8 +156,9 @@ void CameraFactory::parseConfig(const char* configFile)
         }
 
         // If there is only one camera, assume its facing is front
-        if (mCameraNum == 1 && prop[0] == '\0') {
+        if (mCameraNum == 1 && no_prop) {
             mCameraFacing[0] = CAMERA_FACING_FRONT;
+            ALOGI("%s assume %s is front", __FUNCTION__, mCameraDevices[0]);
         }
     }
 }