Refactoring updateinfo related codes
[platform/core/appfw/pkgmgr-server.git] / src / request.c
index 7345026..fe31de8 100644 (file)
@@ -4,10 +4,9 @@
 
 #include <glib.h>
 #include <gio/gio.h>
-#include <gum/gum-user.h>
-#include <gum/common/gum-user-types.h>
 
 #include "queue.h"
+#include "pkgmgr-info.h"
 #include "pkgmgr-server.h"
 #include "package-manager.h"
 
@@ -27,7 +26,6 @@ static const char instropection_xml[] =
        "    </method>"
        "    <method name='reinstall'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='s' name='pkgid' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
@@ -42,14 +40,12 @@ static const char instropection_xml[] =
        "    </method>"
        "    <method name='uninstall'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='s' name='pkgid' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
        "    <method name='move'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='s' name='pkgid' direction='in'/>"
        "      <arg type='i' name='movetype' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
@@ -57,18 +53,32 @@ static const char instropection_xml[] =
        "    </method>"
        "    <method name='enable_pkgs'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='as' name='pkgids' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
        "    <method name='disable_pkgs'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='as' name='pkgids' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
+       "    <method name='register_pkg_update_info'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='s' name='version' direction='in'/>"
+       "      <arg type='i' name='type' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
+       "    <method name='unregister_pkg_update_info'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
+       "    <method name='unregister_all_pkg_update_info'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
        "    <method name='enable_app'>"
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='appid' direction='in'/>"
@@ -81,6 +91,18 @@ static const char instropection_xml[] =
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
+       "    <method name='enable_apps'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='as' name='appids' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "      <arg type='s' name='reqkey' direction='out'/>"
+       "    </method>"
+       "    <method name='disable_apps'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='as' name='appids' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "      <arg type='s' name='reqkey' direction='out'/>"
+       "    </method>"
        "    <method name='enable_global_app_for_uid'>"
        "      <arg type='u' name='uid' direction='in'/>"
        "      <arg type='s' name='appid' direction='in'/>"
@@ -100,9 +122,15 @@ static const char instropection_xml[] =
        "      <arg type='i' name='ret' direction='out'/>"
        "      <arg type='s' name='reqkey' direction='out'/>"
        "    </method>"
+       "    <method name='getsize_sync'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='i' name='get_type' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "      <arg type='x' name='size_info' direction='out'/>"
+       "    </method>"
        "    <method name='cleardata'>"
        "      <arg type='u' name='uid' direction='in'/>"
-       "      <arg type='s' name='pkgtype' direction='in'/>"
        "      <arg type='s' name='pkgid' direction='in'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "    </method>"
@@ -166,6 +194,17 @@ static const char instropection_xml[] =
        "      <arg type='i' name='result' direction='out'/>"
        "      <arg type='i' name='ret' direction='out'/>"
        "    </method>"
+       "    <method name='set_app_label'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='appid' direction='in'/>"
+       "      <arg type='s' name='label' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
+       "    <method name='migrate_external_image'>"
+       "      <arg type='u' name='uid' direction='in'/>"
+       "      <arg type='s' name='pkgid' direction='in'/>"
+       "      <arg type='i' name='ret' direction='out'/>"
+       "    </method>"
        "  </interface>"
        "</node>";
 static GDBusNodeInfo *instropection_data;
@@ -188,7 +227,7 @@ static char *__generate_reqkey(const char *pkgid)
        size = strlen(pkgid) + strlen(timestr) + 2;
        str_req_key = (char *)calloc(size, sizeof(char));
        if (str_req_key == NULL) {
-               DBG("calloc failed");
+               ERR("calloc failed");
                return NULL;
        }
        snprintf(str_req_key, size, "%s_%s", pkgid, timestr);
@@ -196,33 +235,6 @@ static char *__generate_reqkey(const char *pkgid)
        return str_req_key;
 }
 
