Fix getting application ID 24/263024/3
authorHwankyu Jhun <h.jhun@samsung.com>
Tue, 24 Aug 2021 23:35:05 +0000 (08:35 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 25 Aug 2021 00:10:21 +0000 (09:10 +0900)
This patch is for robot profile. If getting the application ID is failed,
AMD tries to get the process name by the process ID.

Change-Id: I6cf5ed8dc3ecd6b8015389cd6123bd610368bf90
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/lib/amd_app_status.c

index a97190752299b8a3b843ff4013e2da451f3d03aa..3efcd3be37494bb062bfb51f0c06e4c576a4e206 100644 (file)
@@ -41,6 +41,7 @@
 #include "amd_inotify.h"
 #include "amd_launch.h"
 #include "amd_noti.h"
+#include "amd_proc.h"
 #include "amd_request.h"
 #include "amd_signal.h"
 #include "amd_socket.h"
@@ -1353,23 +1354,26 @@ int _app_status_get_appid_bypid(int fd, int pid)
 {
        int cmd = APP_GET_INFO_ERROR;
        int len = 0;
-       int ret;
-       char appid[MAX_PACKAGE_STR_SIZE] = {0,};
+       const char *appid;
        app_status_h app_status;
 
        app_status = _app_status_find(pid);
        if (app_status) {
-               snprintf(appid, sizeof(appid), "%s",
-                               _app_status_get_appid(app_status));
-               SECURE_LOGD("appid for %d is %s", pid, appid);
+               appid = _app_status_get_appid(app_status);
+               SECURE_LOGD("App ID of %d is %s", pid, appid);
+       } else {
+               appid = _proc_get_name(pid);
+               if (appid)
+                       SECURE_LOGD("Process name of %d is %s", pid, appid);
+       }
+
+       if (appid) {
                len = strlen(appid);
                cmd = APP_GET_INFO_OK;
        }
 
-       ret = aul_sock_send_raw_with_fd(fd, cmd, (unsigned char *)appid,
+       return aul_sock_send_raw_with_fd(fd, cmd, (unsigned char *)appid,
                        len, AUL_SOCK_NOREPLY);
-
-       return ret;
 }
 
 int _app_status_get_pkgid_bypid(int fd, int pid)