Release version 0.24.14
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_appinfo.c
index ad481a3..8ea2611 100644 (file)
@@ -179,11 +179,32 @@ API int pkgmgrinfo_appinfo_get_disabled_appinfo(
                        appid, _getuid(), handle);
 }
 
+static char *__get_real_appid(const char *appid)
+{
+       char *str;
+       char *saveptr;
+       char *token;
+
+       str = strdup(appid);
+       if (str == NULL)
+               return NULL;
+
+       token = strtok_r(str, "::", &saveptr);
+       if (token == NULL)
+               return str;
+
+       LOGD("Real appid = %s", token);
+       token = strdup(token);
+       free(str);
+       return token;
+}
+
 API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
                pkgmgrinfo_appinfo_h *handle)
 {
        int ret;
        pkgmgrinfo_appinfo_filter_h filter;
+       char *real_appid;
 
        if (appid == NULL || handle == NULL) {
                LOGE("invalid parameter");
@@ -194,10 +215,18 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
        if (ret != PMINFO_R_OK)
                return ret;
 
+       real_appid = __get_real_appid(appid);
+       if (real_appid == NULL) {
+               LOGE("Out of memory");
+               pkgmgrinfo_appinfo_filter_destroy(filter);
+               return PMINFO_R_ERROR;
+       }
+
        ret = pkgmgrinfo_appinfo_filter_add_string(filter,
-                       PMINFO_APPINFO_PROP_APP_ID, appid);
+                       PMINFO_APPINFO_PROP_APP_ID, real_appid);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_filter_destroy(filter);
+               free(real_appid);
                return PMINFO_R_ERROR;
        }
 
@@ -205,6 +234,7 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
                        PMINFO_APPINFO_PROP_APP_DISABLE, false);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_filter_destroy(filter);
+               free(real_appid);
                return PMINFO_R_ERROR;
        }
 
@@ -212,10 +242,12 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
                        PMINFO_APPINFO_PROP_PKG_DISABLE, false);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_filter_destroy(filter);
+               free(real_appid);
                return PMINFO_R_ERROR;
        }
 
-       ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
+       ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
+       free(real_appid);
        pkgmgrinfo_appinfo_filter_destroy(filter);
        return ret;
 }