change appid acquisition method due to AMD latency 31/311831/3 accepted/tizen_unified_toolchain accepted/tizen_unified_x_asan accepted/tizen/unified/20240603.160955 accepted/tizen/unified/dev/20240620.005500 accepted/tizen/unified/toolchain/20240624.121515 accepted/tizen/unified/x/20240605.012749 accepted/tizen/unified/x/asan/20240625.092543
authorjae915 <jae915@samsung.com>
Wed, 29 May 2024 00:00:23 +0000 (09:00 +0900)
committerjae915 <jae915@samsung.com>
Fri, 31 May 2024 01:39:05 +0000 (10:39 +0900)
Change-Id: Ie2b4b1c1f49e4c041e507c6896834e970797d780

src/mm_camcorder_rm.c

index b3e1d12..cdb3696 100644 (file)
@@ -31,6 +31,8 @@
 #include "mm_camcorder_rm.h"
 #include "mm_camcorder_internal.h"
 
+#define PROCESS_NAME_PATH_MAX  200
+
 static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event_src,
        rm_device_request_s *info, void* cb_data)
 {
@@ -64,6 +66,60 @@ static rm_cb_result __mmcamcorder_rm_callback(int handle, rm_callback_type event
        return cb_res;
 }
 
+void _mmcamcorder_get_appid_bypid(int pid, char *name, size_t size)
+{
+       FILE *cmdline;
+       char buf[PROCESS_NAME_PATH_MAX];
+       int length;
+       unsigned int buf_pos = 0;
+       unsigned int ret_pos = 0;
+       char *read = NULL;
+
+
+       mmf_return_if_fail(name);
+
+       if (size > 0u) {
+               name[0] = 0;
+       }
+
+       length = snprintf(buf, sizeof(buf), "/proc/%d/cmdline", (int)pid);
+       if (length >= (int)sizeof(buf))
+               return;
+
+       cmdline = fopen(buf, "r");
+       if (NULL == cmdline) {
+               MMCAM_LOG_ERROR("File[%s] open failed", buf);
+               return;
+       }
+
+       read = fgets(buf, sizeof(buf), cmdline);
+       fclose(cmdline);
+
+       if (NULL == read) {
+               MMCAM_LOG_ERROR("File read failed");
+               return;
+       }
+
+       for (buf_pos = 0; buf_pos < sizeof(buf); buf_pos++) {
+               switch(buf[buf_pos]) {
+                       case '\0':
+                               name[ret_pos] = '\0';
+                               return;
+                       case '/':
+                               ret_pos = 0;
+                               break;
+                       default:
+                               if (ret_pos < size)
+                                       name[ret_pos] = buf[buf_pos];
+
+                               ret_pos++;
+                               break;
+               }
+       }
+
+}
+
+
 int _mmcamcorder_rm_create(MMHandleType handle)
 {
        int ret = RM_OK;
@@ -77,7 +133,7 @@ int _mmcamcorder_rm_create(MMHandleType handle)
        mm_camcorder_get_attributes(handle, NULL,
                MMCAM_CLIENT_PID, &hcamcorder->rci.app_pid,
                NULL);
-       aul_app_get_appid_bypid(hcamcorder->rci.app_pid, hcamcorder->rci.app_id, sizeof(hcamcorder->rci.app_id));
+       _mmcamcorder_get_appid_bypid(hcamcorder->rci.app_pid, hcamcorder->rci.app_id, sizeof(hcamcorder->rci.app_id));
 
        /* RM register */
        /* NULL should be passed for the rci parameter if the application does not have "visibility" */