Fix __get_path_from_db 36/193336/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Tue, 20 Nov 2018 02:05:22 +0000 (11:05 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Tue, 20 Nov 2018 04:51:23 +0000 (13:51 +0900)
If appid is not given, get appid from current pid.

Change-Id: Ie902a6855b3a9cb991640a86babf923df4e709e2
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/aul_path.c

index c7c8ea1..127144a 100644 (file)
@@ -165,6 +165,7 @@ static int __get_path_from_db(char **path, const char *appid, const char *dir_na
 {
        char *_path;
        char buf[PATH_MAX];
+       char appid_buf[NAME_MAX];
        int ret;
        pkgmgrinfo_appinfo_h appinfo;
        int len;
@@ -180,7 +181,17 @@ static int __get_path_from_db(char **path, const char *appid, const char *dir_na
                return AUL_R_OK;
        }
 
-       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &appinfo);
+       if (appid == NULL) {
+               ret = aul_app_get_appid_bypid(getpid(), appid_buf,
+                               sizeof(appid_buf));
+               if (ret != AUL_R_OK) {
+                       _E("appid is not given and failed to get appid");
+                       return ret;
+               }
+       }
+
+       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid ? appid : appid_buf, uid,
+                       &appinfo);
        if (ret != PMINFO_R_OK) {
                _E("Failed to get appinfo. (ret:%d)", ret);
                return AUL_R_ENOAPP;