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

Commit 6fa3953d authored by Steve Kondik's avatar Steve Kondik Committed by Ricardo Cerqueira
Browse files

camera: Full support for HTC camera switch

 * Adds the changes for using the "htcwc" switch.
   We still need this even on ICS.

Change-Id: I5f24cb379b359c5796748f496a03ef431c36e283
parent d6590d4c
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();