-static int __is_admin_user(uid_t uid)
-{
-       GumUser *guser;
-       GumUserType ut = GUM_USERTYPE_NONE;
-
-       guser = gum_user_get_sync(uid, FALSE);
-       if (guser == NULL) {
-               ERR("cannot get user information from gumd");
-               return -1;
-       }
-
-       g_object_get(G_OBJECT(guser), "usertype", &ut, NULL);
-       if (ut == GUM_USERTYPE_NONE) {
-               ERR("cannot get user type");
-               g_object_unref(guser);
-               return -1;
-       } else if (ut != GUM_USERTYPE_ADMIN) {
-               g_object_unref(guser);
-               return 0;
-       }
-
-       g_object_unref(guser);
-
-       return 1;
-}
-
-#define REGULAR_USER 5000
 static int __check_caller_permission(uid_t uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
@@ -263,12 +275,13 @@ static int __check_caller_permission(uid_t uid,
        return 0;
 }
 
-static int __handle_request_install(uid_t uid,
+static int __handle_request_install(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
-       char *pkgpath = NULL;
+       char *arg_pkgtype = NULL;
+       const char *pkgtype;
+       const char *pkgpath = NULL;
        char *args = NULL;
        char *reqkey = NULL;
        gchar **tmp_args = NULL;
@@ -277,9 +290,10 @@ static int __handle_request_install(uid_t uid,
        GVariant *value;
        int i = 0;
        int len = 0;
+       size_t s = 0;
 
-       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &pkgtype, &pkgpath,
-                       &value);
+       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
+                       &pkgpath, &value);
        tmp_args = (gchar **)g_variant_get_strv(value, &args_count);
 
        for (i = 0; i < args_count; i++)
@@ -295,19 +309,26 @@ static int __handle_request_install(uid_t uid,
        }
 
        for (i = 0; i < args_count; i++) {
-               strncat(args, tmp_args[i], strlen(tmp_args[i]));
-               if (i != args_count - 1)
-                       strncat(args, " ", strlen(" "));
+               strncat(args, tmp_args[i], len - s - 1);
+               s += strlen(tmp_args[i]);
+               if (i != args_count - 1) {
+                       strncat(args, " ", len - s - 1);
+                       s += strlen(" ");
+               }
        }
 
-       if (target_uid == (uid_t)-1 || pkgtype == NULL) {
+       if (target_uid == (uid_t)-1 || pkgpath == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                ret = -1;
                goto catch;
        }
 
-       if (pkgpath == NULL) {
+       pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid);
+       pkgtype = _get_pkgtype_from_file(pkgpath);
+       if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype))
+               pkgtype = (const char *)arg_pkgtype;
+       if (pkgtype == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                ret = -1;
@@ -322,8 +343,8 @@ static int __handle_request_install(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_INSTALL, pkgtype,
-                               pkgpath, args)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_INSTALL,
+                               pkgtype, pkgpath, args, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -342,15 +363,19 @@ catch:
        if (args)
                free(args);
 
+       if (tmp_args)
+               g_free(tmp_args);
+
        return ret;
 }
 
-static int __handle_request_mount_install(uid_t uid,
+static int __handle_request_mount_install(uid_t caller_uid,
        GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
-       char *pkgpath = NULL;
+       char *arg_pkgtype = NULL;
+       const char *pkgtype;
+       const char *pkgpath = NULL;
        char *args = NULL;
        char *reqkey = NULL;
        gchar **tmp_args = NULL;
@@ -359,9 +384,10 @@ static int __handle_request_mount_install(uid_t uid,
        GVariant *value;
        int i = 0;
        int len = 0;
+       size_t s = 0;
 
-       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &pkgtype, &pkgpath,
-                       &value);
+       g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
+                       &pkgpath, &value);
        tmp_args = (gchar **)g_variant_get_strv(value, &args_count);
 
        for (i = 0; i < args_count; i++)
@@ -377,19 +403,26 @@ static int __handle_request_mount_install(uid_t uid,
        }
 
        for (i = 0; i < args_count; i++) {
-               strncat(args, tmp_args[i], strlen(tmp_args[i]));
-               if (i != args_count - 1)
-                       strncat(args, " ", strlen(" "));
+               strncat(args, tmp_args[i], len - s - 1);
+               s += strlen(tmp_args[i]);
+               if (i != args_count - 1) {
+                       strncat(args, " ", len - s - 1);
+                       s += strlen(" ");
+               }
        }
 
-       if (target_uid == (uid_t)-1 || pkgtype == NULL) {
+       if (target_uid == (uid_t)-1 || pkgpath == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                ret = -1;
                goto catch;
        }
 
-       if (pkgpath == NULL) {
+       pkgpath = _get_adjusted_pkgpath(pkgpath, caller_uid);
+       pkgtype = _get_pkgtype_from_file(pkgpath);
+       if (!pkgtype && arg_pkgtype && strlen(arg_pkgtype))
+               pkgtype = (const char *)arg_pkgtype;
+       if (pkgtype == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                ret = -1;
@@ -404,8 +437,9 @@ static int __handle_request_mount_install(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_MOUNT_INSTALL,
-                               pkgtype, pkgpath, args)) {
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_MOUNT_INSTALL,
+                               pkgtype, pkgpath, args, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -423,133 +457,165 @@ catch:
        if (args)
                free(args);
 
+       if (tmp_args)
+               g_free(tmp_args);
+
        return ret;
 }
 
-static int __handle_request_reinstall(uid_t uid,
+static int __handle_request_reinstall(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
+       char *pkgtype;
        char *pkgid = NULL;
        char *reqkey;
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgid);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgid == NULL) {
+       g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
        }
 
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        reqkey = __generate_reqkey(pkgid);
        if (reqkey == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               free(pkgtype);
                return -1;
        }
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_REINSTALL, pkgtype,
-                               pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_REINSTALL,
+                               pkgtype, pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
+               free(pkgtype);
                return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(is)", PKGMGR_R_OK, reqkey));
        free(reqkey);
+       free(pkgtype);
 
        return 0;
 }
 
-static int __handle_request_uninstall(uid_t uid,
+static int __handle_request_uninstall(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
+       char *pkgtype;
        char *pkgid = NULL;
        char *reqkey;
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgid);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgid == NULL) {
+       g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
        }
 
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        reqkey = __generate_reqkey(pkgid);
        if (reqkey == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               free(pkgtype);
                return -1;
        }
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_UNINSTALL, pkgtype,
-                               pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_UNINSTALL,
+                               pkgtype, pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
+               free(pkgtype);
                return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(is)", PKGMGR_R_OK, reqkey));
        free(reqkey);
+       free(pkgtype);
 
        return 0;
 }
 
-static int __handle_request_move(uid_t uid,
+static int __handle_request_move(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
+       char *pkgtype;
        char *pkgid = NULL;
        char *reqkey;
        int move_type = -1;
        char buf[4] = { '\0' };
 
-       g_variant_get(parameters, "(u&s&si)", &target_uid, &pkgtype, &pkgid,
-                       &move_type);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgid == NULL) {
+       g_variant_get(parameters, "(u&si)", &target_uid, &pkgid, &move_type);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
        }
 
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        reqkey = __generate_reqkey(pkgid);
        if (reqkey == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               free(pkgtype);
                return -1;
        }
 
        snprintf(buf, sizeof(buf), "%d", move_type);
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_MOVE, pkgtype,
-                               pkgid, buf)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_MOVE,
+                               pkgtype, pkgid, buf, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
+               free(pkgtype);
                return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(is)", PKGMGR_R_OK, reqkey));
        free(reqkey);
+       free(pkgtype);
 
        return 0;
 }
 
-static int __handle_request_enable_pkgs(uid_t uid,
+static int __handle_request_enable_pkgs(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
+       char *pkgtype;
        char *pkgid;
        char *reqkey;
        GVariantIter *iter;
 
-       g_variant_get(parameters, "(u&sas)", &target_uid, &pkgtype, &iter);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || iter == NULL) {
+       g_variant_get(parameters, "(uas)", &target_uid, &iter);
+       if (target_uid == (uid_t)-1 || iter == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
@@ -563,14 +629,25 @@ static int __handle_request_enable_pkgs(uid_t uid,
        }
 
        while (g_variant_iter_next(iter, "&s", &pkgid)) {
-               if (_push_queue(target_uid, reqkey, REQUEST_TYPE_ENABLE_PKG,
-                                       pkgtype, pkgid, NULL)) {
+               pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+               if (pkgtype == NULL) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(is)",
+                                               PKGMGR_R_ENOPKG, ""));
+                       free(reqkey);
+                       return -1;
+               }
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_ENABLE_PKG,
+                                       pkgtype, pkgid, NULL, NULL)) {
                        g_dbus_method_invocation_return_value(invocation,
                                        g_variant_new("(is)",
                                                PKGMGR_R_ESYSTEM, ""));
+                       free(pkgtype);
                        free(reqkey);
                        return -1;
                }
+               free(pkgtype);
        }
 
        g_dbus_method_invocation_return_value(invocation,
@@ -580,17 +657,215 @@ static int __handle_request_enable_pkgs(uid_t uid,
        return 0;
 }
 
-static int __handle_request_disable_pkgs(uid_t uid,
+static int __handle_request_register_pkg_update_info(
+               uid_t caller_uid, GDBusMethodInvocation *invocation,
+               GVariant *parameters)
+{
+       char *reqkey;
+       char buf[MAX_PKG_ARGS_LEN];
+       int ret;
+       pkgmgrinfo_pkginfo_h pkg_info;
+       bool is_global_pkg;
+       pkgmgrinfo_updateinfo_h update_info;
+       pkgmgrinfo_updateinfo_update_type converted_type;
+       uid_t target_uid = (uid_t)-1;
+       gchar *pkgid = NULL;
+       gchar *version = NULL;
+
+       g_variant_get(parameters, "(ussi)", &target_uid, &pkgid, &version, &converted_type);
+
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, target_uid, &pkg_info);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EIO));
+               return -1;
+       }
+       ret = pkgmgrinfo_pkginfo_is_global(pkg_info, &is_global_pkg);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EIO));
+               return -1;
+       }
+       pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
+
+       /* return error if given pkg is global pkg but caller is not admin */
+       if (caller_uid >= REGULAR_USER && is_global_pkg
+                       && !__is_admin_user(caller_uid)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EPRIV));
+               return -1;
+       }
+
+       ret = pkgmgrinfo_updateinfo_create(&update_info);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               return -1;
+       }
+
+       ret = pkgmgrinfo_updateinfo_set_pkgid(update_info, (char *)pkgid);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
+               return -1;
+       }
+
+       ret = pkgmgrinfo_updateinfo_set_version(update_info, (char *)version);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
+               return -1;
+       }
+
+       ret = pkgmgrinfo_updateinfo_set_type(update_info, converted_type);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               pkgmgrinfo_updateinfo_destroy(update_info);
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("register_pkg_update_info");
+       if (reqkey == NULL) {
+               pkgmgrinfo_updateinfo_destroy(update_info);
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                       REQUEST_TYPE_REGISTER_PKG_UPDATE_INFO, "default",
+                       NULL, buf, update_info)) {
+               pkgmgrinfo_updateinfo_destroy(update_info);
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(reqkey);
+               return -1;
+       }
+       if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+                               (gpointer)invocation))
+               ERR("reqkey already exists");
+
+       return 0;
+}
+
+static int __handle_request_unregister_pkg_update_info(
+               uid_t caller_uid, GDBusMethodInvocation *invocation,
+               GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *pkgid = NULL;
+       char *reqkey;
+       pkgmgrinfo_pkginfo_h pkg_info;
+       bool is_global_pkg;
+       int ret;
+
+       g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+               return -1;
+       }
+
+       ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, target_uid, &pkg_info);
+       if (ret != PMINFO_R_OK) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EIO));
+               return -1;
+       }
+       ret = pkgmgrinfo_pkginfo_is_global(pkg_info, &is_global_pkg);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EIO));
+               return -1;
+       }
+       pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_info);
+
+       /* return error if given pkg is global pkg but caller is not admin */
+       if (caller_uid >= REGULAR_USER && is_global_pkg
+                       && !__is_admin_user(caller_uid)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_EPRIV));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("unregister_pkg_update_info");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                       REQUEST_TYPE_UNREGISTER_PKG_UPDATE_INFO, "default",
+                       pkgid, NULL, NULL)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(reqkey);
+               return -1;
+       }
+
+       if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+                               (gpointer)invocation))
+               ERR("reqkey already exists");
+
+
+       return 0;
+
+}
+
+static int __handle_request_unregister_all_pkg_update_info(
+               uid_t caller_uid, GDBusMethodInvocation *invocation,
+               GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *reqkey;
+
+       g_variant_get(parameters, "(u)", &target_uid);
+       if (target_uid == (uid_t)-1) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("unregister_all_pkg_update_info");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                       REQUEST_TYPE_UNREGISTER_ALL_PKG_UPDATE_INFO, "default",
+                       NULL, NULL, NULL)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
+               free(reqkey);
+               return -1;
+       }
+
+       if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+                               (gpointer)invocation))
+               ERR("reqkey already exists");
+
+       return 0;
+}
+
+static int __handle_request_disable_pkgs(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
+       char *pkgtype;
        char *pkgid;
        char *reqkey;
        GVariantIter *iter;
 
-       g_variant_get(parameters, "(u&sas)", &target_uid, &pkgtype, &iter);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || iter == NULL) {
+       g_variant_get(parameters, "(uas)", &target_uid, &iter);
+       if (target_uid == (uid_t)-1 || iter == NULL) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
@@ -604,14 +879,25 @@ static int __handle_request_disable_pkgs(uid_t uid,
        }
 
        while (g_variant_iter_next(iter, "&s", &pkgid)) {
-               if (_push_queue(target_uid, reqkey, REQUEST_TYPE_DISABLE_PKG,
-                                       pkgtype, pkgid, NULL)) {
+               pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+               if (pkgtype == NULL) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(is)",
+                                               PKGMGR_R_ENOPKG, ""));
+                       free(reqkey);
+                       return -1;
+               }
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_DISABLE_PKG,
+                                       pkgtype, pkgid, NULL, NULL)) {
                        g_dbus_method_invocation_return_value(invocation,
                                        g_variant_new("(is)",
                                                PKGMGR_R_ESYSTEM, ""));
+                       free(pkgtype);
                        free(reqkey);
                        return -1;
                }
