diff options
| author | Ivan <ivan.flashka@gmail.com> | 2015-04-05 20:40:30 +0300 |
|---|---|---|
| committer | Ivan <ivan.flashka@gmail.com> | 2015-04-05 20:40:30 +0300 |
| commit | 1fc9d6387f38177fc5febdb62a71a00f0fe012e1 (patch) | |
| tree | 51639f73a8d2bc0e8b991337917117f08d9020c1 | |
| parent | 1b980a15cac5f4925dcb175d9be562a9e6d9121d (diff) | |
ha3g: camerawrapper workaround for permissions
| -rw-r--r-- | camera/CameraWrapper.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/camera/CameraWrapper.cpp b/camera/CameraWrapper.cpp index e67c4ea..f593fcf 100644 --- a/camera/CameraWrapper.cpp +++ b/camera/CameraWrapper.cpp @@ -25,6 +25,8 @@ #define LOG_TAG "CameraWrapper" #include <cutils/log.h> +#include <sys/types.h> +#include <sys/stat.h> #include <utils/threads.h> #include <utils/String8.h> @@ -33,6 +35,8 @@ #include <camera/Camera.h> #include <camera/CameraParameters.h> +#define CAMID_PATH "/data/CameraID.txt" + static android::Mutex gCameraWrapperLock; static camera_module_t *gVendorModule = 0; @@ -79,6 +83,36 @@ typedef struct wrapper_camera_device { }) #define CAMERA_ID(device) (((wrapper_camera_device_t *)(device))->id) +static void fix_camera_id_permissions() +{ + FILE* camidfile; + int amode; + int ret = -1; + camidfile = fopen(CAMID_PATH, "w"); + if (camidfile == 0) { + fprintf(stderr, "open(%s) failed\n", CAMID_PATH); + ALOGE("Can't open %s\n", CAMID_PATH); + } else { + ALOGD("Setting permissions of %s\n", CAMID_PATH); + + /* write permissions for the file owner */ + amode = S_IWUSR; + ret = chmod(CAMID_PATH, amode); + + /* owner: media; group: system */ + char* chown_cmd = (char*) malloc(strlen("chown media ") + strlen(CAMID_PATH) + 1); + char* chgrp_cmd = (char*) malloc(strlen("chgrp system ") + strlen(CAMID_PATH) + 1); + sprintf(chown_cmd, "chown media %s", CAMID_PATH); + sprintf(chgrp_cmd, "chgrp system %s", CAMID_PATH); + system(chown_cmd); + system(chgrp_cmd); + + if (ret != 0) { + fprintf(stderr, "chmod() on file %s failed\n", CAMID_PATH); + ALOGE("Can't set permissions on %s\n", CAMID_PATH); + } + } +} static int check_vendor_module() { |
