Fix app_control process 06/40506/3 submit/tizen/20150605.041856 submit/tizen/20150605.044443
authorSangyoon Jang <s89.jang@samsung.com>
Thu, 4 Jun 2015 11:42:25 +0000 (20:42 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Fri, 5 Jun 2015 02:02:38 +0000 (11:02 +0900)
retrieve appcontrol info when getting appinfo
fix appcontrol_x
fix pkgmgrinfo_appinfo_foreach_appcontrol
fix pkgmgrinfo_appinfo_get_installed_list

Change-Id: Ie70c08331df3981a1d99035b8ba66d8280b0b7d6
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
include/pkgmgr-info.h
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info.c

index 264c110..1577dd3 100644 (file)
@@ -308,7 +308,7 @@ typedef int (*pkgmgrinfo_app_metadata_list_cb ) (const char *metadata_key,
  *
  * @see  pkgmgrinfo_appinfo_foreach_appcontrol()
  */
-typedef int (*pkgmgrinfo_app_control_list_cb ) (pkgmgrinfo_appcontrol_h handle,
+typedef int (*pkgmgrinfo_app_control_list_cb ) (const char *operation, const char *uri, const char *mime,
                                                        void *user_data);
 
 /**
@@ -3513,8 +3513,6 @@ static int check_operation(const char *appid, char *operation)
  */
 int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data);
-int pkgmgrinfo_usr_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
-                       pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data, uid_t uid);
 
 /**
  * @fn int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
index c28dfa3..8d5ef0d 100644 (file)
@@ -1741,50 +1741,15 @@ static void __ps_free_appcontrol(appcontrol_x *appcontrol)
 {
        if (appcontrol == NULL)
                return;
-       if (appcontrol->text) {
-               free((void *)appcontrol->text);
-               appcontrol->text = NULL;
-       }
        /*Free Operation*/
-       if (appcontrol->operation) {
-               operation_x *operation = appcontrol->operation;
-               operation_x *tmp = NULL;
-               while(operation != NULL) {
-                       tmp = operation->next;
-                       __ps_free_operation(operation);
-                       operation = tmp;
-               }
-       }
+       if (appcontrol->operation)
+               free(appcontrol->operation);
        /*Free Uri*/
-       if (appcontrol->uri) {
-               uri_x *uri = appcontrol->uri;
-               uri_x *tmp = NULL;
-               while(uri != NULL) {
-                       tmp = uri->next;
-                       __ps_free_uri(uri);
-                       uri = tmp;
-               }
-       }
+       if (appcontrol->uri)
+               free(appcontrol->uri);
        /*Free Mime*/
-       if (appcontrol->mime) {
-               mime_x *mime = appcontrol->mime;
-               mime_x *tmp = NULL;
-               while(mime != NULL) {
-                       tmp = mime->next;
-                       __ps_free_mime(mime);
-                       mime = tmp;
-               }
-       }
-       /*Free subapp*/
-       if (appcontrol->subapp) {
-               subapp_x *subapp = appcontrol->subapp;
-               subapp_x *tmp = NULL;
-               while(subapp != NULL) {
-                       tmp = subapp->next;
-                       __ps_free_subapp(subapp);
-                       subapp = tmp;
-               }
-       }
+       if (appcontrol->mime)
+               free(appcontrol->mime);
        free((void*)appcontrol);
        appcontrol = NULL;
 }
@@ -2724,10 +2689,6 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
        const xmlChar *node;
        int ret = -1;
        int depth = -1;
