Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a0c455f authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "camera: Full support for HTC camera switch" into ics

parents 79da6996 6fa3953d
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,4 +21,8 @@ LOCAL_SHARED_LIBRARIES:= \

LOCAL_MODULE:= libcameraservice

ifeq ($(BOARD_HAVE_HTC_FFC), true)
LOCAL_CFLAGS += -DBOARD_HAVE_HTC_FFC
endif

include $(BUILD_SHARED_LIBRARY)
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>

#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
@@ -66,6 +68,23 @@ static int getCallingUid() {

// ----------------------------------------------------------------------------

#if defined(BOARD_HAVE_HTC_FFC)
#define HTC_SWITCH_CAMERA_FILE_PATH "/sys/android_camera2/htcwc"
static void htcCameraSwitch(int cameraId)
{
    char buffer[16];
    int fd;

    if (access(HTC_SWITCH_CAMERA_FILE_PATH, W_OK) == 0) {
        snprintf(buffer, sizeof(buffer), "%d", cameraId);

        fd = open(HTC_SWITCH_CAMERA_FILE_PATH, O_WRONLY);
        write(fd, buffer, strlen(buffer));
        close(fd);
    }
}
#endif

// This is ugly and only safe if we never re-create the CameraService, but
// should be ok for now.
static CameraService *gCameraService;
@@ -157,6 +176,10 @@ sp<ICamera> CameraService::connect(
        return NULL;
    }

#if defined(BOARD_HAVE_HTC_FFC)
    htcCameraSwitch(cameraId);
#endif

    Mutex::Autolock lock(mServiceLock);
    if (mClient[cameraId] != 0) {
        client = mClient[cameraId].promote();