+               free(pkgtype);
        }
 
        g_dbus_method_invocation_return_value(invocation,
@@ -621,7 +907,92 @@ static int __handle_request_disable_pkgs(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_app(uid_t uid,
+static int __handle_request_enable_apps(uid_t caller_uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *appid;
+       char *reqkey;
+       char buf[MAX_PKG_ARGS_LEN];
+       GVariantIter *iter;
+
+       g_variant_get(parameters, "(uas)", &target_uid, &iter);
+       if (target_uid == (uid_t)-1 || iter == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("enable_apps");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               return -1;
+       }
+
+       while (g_variant_iter_next(iter, "&s", &appid)) {
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_ENABLE_APP,
+                                       "default", appid, buf, NULL)) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(is)",
+                                               PKGMGR_R_ESYSTEM, ""));
+                       free(reqkey);
+                       return -1;
+               }
+       }
+
+       g_dbus_method_invocation_return_value(invocation,
+               g_variant_new("(is)", PKGMGR_R_OK, reqkey));
+
+       free(reqkey);
+       return 0;
+}
+
+static int __handle_request_disable_apps(uid_t caller_uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *appid;
+       char *reqkey;
+       char buf[MAX_PKG_ARGS_LEN];
+       GVariantIter *iter;
+
+       g_variant_get(parameters, "(uas)", &target_uid, &iter);
+       if (target_uid == (uid_t)-1 || iter == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("disable_apps");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+               return -1;
+       }
+
+       while (g_variant_iter_next(iter, "&s", &appid)) {
+               if (_push_queue(target_uid, caller_uid, reqkey,
+                                       REQUEST_TYPE_DISABLE_APP,
+                                       "default", appid, buf, NULL)) {
+                       g_dbus_method_invocation_return_value(invocation,
+                                       g_variant_new("(is)",
+                                               PKGMGR_R_ESYSTEM, ""));
+                       free(reqkey);
+                       return -1;
+               }
+       }
+
+       g_dbus_method_invocation_return_value(invocation,
+               g_variant_new("(is)", PKGMGR_R_OK, reqkey));
+
+       free(reqkey);
+       return 0;
+
+}
+
+static int __handle_request_enable_app(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -644,8 +1015,9 @@ static int __handle_request_enable_app(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_ENABLE_APP, "default",
-                               appid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_ENABLE_APP, "default",
+                               appid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -664,7 +1036,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_disable_app(uid_t uid,
+static int __handle_request_disable_app(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -687,8 +1059,9 @@ static int __handle_request_disable_app(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_DISABLE_APP, "default",
-                               appid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_DISABLE_APP, "default",
+                               appid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -707,7 +1080,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_enable_global_app_for_uid(uid_t uid,
+static int __handle_request_enable_global_app_for_uid(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -730,9 +1103,9 @@ static int __handle_request_enable_global_app_for_uid(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_ENABLE_GLOBAL_APP_FOR_UID,
-                               "default", appid, NULL)) {
+                               "default", appid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -751,7 +1124,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_disable_global_app_for_uid(uid_t uid,
+static int __handle_request_disable_global_app_for_uid(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -774,9 +1147,9 @@ static int __handle_request_disable_global_app_for_uid(uid_t uid,
                goto catch;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_DISABLE_GLOBAL_APP_FOR_UID,
-                               "default", appid, NULL)) {
+                               "default", appid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                ret = -1;
@@ -795,7 +1168,7 @@ catch:
        return ret;
 }
 
-static int __handle_request_getsize(uid_t uid,
+static int __handle_request_getsize(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -819,8 +1192,8 @@ static int __handle_request_getsize(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", get_type);
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_GETSIZE, "pkgtool",
-                               pkgid, buf)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_GETSIZE,
+                               "pkgtool", pkgid, buf, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
@@ -834,49 +1207,87 @@ static int __handle_request_getsize(uid_t uid,
        return 0;
 }
 
-static int __handle_request_cleardata(uid_t uid,
+static int __handle_request_getsize_sync(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
-       char *pkgtype = NULL;
        char *pkgid = NULL;
-       char *reqkey = NULL;
+       int get_type = -1;
+       char *reqkey;
+       char buf[4];
 
-       g_variant_get(parameters, "(u&s&s)", &target_uid, &pkgtype, &pkgid);
-       if (target_uid == (uid_t)-1 || pkgtype == NULL || pkgid == NULL) {
+       g_variant_get(parameters, "(u&si)", &target_uid, &pkgid, &get_type);
+       if (target_uid == (uid_t)-1 || pkgid == NULL || get_type == -1) {
                g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+                               g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
                return -1;
        }
 
        reqkey = __generate_reqkey(pkgid);
        if (reqkey == NULL) {
                g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+                               g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_CLEARDATA, pkgtype,
-                               pkgid, NULL)) {
+       snprintf(buf, sizeof(buf), "%d", get_type);
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_GETSIZE_SYNC,
+                               "pkgtool", pkgid, buf, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
-                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+                               g_variant_new("(is)", PKGMGR_R_ESYSTEM, ""));
                free(reqkey);
                return -1;
        }
 
+       if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+                               (gpointer)invocation))
+               ERR("reqkey already exists");
+
+       return 0;
+}
+
+static int __handle_request_cleardata(uid_t caller_uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *pkgid = NULL;
+       char *pkgtype;
+
+       g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+               return -1;
+       }
+
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARDATA,
+                               pkgtype, pkgid, NULL, NULL)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(pkgtype);
+               return -1;
+       }
+
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(i)", PKGMGR_R_OK));
-
-       free(reqkey);
+       free(pkgtype);
 
        return 0;
 }
 
-static int __handle_request_clearcache(uid_t uid,
+static int __handle_request_clearcache(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgid = NULL;
+       char *pkgtype;
 
        g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
        if (target_uid == (uid_t)-1 || pkgid == NULL) {
@@ -885,20 +1296,32 @@ static int __handle_request_clearcache(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, NULL, REQUEST_TYPE_CLEARCACHE,
-                               "pkgtool",  pkgid, NULL)) {
+       if (strcmp(PKG_CLEAR_ALL_CACHE, pkgid) == 0)
+               pkgtype = strdup("pkgtool");
+       else
+               pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARCACHE,
+                               pkgtype,  pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(pkgtype);
                return -1;
        }
 
        g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(i)", PKGMGR_R_OK));
+       free(pkgtype);
 
        return 0;
 }
 
-static int __handle_request_kill(uid_t uid,
+static int __handle_request_kill(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -919,8 +1342,8 @@ static int __handle_request_kill(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_KILL,
-                               "default", pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_KILL,
+                               "default", pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(ii)", PKGMGR_R_ESYSTEM, 0));
                free(reqkey);
@@ -934,7 +1357,7 @@ static int __handle_request_kill(uid_t uid,
        return 0;
 }
 
-static int __handle_request_check(uid_t uid,
+static int __handle_request_check(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -955,8 +1378,8 @@ static int __handle_request_check(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, REQUEST_TYPE_CHECK,
-                               "default", pkgid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_CHECK,
+                               "default", pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(ii)", PKGMGR_R_ESYSTEM, 0));
                free(reqkey);
@@ -970,7 +1393,7 @@ static int __handle_request_check(uid_t uid,
        return 0;
 }
 
-static int __handle_request_generate_license_request(uid_t uid,
+static int __handle_request_generate_license_request(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -991,9 +1414,9 @@ static int __handle_request_generate_license_request(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey,
+       if (_push_queue(caller_uid, caller_uid, reqkey,
                                REQUEST_TYPE_GENERATE_LICENSE_REQUEST,
-                               "default", NULL, resp_data)) {
+                               "default", NULL, resp_data, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(iss)", PKGMGR_R_ESYSTEM, "",
                                        ""));
@@ -1008,7 +1431,7 @@ static int __handle_request_generate_license_request(uid_t uid,
        return 0;
 }
 
-static int __handle_request_register_license(uid_t uid,
+static int __handle_request_register_license(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -1028,8 +1451,9 @@ static int __handle_request_register_license(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey, REQUEST_TYPE_REGISTER_LICENSE,
-                               "default", NULL, resp_data)) {
+       if (_push_queue(caller_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_REGISTER_LICENSE,
+                               "default", NULL, resp_data, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -1043,7 +1467,7 @@ static int __handle_request_register_license(uid_t uid,
        return 0;
 }
 
-static int __handle_request_decrypt_package(uid_t uid,
+static int __handle_request_decrypt_package(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        char *reqkey;
@@ -1065,9 +1489,10 @@ static int __handle_request_decrypt_package(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(uid, reqkey, REQUEST_TYPE_DECRYPT_PACKAGE,
+       if (_push_queue(caller_uid, caller_uid, reqkey,
+                               REQUEST_TYPE_DECRYPT_PACKAGE,
                                "default", drm_file_path,
-                               decrypted_file_path)) {
+                               decrypted_file_path, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -1081,7 +1506,7 @@ static int __handle_request_decrypt_package(uid_t uid,
        return 0;
 }
 
-static int __update_app_splash_screen(uid_t uid,
+static int __update_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters,
                int req_type)
 {
@@ -1105,8 +1530,8 @@ static int __update_app_splash_screen(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey, req_type, "default",
-                               appid, NULL)) {
+       if (_push_queue(target_uid, caller_uid, reqkey, req_type, "default",
+                               appid, NULL, NULL)) {
                ERR("Failed to push request");
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
@@ -1123,21 +1548,21 @@ static int __update_app_splash_screen(uid_t uid,
        return 0;
 }
 
-static int __handle_request_enable_app_splash_screen(uid_t uid,
+static int __handle_request_enable_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
-       return __update_app_splash_screen(uid, invocation, parameters,
+       return __update_app_splash_screen(caller_uid, invocation, parameters,
                        REQUEST_TYPE_ENABLE_APP_SPLASH_SCREEN);
 }
 
-static int __handle_request_disable_app_splash_screen(uid_t uid,
+static int __handle_request_disable_app_splash_screen(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
-       return __update_app_splash_screen(uid, invocation, parameters,
+       return __update_app_splash_screen(caller_uid, invocation, parameters,
                        REQUEST_TYPE_DISABLE_APP_SPLASH_SCREEN);
 }
 
-static int __handle_request_set_restriction_mode(uid_t uid,
+static int __handle_request_set_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1161,9 +1586,9 @@ static int __handle_request_set_restriction_mode(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", mode);
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_SET_RESTRICTION_MODE,
-                               "default", pkgid, buf)) {
+                               "default", pkgid, buf, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -1177,7 +1602,7 @@ static int __handle_request_set_restriction_mode(uid_t uid,
        return 0;
 }
 
-static int __handle_request_unset_restriction_mode(uid_t uid,
+static int __handle_request_unset_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1201,9 +1626,9 @@ static int __handle_request_unset_restriction_mode(uid_t uid,
        }
 
        snprintf(buf, sizeof(buf), "%d", mode);
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_UNSET_RESTRICTION_MODE,
-                               "default", pkgid, buf)) {
+                               "default", pkgid, buf, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -1217,7 +1642,7 @@ static int __handle_request_unset_restriction_mode(uid_t uid,
        return 0;
 }
 
-static int __handle_request_get_restriction_mode(uid_t uid,
+static int __handle_request_get_restriction_mode(uid_t caller_uid,
                GDBusMethodInvocation *invocation, GVariant *parameters)
 {
        uid_t target_uid = (uid_t)-1;
@@ -1238,9 +1663,9 @@ static int __handle_request_get_restriction_mode(uid_t uid,
                return -1;
        }
 
-       if (_push_queue(target_uid, reqkey,
+       if (_push_queue(target_uid, caller_uid, reqkey,
                                REQUEST_TYPE_GET_RESTRICTION_MODE,
-                               "default", pkgid, NULL)) {
+                               "default", pkgid, NULL, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(ii)", -1, PKGMGR_R_ESYSTEM));
                free(reqkey);
@@ -1254,6 +1679,93 @@ static int __handle_request_get_restriction_mode(uid_t uid,
        return 0;
 }
 
+static int __handle_request_set_app_label(uid_t uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *appid = NULL;
+       char *label = NULL;
+       char *reqkey;
+
+       g_variant_get(parameters, "(uss)", &target_uid, &appid, &label);
+       if (target_uid == (uid_t)-1 || appid == NULL || label == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey("appid");
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               return -1;
+       }
+
+       if (_push_queue(target_uid, uid, reqkey,
+                               REQUEST_TYPE_SET_APP_LABEL,
+                               "default", appid, label, NULL)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(reqkey);
+               return -1;
+       }
+
+       if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+                               (gpointer)invocation))
+               ERR("reqkey already exists");
+
+       return 0;
+}
+
+static int __handle_request_migrate_external_image(uid_t uid,
+               GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+       uid_t target_uid = (uid_t)-1;
+       char *pkgid = NULL;
+       char *pkgtype;
+       char *reqkey;
+
+       g_variant_get(parameters, "(us)", &target_uid, &pkgid);
+       if (target_uid == (uid_t)-1 || pkgid == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ECOMM));
+               return -1;
+       }
+
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOPKG));
+               return -1;
+       }
+
+       reqkey = __generate_reqkey(pkgid);
+       if (reqkey == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ENOMEM));
+               free(pkgtype);
+               return -1;
+       }
+
+       if (_push_queue(target_uid, uid, reqkey,
+                               REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE,
+                               pkgtype, pkgid, NULL, NULL)) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+               free(reqkey);
+               free(pkgtype);
+               return -1;
+       }
+
+       g_dbus_method_invocation_return_value(invocation,
+                       g_variant_new("(i)", PKGMGR_R_OK));
+
+       free(reqkey);
+       free(pkgtype);
+
+       return 0;
+}
+
 static uid_t __get_caller_uid(GDBusConnection *connection, const char *name)
 {
        GError *err = NULL;
@@ -1272,6 +1784,7 @@ static uid_t __get_caller_uid(GDBusConnection *connection, const char *name)
        }
 
        g_variant_get(result, "(u)", &uid);
+       g_variant_unref(result);
 
        return uid;
 }
@@ -1310,14 +1823,26 @@ static void __handle_method_call(GDBusConnection *connection,
                ret = __handle_request_enable_pkgs(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "disable_pkgs") == 0)
                ret = __handle_request_disable_pkgs(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "register_pkg_update_info") == 0)
+               ret = __handle_request_register_pkg_update_info(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "unregister_pkg_update_info") == 0)
+               ret = __handle_request_unregister_pkg_update_info(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "unregister_all_pkg_update_info") == 0)
+               ret = __handle_request_unregister_all_pkg_update_info(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "getsize") == 0)
                ret = __handle_request_getsize(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "getsize_sync") == 0)
+               ret = __handle_request_getsize_sync(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "clearcache") == 0)
                ret = __handle_request_clearcache(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "enable_app") == 0)
                ret = __handle_request_enable_app(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "disable_app") == 0)
                ret = __handle_request_disable_app(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "enable_apps") == 0)
+               ret = __handle_request_enable_apps(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "disable_apps") == 0)
+               ret = __handle_request_disable_apps(uid, invocation, parameters);
        else if (g_strcmp0(method_name, "enable_global_app_for_uid") == 0)
                ret = __handle_request_enable_global_app_for_uid(uid,
                                invocation, parameters);
@@ -1352,6 +1877,11 @@ static void __handle_method_call(GDBusConnection *connection,
        else if (g_strcmp0(method_name, "get_restriction_mode") == 0)
                ret = __handle_request_get_restriction_mode(uid, invocation,
                                parameters);
+       else if (g_strcmp0(method_name, "set_app_label") == 0)
+               ret = __handle_request_set_app_label(uid, invocation, parameters);
+       else if (g_strcmp0(method_name, "migrate_external_image") == 0)
+               ret = __handle_request_migrate_external_image(uid, invocation,
+                               parameters);
        else
                ret = -1;