-       operation_x *tmp1 = NULL;
-       uri_x *tmp2 = NULL;
-       mime_x *tmp3 = NULL;
-       subapp_x *tmp4 = NULL;
 
        depth = xmlTextReaderDepth(reader);
        while ((ret = __next_child_element(reader, depth))) {
@@ -2738,45 +2699,14 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
                }
 
                if (!strcmp(ASCII(node), "operation")) {
-                       operation_x *operation = malloc(sizeof(operation_x));
-                       if (operation == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(operation, '\0', sizeof(operation_x));
-                       LISTADD(appcontrol->operation, operation);
-                       ret = __ps_process_operation(reader, operation);
+                       appcontrol->operation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
                        _LOGD("operation processing\n");
                } else if (!strcmp(ASCII(node), "uri")) {
-                       uri_x *uri= malloc(sizeof(uri_x));
-                       if (uri == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(uri, '\0', sizeof(uri_x));
-                       LISTADD(appcontrol->uri, uri);
-                       ret = __ps_process_uri(reader, uri);
+                       appcontrol->uri = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
                        _LOGD("uri processing\n");
                } else if (!strcmp(ASCII(node), "mime")) {
-                       mime_x *mime = malloc(sizeof(mime_x));
-                       if (mime == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(mime, '\0', sizeof(mime_x));
-                       LISTADD(appcontrol->mime, mime);
-                       ret = __ps_process_mime(reader, mime);
+                       appcontrol->mime = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
                        _LOGD("mime processing\n");
-               } else if (!strcmp(ASCII(node), "subapp")) {
-                       subapp_x *subapp = malloc(sizeof(subapp_x));
-                       if (subapp == NULL) {
-                               _LOGD("Malloc Failed\n");
-                               return -1;
-                       }
-                       memset(subapp, '\0', sizeof(subapp_x));
-                       LISTADD(appcontrol->subapp, subapp);
-                       ret = __ps_process_subapp(reader, subapp);
-                       _LOGD("subapp processing\n");
                } else
                        return -1;
                if (ret < 0) {
@@ -2784,26 +2714,6 @@ static int __ps_process_appcontrol(xmlTextReaderPtr reader, appcontrol_x *appcon
                        return ret;
                }
        }
-       if (appcontrol->operation) {
-               LISTHEAD(appcontrol->operation, tmp1);
-               appcontrol->operation = tmp1;
-       }
-       if (appcontrol->uri) {
-               LISTHEAD(appcontrol->uri, tmp2);
-               appcontrol->uri = tmp2;
-       }
-       if (appcontrol->mime) {
-               LISTHEAD(appcontrol->mime, tmp3);
-               appcontrol->mime = tmp3;
-       }
-       if (appcontrol->subapp) {
-               LISTHEAD(appcontrol->subapp, tmp4);
-               appcontrol->subapp = tmp4;
-       }
-
-       xmlTextReaderRead(reader);
-       if (xmlTextReaderValue(reader))
-               appcontrol->text = ASCII(xmlTextReaderValue(reader));
 
        return ret;
 }
@@ -4619,68 +4529,16 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, A
 
                        uiapplication_x *up = mfx->uiapplication;
                        appcontrol_x *acontrol = NULL;
-                       operation_x *op = NULL;
-                       mime_x *mi = NULL;
-                       uri_x *ui = NULL;
-                       subapp_x *sub = NULL;
-                       const char *operation = NULL;
-                       const char *mime = NULL;
-                       const char *uri = NULL;
-                       const char *subapp = NULL;
-                       int i = 0;
-
                        acontrol = up->appcontrol;
                        while(acontrol != NULL) {
-                               op = acontrol->operation;
-                               while(op != NULL) {
-                                       if (op)
-                                               operation = op->name;
-                                       mi = acontrol->mime;
-
-                                       do
-                                       {
-                                               if (mi)
-                                                       mime = mi->name;
-                                               sub = acontrol->subapp;
-                                               do
-                                               {
-                                                       if (sub)
-                                                               subapp = sub->name;
-                                                       ui = acontrol->uri;
-                                                       do
-                                                       {
-                                                               if (ui)
-                                                                       uri = ui->name;
-
-                                                               if(i++ > 0) {
-                                                                       strncpy(buftemp, buf, BUFMAX);
-                                                                       snprintf(buf, BUFMAX, "%s;", buftemp);
-                                                               }
-
-                                                               strncpy(buftemp, buf, BUFMAX);
-                                                               snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
-                                                               _LOGD("buf[%s]\n", buf);
-
-                                                               if (ui)
-                                                                       ui = ui->next;
-                                                               uri = NULL;
-                                                       } while(ui != NULL);
-                                               if (sub)
-                                                               sub = sub->next;
-                                                       subapp = NULL;
-                                               }while(sub != NULL);
-                                               if (mi)
-                                                       mi = mi->next;
-                                               mime = NULL;
-                                       }while(mi != NULL);
-                                       if (op)
-                                               op = op->next;
-                                       operation = NULL;
-                               }
+                               snprintf(buf, BUFMAX, "%s|%s|%s",
+                                               acontrol->operation ? acontrol->operation : "NULL",
+                                               acontrol->uri ? acontrol->uri : "NULL",
+                                               acontrol->mime ? acontrol->mime : "NULL");
+                               _LOGD("buf[%s]\n", buf);
                                acontrol = acontrol->next;
                        }
 
-
                        fwrite(buf, 1, strlen(buf), file);
 
 //                     strncpy(buftemp, buf, BUFMAX);
index c737790..14abe28 100644 (file)
@@ -310,11 +310,9 @@ typedef struct appsvc_x {
 } appsvc_x;
 
 typedef struct appcontrol_x {
-       const char *text;
-       struct operation_x *operation;
-       struct uri_x *uri;
-       struct mime_x *mime;
-       struct subapp_x *subapp;
+       const char *operation;
+       const char *uri;
+       const char *mime;
        struct appcontrol_x *prev;
        struct appcontrol_x *next;
 } appcontrol_x;
index cdaece4..02f1674 100644 (file)
@@ -971,68 +971,26 @@ static int __insert_uiapplication_appcontrol_info(manifest_x *mfx)
 {
        uiapplication_x *up = mfx->uiapplication;
        appcontrol_x *acontrol = NULL;
-       operation_x *op = NULL;
-       mime_x *mi = NULL;
-       uri_x *ui = NULL;
-       subapp_x *sub = NULL;
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
        char buf[BUFSIZE] = {'\0'};
-       const char *operation = NULL;
-       const char *mime = NULL;
-       const char *uri = NULL;
-       const char *subapp = NULL;
        while (up != NULL) {
                acontrol = up->appcontrol;
                while (acontrol != NULL) {
-                       op = acontrol->operation;
-                       while (op != NULL) {
-                               if (op)
-                                       operation = op->name;
-                               mi = acontrol->mime;
-
-                               do {
-                                       if (mi)
-                                               mime = mi->name;
-                                       sub = acontrol->subapp;
-                                       do {
-                                               if (sub)
-                                                       subapp = sub->name;
-                                               ui = acontrol->uri;
-                                               do {
-                                                       if (ui)
-                                                               uri = ui->name;
-                                                       snprintf(buf, BUFSIZE, "%s|%s|%s|%s",
-                                                                       operation ? operation : "NULL",
-                                                                       uri ? uri : "NULL",
-                                                                       mime ? mime : "NULL",
-                                                                       subapp ? subapp : "NULL");
-                                                       snprintf(query, MAX_QUERY_LEN,
-                                                                       "insert into package_app_app_control(app_id, app_control) " \
-                                                                       "values('%s', '%s')",\
-                                                                       up->appid, buf);
-                                                       ret = __exec_query(query);
-                                                       if (ret == -1) {
-                                                               _LOGD("Package UiApp AppSvc DB Insert Failed\n");
-                                                               return -1;
-                                                       }
-                                                       memset(query, '\0', MAX_QUERY_LEN);
-                                                       if (ui)
-                                                               ui = ui->next;
-                                                       uri = NULL;
-                                               } while (ui != NULL);
-                                               if (sub)
-                                                       sub = sub->next;
-                                               subapp = NULL;
-                                       } while (sub != NULL);
-                                       if (mi)
-                                               mi = mi->next;
-                                       mime = NULL;
-                               } while (mi != NULL);
-                               if (op)
-                                       op = op->next;
-                               operation = NULL;
+                       snprintf(buf, BUFSIZE, "%s|%s|%s",\
+                                       acontrol->operation ? acontrol->operation : "NULL",
+                                       acontrol->uri ? acontrol->uri : "NULL",
+                                       acontrol->mime ? acontrol->mime : "NULL");
+                       snprintf(query, MAX_QUERY_LEN,
+                                       "insert into package_app_app_control(app_id, app_control) " \
+                                       "values('%s', '%s')",\
+                                       up->appid, buf);
+                       ret = __exec_query(query);
+                       if (ret == -1) {
+                               _LOGD("Package UiApp AppSvc DB Insert Failed\n");
+                               return -1;
                        }
+                       memset(query, '\0', MAX_QUERY_LEN);
                        acontrol = acontrol->next;
                }
                up = up->next;
@@ -1309,64 +1267,23 @@ static int __insert_serviceapplication_appcontrol_info(manifest_x *mfx)
        int ret = -1;
        char query[MAX_QUERY_LEN] = {'\0'};
        char buf[BUFSIZE] = {'\0'};
-       operation_x *op = NULL;
-       mime_x *mi = NULL;
-       uri_x *ui = NULL;
-       subapp_x *sub = NULL;
-       const char *operation = NULL;
-       const char *mime = NULL;
-       const char *uri = NULL;
-       const char *subapp = NULL;
        while (sp != NULL) {
                acontrol = sp->appcontrol;
                while (acontrol != NULL) {
-                       op = acontrol->operation;
-                       while (op != NULL) {
-                               if (op)
-                                       operation = op->name;
-                               mi = acontrol->mime;
-                               do {
-                                       if (mi)
-                                               mime = mi->name;
-                                       sub = acontrol->subapp;
-                                       do {
-                                               if (sub)
-                                                       subapp = sub->name;
-                                               ui = acontrol->uri;
-                                               do {
-                                                       if (ui)
-                                                               uri = ui->name;
-                                                       snprintf(buf, BUFSIZE, "%s|%s|%s|%s",
-                                                                       operation ? operation : "NULL",
-                                                                       uri ? uri : "NULL",
-                                                                       mime ? mime : "NULL",
-                                                                       subapp ? subapp : "NULL");
-                                                       snprintf(query, MAX_QUERY_LEN,
-                                                                       "insert into package_app_app_control(app_id, app_control) " \
-                                                                       "values('%s', '%s')",\
-                                                                       sp->appid, buf);
-                                                       ret = __exec_query(query);
-                                                       if (ret == -1) {
-                                                               _LOGD("Package UiApp AppSvc DB Insert Failed\n");
-                                                               return -1;
-                                                       }
-                                                       memset(query, '\0', MAX_QUERY_LEN);
-                                                       if (ui)
-                                                               ui = ui->next;
-                                                       uri = NULL;
-                                               } while (ui != NULL);
-                                               if (sub)
-                                                       sub = sub->next;
-                                               subapp = NULL;
-                                       } while (sub != NULL);
-                                       if (mi)
-                                               mi = mi->next;
-                                       mime = NULL;
-                               } while (mi != NULL);
-                               if (op)
-                                       op = op->next;
-                               operation = NULL;
+                       snprintf(buf, BUFSIZE, "%s|%s|%s",
+                                       acontrol->operation ? acontrol->operation : "NULL",
+                                       acontrol->uri ? acontrol->uri : "NULL",
+                                       acontrol->mime ? acontrol->mime : "NULL");
+                       snprintf(query, MAX_QUERY_LEN,
+                                       "insert into package_app_app_control(app_id, app_control) " \
+                                       "values('%s', '%s')",\
+                                       sp->appid, buf);
+                       ret = __exec_query(query);
+                       if (ret == -1) {
+                               _LOGD("Package UiApp AppSvc DB Insert Failed\n");
+                               return -1;
                        }
+                       memset(query, '\0', MAX_QUERY_LEN);
                        acontrol = acontrol->next;
                }
                sp = sp->next;
index e366344..609f644 100644 (file)
@@ -1902,6 +1902,34 @@ static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colnam
        return 0;
 }
 
+static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
+{
+       char *dup;
+       char *token;
+       char *ptr;
+       appcontrol_x *ac;
+
+       if (appcontrol_str == NULL)
+               return;
+
+       dup = strdup(appcontrol_str);
+       do {
+               ac = calloc(1, sizeof(appcontrol_x));
+               token = strtok_r(dup, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->operation = strdup(token);
+               token = strtok_r(NULL, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->uri = strdup(token);
+               token = strtok_r(NULL, "|", &ptr);
+               if (strcmp(token, "NULL"))
+                       ac->mime = strdup(token);
+               LISTADD(*appcontrol, ac);
+       } while (token = strtok_r(NULL, ";", &ptr));
+
+       free(dup);
+}
+
 static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
 {
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
@@ -1912,6 +1940,7 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
        metadata_x *metadata = NULL;
        permission_x *permission = NULL;
        image_x *image = NULL;
+       appcontrol_x *appcontrol = NULL;
 
        switch (info->app_component) {
        case PMINFO_UI_APP:
@@ -2099,6 +2128,8 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->uiapp_info->launch_mode = strdup(coltxt[i]);
                                else
                                        info->uiapp_info->launch_mode = NULL;
+                       } else if (strcmp(colname[i], "app_control") == 0 ) {
+                               __parse_appcontrol(&info->uiapp_info->appcontrol, coltxt[i]);
                        } else
                                continue;
                }
@@ -2200,6 +2231,8 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->svcapp_info->permission_type = strdup(coltxt[i]);
                                else
                                        info->svcapp_info->permission_type = NULL;
+                       } else if (strcmp(colname[i], "app_control") == 0 ) {
+                               __parse_appcontrol(&info->svcapp_info->appcontrol, coltxt[i]);
                        } else
                                continue;
                }
@@ -4503,6 +4536,7 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
        metadata_x *ptr4 = NULL;
        permission_x *ptr5 = NULL;
        image_x *ptr6 = NULL;
+       appcontrol_x *ptr7 = NULL;
        const char* user_pkg_parser = NULL;
 
        /*get system locale*/
@@ -4591,6 +4625,12 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                        ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+                       /*store app control info*/
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
+                       memset(query, '\0', MAX_QUERY_LEN);
                        if (appinfo->uiapp_info->label) {
                                LISTHEAD(appinfo->uiapp_info->label, ptr2);
                                appinfo->uiapp_info->label = ptr2;
@@ -4615,6 +4655,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                                LISTHEAD(appinfo->uiapp_info->image, ptr6);
                                appinfo->uiapp_info->image = ptr6;
                        }
+                       if (appinfo->uiapp_info->appcontrol) {
+                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+                               appinfo->uiapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4647,6 +4691,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                        ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->svcapp_info->label) {
                                LISTHEAD(appinfo->svcapp_info->label, ptr2);
                                appinfo->svcapp_info->label = ptr2;
@@ -4667,6 +4715,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                                LISTHEAD(appinfo->svcapp_info->permission, ptr5);
                                appinfo->svcapp_info->permission = ptr5;
                        }
+                       if (appinfo->svcapp_info->appcontrol) {
+                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+                               appinfo->svcapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4716,6 +4768,11 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                        ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+                       /*store app control info*/
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->uiapp_info->label) {
                                LISTHEAD(appinfo->uiapp_info->label, ptr2);
                                appinfo->uiapp_info->label = ptr2;
@@ -4740,6 +4797,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                                LISTHEAD(appinfo->uiapp_info->image, ptr6);
                                appinfo->uiapp_info->image = ptr6;
                        }
+                       if (appinfo->uiapp_info->appcontrol) {
+                               LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+                               appinfo->uiapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4769,6 +4830,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                        ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
 
+                       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+                       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+                       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                        if (appinfo->svcapp_info->label) {
                                LISTHEAD(appinfo->svcapp_info->label, ptr2);
                                appinfo->svcapp_info->label = ptr2;
@@ -4789,6 +4854,10 @@ API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_
                                LISTHEAD(appinfo->svcapp_info->permission, ptr5);
                                appinfo->svcapp_info->permission = ptr5;
                        }
+                       if (appinfo->svcapp_info->appcontrol) {
+                               LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+                               appinfo->svcapp_info->appcontrol = ptr7;
+                       }
                        ret = app_func((void *)appinfo, user_data);
                        if (ret < 0)
                                break;
@@ -4931,6 +5000,7 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_fun
        metadata_x *tmp4 = NULL;
        permission_x *tmp5 = NULL;
        image_x *tmp6 = NULL;
+       appcontrol_x *tmp7 = NULL;
        const char *user_pkg_parser = NULL;
 
        /*get system locale*/
@@ -5014,13 +5084,18 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_fun
                snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
                ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-               
+
                /*store app preview image info*/
                memset(query, '\0', MAX_QUERY_LEN);
                snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
                ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+               /*store app control info*/
+               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr1->appid);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                if (appinfo->uiapp_info->label) {
                        LISTHEAD(appinfo->uiapp_info->label, tmp1);
                        appinfo->uiapp_info->label = tmp1;
@@ -5045,6 +5120,10 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_fun
                        LISTHEAD(appinfo->uiapp_info->image, tmp6);
                        appinfo->uiapp_info->image = tmp6;
                }
+               if (appinfo->uiapp_info->appcontrol) {
+                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+                       appinfo->uiapp_info->appcontrol = tmp7;
+               }
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
@@ -5081,6 +5160,10 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_fun
                ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
                tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
 
+               snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr2->appid);
+               ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+               tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
                if (appinfo->svcapp_info->label) {
                        LISTHEAD(appinfo->svcapp_info->label, tmp1);
                        appinfo->svcapp_info->label = tmp1;
@@ -5101,6 +5184,10 @@ API int pkgmgrinfo_appinfo_get_usr_installed_list(pkgmgrinfo_app_list_cb app_fun
                        LISTHEAD(appinfo->svcapp_info->permission, tmp5);
                        appinfo->svcapp_info->permission = tmp5;
                }
+               if (appinfo->svcapp_info->appcontrol) {
+                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+                       appinfo->svcapp_info->appcontrol = tmp7;
+               }
                ret = app_func((void *)appinfo, user_data);
                if (ret < 0)
                        break;
@@ -5148,6 +5235,7 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgri
        metadata_x *tmp4 = NULL;
        permission_x *tmp5 = NULL;
        image_x *tmp6 = NULL;
+       appcontrol_x *tmp7 = NULL;
        char query[MAX_QUERY_LEN] = {'\0'};
        const char* user_pkg_parser = NULL;
 
@@ -5239,6 +5327,11 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgri
        ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
        tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
 
+       /*store app control info*/
+       snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+       ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+       tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
        switch (appinfo->app_component) {
        case PMINFO_UI_APP:
                if (appinfo->uiapp_info->label) {
@@ -5265,6 +5358,10 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgri
                        LISTHEAD(appinfo->uiapp_info->image, tmp6);
                        appinfo->uiapp_info->image = tmp6;
                }
+               if (appinfo->uiapp_info->appcontrol) {
+                       LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+                       appinfo->uiapp_info->appcontrol = tmp7;
+               }
                break;
        case PMINFO_SVC_APP:
                if (appinfo->svcapp_info->label) {
@@ -5287,6 +5384,10 @@ API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid, pkgmgri
                        LISTHEAD(appinfo->svcapp_info->permission, tmp5);
                        appinfo->svcapp_info->permission = tmp5;
                }
+               if (appinfo->svcapp_info->appcontrol) {
+                       LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+                       appinfo->svcapp_info->appcontrol = tmp7;
+               }
                break;
        default:
                break;
@@ -5963,371 +6064,40 @@ API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_usr_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
-                       pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data, uid_t uid)
-{
-       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
-       retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
-       int i = 0;
-       int ret = -1;
-       int oc = 0;
-       int mc = 0;
-       int uc = 0;
-       int sc = 0;
-       char *pkgid = NULL;
-       char *manifest = NULL;
-       char **operation = NULL;
-       char **uri = NULL;
-       char **mime = NULL;
-       char **subapp = NULL;
-       appcontrol_x *appcontrol = NULL;
-       manifest_x *mfx = NULL;
-       operation_x *op = NULL;
-       uri_x *ui = NULL;
-       mime_x *mi = NULL;
-       subapp_x *sa = NULL;
-       pkgmgrinfo_app_component component;
-       pkgmgrinfo_appcontrol_x *ptr = NULL;
-       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
-       if (ret < 0) {
-               _LOGE("Failed to get package name\n");
-               return PMINFO_R_ERROR;
-       }
-       ret = pkgmgrinfo_appinfo_get_component(handle, &component);
-       if (ret < 0) {
-               _LOGE("Failed to get app component name\n");
-               return PMINFO_R_ERROR;
-       }
-       manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
-       if (manifest == NULL) {
-               _LOGE("Failed to fetch package manifest file\n");
-               return PMINFO_R_ERROR;
-       }
-       mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
-       if (mfx == NULL) {
-               _LOGE("Failed to parse package manifest file\n");
-               free(manifest);
-               manifest = NULL;
-               return PMINFO_R_ERROR;
-       }
-       free(manifest);
-       ptr  = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
-       if (ptr == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               pkgmgr_parser_free_manifest_xml(mfx);
-               return PMINFO_R_ERROR;
-       }
-       /*Get Operation, Uri, Mime*/
-       switch (component) {
-       case PMINFO_UI_APP:
-               if (mfx->uiapplication) {
-                       if (mfx->uiapplication->appsvc) {
-                               appcontrol = mfx->uiapplication->appsvc;
-                       }
-               }
-               break;
-       case PMINFO_SVC_APP:
-               if (mfx->serviceapplication) {
-                       if (mfx->serviceapplication->appsvc) {
-                               appcontrol = mfx->serviceapplication->appsvc;
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-       for (; appcontrol; appcontrol = appcontrol->next) {
-               op = appcontrol->operation;
-               for (; op; op = op->next)
-                       oc = oc + 1;
-               op = appcontrol->operation;
-
-               ui = appcontrol->uri;
-               for (; ui; ui = ui->next)
-                       uc = uc + 1;
-               ui = appcontrol->uri;
-
-               mi = appcontrol->mime;
-               for (; mi; mi = mi->next)
-                       mc = mc + 1;
-               mi = appcontrol->mime;
-
-               sa = appcontrol->subapp;
-               for (; sa; sa = sa->next)
-                       sc = sc + 1;
-               sa = appcontrol->subapp;
-
-               operation = (char **)calloc(oc, sizeof(char *));
-               for (i = 0; i < oc; i++) {
-                       operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
-                       op = op->next;
-               }
-
-               uri = (char **)calloc(uc, sizeof(char *));
-               for (i = 0; i < uc; i++) {
-                       uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
-                       ui = ui->next;
-               }
-
-               mime = (char **)calloc(mc, sizeof(char *));
-               for (i = 0; i < mc; i++) {
-                       mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
-                       mi = mi->next;
-               }
-
-               subapp = (char **)calloc(sc, sizeof(char *));
-               for (i = 0; i < sc; i++) {
-                       subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
-                       sa = sa->next;
-               }
-
-               /*populate appcontrol handle*/
-               ptr->operation_count = oc;
-               ptr->uri_count = uc;
-               ptr->mime_count = mc;
-               ptr->subapp_count = sc;
-               ptr->operation = operation;
-               ptr->uri = uri;
-               ptr->mime = mime;
-               ptr->subapp = subapp;
-
-               ret = appcontrol_func((void *)ptr, user_data);
-               for (i = 0; i < oc; i++) {
-                       if (operation[i]) {
-                               free(operation[i]);
-                               operation[i] = NULL;
-                       }
-               }
-               if (operation) {
-                       free(operation);
-                       operation = NULL;
-               }
-               for (i = 0; i < uc; i++) {
-                       if (uri[i]) {
-                               free(uri[i]);
-                               uri[i] = NULL;
-                       }
-               }
-               if (uri) {
-                       free(uri);
-                       uri = NULL;
-               }
-               for (i = 0; i < mc; i++) {
-                       if (mime[i]) {
-                               free(mime[i]);
-                               mime[i] = NULL;
-                       }
-               }
-               if (mime) {
-                       free(mime);
-                       mime = NULL;
-               }
-               for (i = 0; i < sc; i++) {
-                       if (subapp[i]) {
-                               free(subapp[i]);
-                               subapp[i] = NULL;
-                       }
-               }
-               if (subapp) {
-                       free(subapp);
-                       subapp = NULL;
-               }
-               if (ret < 0)
-                       break;
-               uc = 0;
-               mc = 0;
-               oc = 0;
-               sc = 0;
-       }
-       pkgmgr_parser_free_manifest_xml(mfx);
-       if (ptr) {
-               free(ptr);
-               ptr = NULL;
-       }
-       return PMINFO_R_OK;
-}
-
 API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
-       int i = 0;
-       int ret = -1;
-       int oc = 0;
-       int mc = 0;
-       int uc = 0;
-       int sc = 0;
-       char *pkgid = NULL;
-       char *manifest = NULL;
-       char **operation = NULL;
-       char **uri = NULL;
-       char **mime = NULL;
-       char **subapp = NULL;
-       appcontrol_x *appcontrol = NULL;
-       manifest_x *mfx = NULL;
-       operation_x *op = NULL;
-       uri_x *ui = NULL;
-       mime_x *mi = NULL;
-       subapp_x *sa = NULL;
+       int ret;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       appcontrol_x *appcontrol;
        pkgmgrinfo_app_component component;
-       pkgmgrinfo_appcontrol_x *ptr = NULL;
-       ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
-       if (ret < 0) {
-               _LOGE("Failed to get package name\n");
-               return PMINFO_R_ERROR;
-       }
        ret = pkgmgrinfo_appinfo_get_component(handle, &component);
        if (ret < 0) {
                _LOGE("Failed to get app component name\n");
                return PMINFO_R_ERROR;
        }
-       manifest = pkgmgr_parser_get_manifest_file(pkgid);
-       if (manifest == NULL) {
-               _LOGE("Failed to fetch package manifest file\n");
-               return PMINFO_R_ERROR;
-       }
-       mfx = pkgmgr_parser_process_manifest_xml(manifest);
-       if (mfx == NULL) {
-               _LOGE("Failed to parse package manifest file\n");
-               free(manifest);
-               manifest = NULL;
-               return PMINFO_R_ERROR;
-       }
-       free(manifest);
-       ptr  = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
-       if (ptr == NULL) {
-               _LOGE("Out of Memory!!!\n");
-               pkgmgr_parser_free_manifest_xml(mfx);
-               return PMINFO_R_ERROR;
-       }
-       /*Get Operation, Uri, Mime*/
        switch (component) {
        case PMINFO_UI_APP:
-               if (mfx->uiapplication) {
-                       if (mfx->uiapplication->appsvc) {
-                               appcontrol = mfx->uiapplication->appsvc;
-                       }
-               }
+               if (info->uiapp_info == NULL)
+                       return PMINFO_R_EINVAL;
+               appcontrol = info->uiapp_info->appcontrol;
                break;
        case PMINFO_SVC_APP:
-               if (mfx->serviceapplication) {
-                       if (mfx->serviceapplication->appsvc) {
-                               appcontrol = mfx->serviceapplication->appsvc;
-                       }
-               }
+               if (info->svcapp_info == NULL)
+                       return PMINFO_R_EINVAL;
+               appcontrol = info->svcapp_info->appcontrol;
                break;
        default:
                break;
        }
        for (; appcontrol; appcontrol = appcontrol->next) {
-               op = appcontrol->operation;
-               for (; op; op = op->next)
-                       oc = oc + 1;
-               op = appcontrol->operation;
-
-               ui = appcontrol->uri;
-               for (; ui; ui = ui->next)
-                       uc = uc + 1;
-               ui = appcontrol->uri;
-
-               mi = appcontrol->mime;
-               for (; mi; mi = mi->next)
-                       mc = mc + 1;
-               mi = appcontrol->mime;
-
-               sa = appcontrol->subapp;
-               for (; sa; sa = sa->next)
-                       sc = sc + 1;
-               sa = appcontrol->subapp;
-
-               operation = (char **)calloc(oc, sizeof(char *));
-               for (i = 0; i < oc; i++) {
-                       operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
-                       op = op->next;
-               }
-
-               uri = (char **)calloc(uc, sizeof(char *));
-               for (i = 0; i < uc; i++) {
-                       uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
-                       ui = ui->next;
-               }
-
-               mime = (char **)calloc(mc, sizeof(char *));
-               for (i = 0; i < mc; i++) {
-                       mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
-                       mi = mi->next;
-               }
-
-               subapp = (char **)calloc(sc, sizeof(char *));
-               for (i = 0; i < sc; i++) {
-                       subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
-                       sa = sa->next;
-               }
-
-               /*populate appcontrol handle*/
-               ptr->operation_count = oc;
-               ptr->uri_count = uc;
-               ptr->mime_count = mc;
-               ptr->subapp_count = sc;
-               ptr->operation = operation;
-               ptr->uri = uri;
-               ptr->mime = mime;
-               ptr->subapp = subapp;
-
-               ret = appcontrol_func((void *)ptr, user_data);
-               for (i = 0; i < oc; i++) {
-                       if (operation[i]) {
-                               free(operation[i]);
-                               operation[i] = NULL;
-                       }
-               }
-               if (operation) {
-                       free(operation);
-                       operation = NULL;
-               }
-               for (i = 0; i < uc; i++) {
-                       if (uri[i]) {
-                               free(uri[i]);
-                               uri[i] = NULL;
-                       }
-               }
-               if (uri) {
-                       free(uri);
-                       uri = NULL;
-               }
-               for (i = 0; i < mc; i++) {
-                       if (mime[i]) {
-                               free(mime[i]);
-                               mime[i] = NULL;
-                       }
-               }
-               if (mime) {
-                       free(mime);
-                       mime = NULL;
-               }
-               for (i = 0; i < sc; i++) {
-                       if (subapp[i]) {
-                               free(subapp[i]);
-                               subapp[i] = NULL;
-                       }
-               }
-               if (subapp) {
-                       free(subapp);
-                       subapp = NULL;
-               }
+               ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
                if (ret < 0)
                        break;
-               uc = 0;
-               mc = 0;
-               oc = 0;
-               sc = 0;
-       }
-       pkgmgr_parser_free_manifest_xml(mfx);
-       if (ptr) {
-               free(ptr);
-               ptr = NULL;
        }
+
        return PMINFO_R_OK;
 }