Set default support-mode to 0
[platform/core/appfw/pkgmgr-info.git] / parser / src / pkgmgr_parser_db.c
index a525066..bf7e35d 100644 (file)
@@ -27,6 +27,7 @@
 #include <pwd.h>
 
 #include <glib.h>
+#include <gio/gio.h>
 #include <sqlite3.h>
 
 #include <tzplatform_config.h>
@@ -113,7 +114,7 @@ static const char *__get_bool(char *value, bool is_true)
 
 #define __BEGIN_TRANSACTION(db)                                                \
 do {                                                                           \
-       if (sqlite3_exec(db, "BEGIN EXCLUSIVE", NULL, NULL, NULL) !=           \
+       if (sqlite3_exec(db, "BEGIN DEFERRED", NULL, NULL, NULL) !=           \
                        SQLITE_OK) {                                           \
                _LOGE("begin transaction failed: %s", sqlite3_errmsg(db));     \
                sqlite3_close_v2(db);                                          \
@@ -328,6 +329,9 @@ static const char *parser_init_queries[] = {
        QUERY_CREATE_TABLE_PACKAGE_APP_INFO_FOR_UID,
        QUERY_CREATE_TRIGGER_UPDATE_PACKAGE_APP_INFO_FOR_UID,
        QUERY_CREATE_TABLE_PACKAGE_APP_SPLASH_SCREEN,
+       QUERY_CREATE_TABLE_PACKAGE_DEPENDENCY_INFO,
+       QUERY_CREATE_TABLE_PACKAGE_PLUGIN_INFO,
+       QUERY_CREATE_TABLE_PACKAGE_APP_COMPONENT_INFO,
        NULL,
 };
 
@@ -341,11 +345,23 @@ static const char *cert_init_queries[] = {
        NULL
 };
 
-static int __initialize_db(sqlite3 *db, const char *dbpath, uid_t uid)
+static int __create_tables(sqlite3 *db, const char **queries)
 {
        int ret;
-       const char **queries;
        int i;
+       for (i = 0; queries[i] != NULL; i++) {
+               ret = sqlite3_exec(db, queries[i], NULL, NULL, NULL);
+               if (ret != SQLITE_OK) {
+                       _LOGE("exec failed: %s", sqlite3_errmsg(db));
+                       return -1;
+               }
+       }
+       return 0;
+}
+
+static int __initialize_db(sqlite3 *db, const char *dbpath, uid_t uid)
+{
+       const char **queries;
 
        if (__set_db_version(db))
                return -1;
@@ -359,13 +375,9 @@ static int __initialize_db(sqlite3 *db, const char *dbpath, uid_t uid)
                return -1;
        }
 
-       for (i = 0; queries[i] != NULL; i++) {
-               ret = sqlite3_exec(db, queries[i], NULL, NULL, NULL);
-               if (ret != SQLITE_OK) {
-                       _LOGE("exec failed: %s", sqlite3_errmsg(db));
-                       return -1;
-               }
-       }
+       __BEGIN_TRANSACTION(db);
+       __DO_TRANSACTION(db, __create_tables(db, queries));
+       __END_TRANSACTION(db);
 
        if (__set_db_permission(dbpath, uid))
                _LOGE("failed to set db permission");
@@ -373,6 +385,122 @@ static int __initialize_db(sqlite3 *db, const char *dbpath, uid_t uid)
        return 0;
 }
 
+#define RESOURCED_BUS_NAME "org.tizen.resourced"
+#define RESOURCED_PROC_PATH "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_PROC_INTERFACE "org.tizen.resourced.process"
+#define RESOURCED_PROC_METHOD "ProcExclude"
+static void __send_wakeup_signal_to_resourced(pid_t pid)
+{
+       GError *error = NULL;
+       GDBusConnection *conn;
+       GDBusProxy *proxy;
+       GVariant *reply;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+       if (conn == NULL) {
+               _LOGE("Failed to connect to dbus: %s", error->message);
+               g_error_free(error);
+               return;
+       }
+
+       proxy = g_dbus_proxy_new_sync(conn,
+                       G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+                       NULL, RESOURCED_BUS_NAME,
+                       RESOURCED_PROC_PATH, RESOURCED_PROC_INTERFACE,
+                       NULL, &error);
+       if (proxy == NULL) {
+               _LOGE("failed to get proxy object: %s", error->message);
+               g_error_free(error);
+               g_object_unref(conn);
+               return;
+       }
+
+       reply = g_dbus_proxy_call_sync(proxy, RESOURCED_PROC_METHOD,
+                       g_variant_new("(si)", "wakeup", pid),
+                       G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+       if (reply == NULL)
+               _LOGE("failed to get reply from resourced");
+       if (error) {
+               _LOGE("failed to send request: %s", error->message);
+               g_error_free(error);
+       }
+
+       g_object_unref(proxy);
+       g_object_unref(conn);
+}
+
+static void __check_db_lock(const char *dbpath)
+{
+       FILE *fp;
+       FILE *fp_cmdline;
+       struct stat sb;
+       int pid;
+       unsigned int maj;
+       unsigned int min;
+       ino_t ino;
+       char cmdline[BUFSIZE];
+       char name[BUFSIZE];
+       size_t len;
+
+       if (stat(dbpath, &sb) == -1) {
+               _LOGE("get db file(%s) status failed: %d", dbpath, errno);
+               return;
+       }
+
+       fp = fopen("/proc/locks", "r");
+       if (fp == NULL) {
+               _LOGE("Failed to open lock info: %d", errno);
+               return;
+       }
+
+       while (fscanf(fp, "%*s %*s %*s %*s %d %x:%x:%lu %*s %*s",
+                               &pid, &maj, &min, &ino) != EOF) {
+               if (maj != major(sb.st_dev) || min != minor(sb.st_dev) ||
+                               ino != sb.st_ino || pid == getpid())
+                       continue;
+
+               snprintf(cmdline, sizeof(cmdline), "/proc/%d/cmdline", pid);
+               fp_cmdline = fopen(cmdline, "r");
+               name[0] = '\0';
+               if (fp_cmdline != NULL) {
+                       len = fread(name, sizeof(char), sizeof(name) - 1,
+                                       fp_cmdline);
+                       if (len > 0) {
+                               if (name[len - 1] == '\n')
+                                       name[len - 1] = '\0';
+                               else
+                                       name[len] = '\0';
+                       }
+                       fclose(fp_cmdline);
+               }
+
+               _LOGE("%s (%d) has lock on pkgmgr db(%s)!", name, pid, dbpath);
+               __send_wakeup_signal_to_resourced(pid);
+       }
+
+       fclose(fp);
+}
+
+#define BUSY_WAITING_USEC (1000000 / 10 / 2) /* 0.05 sec */
+#define BUSY_WAITING_MAX 40 /* wait for max 2 sec */
+static int __db_busy_handler(void *data, int count)
+{
+       if (count < (BUSY_WAITING_MAX / 2)) {
+               usleep(BUSY_WAITING_USEC);
+               return 1;
+       } else if (count == (BUSY_WAITING_MAX / 2)) {
+               __check_db_lock((const char *)data);
+               usleep(BUSY_WAITING_USEC);
+               return 1;
+       } else if (count < BUSY_WAITING_MAX) {
+               usleep(BUSY_WAITING_USEC);
+               return 1;
+       } else {
+               /* sqlite3_prepare_v2 will return SQLITE_BUSY */
+               return 0;
+       }
+}
+
 API int pkgmgr_parser_initialize_parser_db(uid_t uid)
 {
        int ret;
@@ -392,6 +520,14 @@ API int pkgmgr_parser_initialize_parser_db(uid_t uid)
                return PM_PARSER_R_ERROR;
        }
 
+       ret = sqlite3_busy_handler(db, __db_busy_handler, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("failed to register busy handler: %s",
+                               sqlite3_errmsg(db));
+               sqlite3_close_v2(db);
+               return ret;
+       }
+
        if (__initialize_db(db, dbpath, uid)) {
                sqlite3_close_v2(db);
                return PM_PARSER_R_ERROR;
@@ -420,6 +556,14 @@ API int pkgmgr_parser_initialize_cert_db(void)
                return PM_PARSER_R_ERROR;
        }
 
+       ret = sqlite3_busy_handler(db, __db_busy_handler, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("failed to register busy handler: %s",
+                               sqlite3_errmsg(db));
+               sqlite3_close_v2(db);
+               return ret;
+       }
+
        if (__initialize_db(db, dbpath, GLOBAL_USER)) {
                sqlite3_close_v2(db);
                return PM_PARSER_R_ERROR;
@@ -453,25 +597,13 @@ API int pkgmgr_parser_create_and_initialize_db(uid_t uid)
        if (pkgmgr_parser_initialize_parser_db(uid))
                return PM_PARSER_R_ERROR;
 
-       if (pkgmgr_parser_initialize_cert_db())
-               return PM_PARSER_R_ERROR;
+       if (uid == OWNER_ROOT || uid == GLOBAL_USER)
+               if (pkgmgr_parser_initialize_cert_db())
+                       return PM_PARSER_R_ERROR;
 
        return PM_PARSER_R_OK;
 }
 
-#define BUSY_WAITING_USEC (1000000 / 10 / 2) /* 0.05 sec */
-#define BUSY_WAITING_MAX 20 /* wait for max 1 sec */
-static int __db_busy_handler(void *data, int count)
-{
-       if (count < BUSY_WAITING_MAX) {
-               usleep(BUSY_WAITING_USEC);
-               return 1;
-       } else {
-               /* sqlite3_prepare_v2 will return SQLITE_BUSY */
-               return 0;
-       }
-}
-
 static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags)
 {
        int ret;
@@ -486,7 +618,7 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags)
        if (ret != SQLITE_OK)
                return ret;
 
-       ret = sqlite3_busy_handler(*db, __db_busy_handler, NULL);
+       ret = sqlite3_busy_handler(*db, __db_busy_handler, (void *)path);
        if (ret != SQLITE_OK) {
                _LOGE("failed to register busy handler: %s",
                                sqlite3_errmsg(*db));
@@ -497,7 +629,7 @@ static int __open_db(uid_t uid, const char *path, sqlite3 **db, int flags)
        if (flags & SQLITE_OPEN_CREATE) {
                ret = __initialize_db(*db, path, uid);
                if (ret) {
-                       _LOGE("failed to initialize db: %s\n");
+                       _LOGE("failed to initialize db: %s", path);
                        sqlite3_close_v2(*db);
                        return -1;
                }
@@ -626,8 +758,9 @@ static int __insert_appcontrol_privilege_info(sqlite3 *db, const char *appid,
 static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
 {
        static const char query[] =
-               "INSERT INTO package_app_app_control (app_id, app_control) "
-               "VALUES (?, ?)";
+               "INSERT INTO package_app_app_control (app_id, app_control,"
+               "  visibility, app_control_id) "
+               "VALUES (?, ?, ?, ?)";
        int ret;
        sqlite3_stmt *stmt;
        int idx;
@@ -658,6 +791,8 @@ static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
                                        ac->mime : "NULL") : "NULL");
                __BIND_TEXT(db, stmt, idx++, app->appid);
                __BIND_TEXT(db, stmt, idx++, app_control);
+               __BIND_TEXT(db, stmt, idx++, ac->visibility);
+               __BIND_TEXT(db, stmt, idx++, ac->id);
 
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
@@ -1005,6 +1140,9 @@ static GList *__find_splashscreens(GList *splashscreens)
        GList *list = NULL;
        splashscreen_x *ss;
 
+       if (splashscreens == NULL)
+               return NULL;
+
        g_list_foreach(splashscreens,
                        __find_appcontrol_splashscreen_with_dpi, &list);
        g_list_foreach(splashscreens,
@@ -1020,7 +1158,8 @@ static GList *__find_splashscreens(GList *splashscreens)
        return list;
 }
 
-static int __insert_splashscreen_info(sqlite3 *db, application_x *app)
+static int __insert_splashscreen_info(sqlite3 *db, application_x *app,
+               GList *ss_list)
 {
        static const char query[] =
                "INSERT INTO package_app_splash_screen (app_id, src, type,"
@@ -1031,12 +1170,10 @@ static int __insert_splashscreen_info(sqlite3 *db, application_x *app)
        int idx;
        GList *tmp;
        splashscreen_x *ss;
-       GList *ss_list;
 
        if (app->splashscreens == NULL)
                return 0;
 
-       ss_list = __find_splashscreens(app->splashscreens);
        if (ss_list == NULL)
                return 0;
 
@@ -1074,6 +1211,51 @@ static int __insert_splashscreen_info(sqlite3 *db, application_x *app)
        return 0;
 }
 
+static int __insert_component_info(sqlite3 *db, application_x *app)
+{
+       static const char query[] =
+               "INSERT INTO package_app_component_info (app_id, component_id, "
+               "type, launch_mode) VALUES(?, ?, ?, ?)";
+       int ret;
+       sqlite3_stmt *stmt;
+       int idx;
+       GList *tmp;
+       component_x *c;
+
+       if (app->components == NULL)
+               return 0;
+
+       ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("prepare failed: %s", sqlite3_errmsg(db));
+               return -1;
+       }
+
+       for (tmp = app->components; tmp; tmp = tmp->next) {
+               c = (component_x *)tmp->data;
+               if (c == NULL)
+                       continue;
+
+               idx = 1;
+               __BIND_TEXT(db, stmt, idx++, app->appid);
+               __BIND_TEXT(db, stmt, idx++, c->id);
+               __BIND_TEXT(db, stmt, idx++, c->type);
+               __BIND_TEXT(db, stmt, idx++, c->launch_mode);
+
+               ret = sqlite3_step(stmt);
+               if (ret != SQLITE_DONE) {
+                       _LOGE("step failed: %s", sqlite3_errmsg(db));
+                       sqlite3_finalize(stmt);
+                       return -1;
+               }
+               sqlite3_reset(stmt);
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
 static void __trimfunc(GList *trim_list)
 {
        char *trim_data;
@@ -1578,6 +1760,81 @@ static int __insert_package_privilege_info(sqlite3 *db, manifest_x *mfx)
        return 0;
 }
 
+static int __insert_package_plugin_execution_info(sqlite3 *db,
+               manifest_x *mfx)
+{
+       static const char query[] =
+               "INSERT INTO package_plugin_info "
+               "(pkgid, appid, plugin_type, plugin_name) "
+               "VALUES (?, ?, ?, ?)";
+       int ret;
+       sqlite3_stmt *stmt;
+       int idx;
+       GList *tmp;
+       plugin_x *plugin;
+
+       if (!mfx->plugin)
+               return 0;
+
+       ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("prepare failed: %s", sqlite3_errmsg(db));
+               return -1;
+       }
+
+       for (tmp = mfx->plugin; tmp; tmp = tmp->next) {
+               plugin = (plugin_x *)tmp->data;
+               if (plugin == NULL)
+                       continue;
+
+               idx = 1;
+               __BIND_TEXT(db, stmt, idx++, plugin->pkgid);
+               __BIND_TEXT(db, stmt, idx++, plugin->appid);
+               __BIND_TEXT(db, stmt, idx++, plugin->plugin_type);
+               __BIND_TEXT(db, stmt, idx++, plugin->plugin_name);
+
+               ret = sqlite3_step(stmt);
+               if (ret != SQLITE_DONE) {
+                       _LOGE("step failed: %s", sqlite3_errmsg(db));
+                       sqlite3_finalize(stmt);
+                       return -1;
+               }
+               sqlite3_reset(stmt);
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+static int __delete_package_plugin_execution_info(sqlite3 *db,
+               const char *pkgid)
+{
+       static const char query[] =
+               "DELETE FROM package_plugin_info WHERE pkgid=?";
+       int ret;
+       sqlite3_stmt *stmt;
+
+       ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("prepare failed: %s", sqlite3_errmsg(db));
+               return -1;
+       }
+
+       __BIND_TEXT(db, stmt, 1, pkgid);
+
+       ret = sqlite3_step(stmt);
+       if (ret != SQLITE_DONE) {
+               _LOGE("step failed: %s", sqlite3_errmsg(db));
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
 static int __insert_package_appdefined_privilege_info(sqlite3 *db,
                manifest_x *mfx)
 {
@@ -1622,6 +1879,49 @@ static int __insert_package_appdefined_privilege_info(sqlite3 *db,
        return 0;
 }
 
+static int __insert_package_dependency_info(sqlite3 *db, manifest_x *mfx)
+{
+       static const char query[] =
+               "INSERT INTO package_dependency_info"
+               "  (package, depends_on, type, required_version) "
+               "VALUES (?, ?, ?, ?)";
+       int ret;
+       sqlite3_stmt *stmt;
+       int idx;
+       GList *tmp;
+       dependency_x *dep;
+
+       ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("prepare failed: %s", sqlite3_errmsg(db));
+               return -1;
+       }
+
+       for (tmp = mfx->dependencies; tmp; tmp = tmp->next) {
+               dep = (dependency_x *)tmp->data;
+               if (dep == NULL)
+                       continue;
+
+               idx = 1;
+               __BIND_TEXT(db, stmt, idx++, mfx->package);
+               __BIND_TEXT(db, stmt, idx++, dep->depends_on);
+               __BIND_TEXT(db, stmt, idx++, dep->type);
+               __BIND_TEXT(db, stmt, idx++, dep->required_version);
+
+               ret = sqlite3_step(stmt);
+               if (ret != SQLITE_DONE) {
+                       _LOGE("step failed: %s", sqlite3_errmsg(db));
+                       sqlite3_finalize(stmt);
+                       return -1;
+               }
+               sqlite3_reset(stmt);
+       }
+
+       sqlite3_finalize(stmt);
+
+       return 0;
+}
+
 /* _PRODUCT_LAUNCHING_ENHANCED_
  *  app->indicatordisplay, app->portraitimg, app->landscapeimg,
  *  app->guestmode_appstatus
@@ -1668,6 +1968,7 @@ static int __insert_application_info(sqlite3 *db, manifest_x *mfx)
        application_x *app;
        int bg_category;
        const char *effective_appid;
+       GList *ss_list;
 
        ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
        if (ret != SQLITE_OK) {
@@ -1716,7 +2017,8 @@ static int __insert_application_info(sqlite3 *db, manifest_x *mfx)
                                __get_bool(app->process_pool, false));
                __BIND_TEXT(db, stmt, idx++, app->launch_mode);
                __BIND_TEXT(db, stmt, idx++, __get_bool(app->ui_gadget, false));
-               __BIND_TEXT(db, stmt, idx++, app->support_mode);
+               __BIND_TEXT(db, stmt, idx++,
+                               app->support_mode ? app->support_mode : "0");
                __BIND_TEXT(db, stmt, idx++,
                                __get_bool(mfx->support_disable, false));
                __BIND_TEXT(db, stmt, idx++, app->component_type);
@@ -1763,14 +2065,24 @@ static int __insert_application_info(sqlite3 *db, manifest_x *mfx)
                        sqlite3_finalize(stmt);
                        return -1;
                }
-               if (__insert_splashscreen_info(db, app)) {
+               ss_list = __find_splashscreens(app->splashscreens);
+               if (__insert_splashscreen_info(db, app, ss_list)) {
+                       g_list_free(ss_list);
                        sqlite3_finalize(stmt);
                        return -1;
                }
+               g_list_free(ss_list);
                if (__insert_app_localized_info(db, app)) {
                        sqlite3_finalize(stmt);
                        return -1;
                }
+
+               if (!strcmp(app->component_type, "componentbasedapp")) {
+                       if (__insert_component_info(db, app)) {
+                               sqlite3_finalize(stmt);
+                               return -1;
+                       }
+               }
        }
 
        sqlite3_finalize(stmt);
@@ -1939,7 +2251,8 @@ static int __insert_package_info(sqlite3 *db, manifest_x *mfx)
        __BIND_TEXT(db, stmt, idx++, mfx->root_path);
        __BIND_TEXT(db, stmt, idx++, mfx->external_path);
        __BIND_TEXT(db, stmt, idx++, mfx->csc_path);
-       __BIND_TEXT(db, stmt, idx++, mfx->support_mode);
+       __BIND_TEXT(db, stmt, idx++,
+                       mfx->support_mode ? mfx->support_mode : "0");
        __BIND_TEXT(db, stmt, idx++, __get_bool(mfx->support_disable, false));
 
        ret = sqlite3_step(stmt);
@@ -1961,6 +2274,8 @@ static int __insert_package_info(sqlite3 *db, manifest_x *mfx)
                return -1;
        if (__insert_package_appdefined_privilege_info(db, mfx))
                return -1;
+       if (__insert_package_dependency_info(db, mfx))
+               return -1;
 
        return 0;
 }
@@ -2883,3 +3198,92 @@ API int pkgmgr_parser_unregister_all_pkg_update_info_in_db(void)
        return pkgmgr_parser_unregister_all_pkg_update_info_in_usr_db(
                        __getuid());
 }
+
+API int pkgmgr_parser_register_pkg_plugin_info_in_usr_db(
+               manifest_x *mfx, uid_t uid)
+{
+       int ret;
+       const char *dbpath;
+       sqlite3 *db;
+
+       if (!mfx)
+               return PM_PARSER_R_EINVAL;
+       dbpath = __get_parser_db_path(uid);
+       ret = __open_db(uid, dbpath, &db, SQLITE_OPEN_READWRITE);
+       if (ret != SQLITE_OK) {
+               _LOGE("open db failed: %d", ret);
+               return PM_PARSER_R_ERROR;
+       }
+
+       __BEGIN_TRANSACTION(db);
+       __DO_TRANSACTION(db, __insert_package_plugin_execution_info(db, mfx));
+       __END_TRANSACTION(db);
+
+       sqlite3_close_v2(db);
+
+       return PM_PARSER_R_OK;
+}
+
+API int pkgmgr_parser_register_pkg_plugin_info_in_db(manifest_x *mfx)
+{
+       return pkgmgr_parser_register_pkg_plugin_info_in_usr_db(mfx, __getuid());
+}
+
+API int pkgmgr_parser_update_pkg_plugin_info_in_usr_db(
+               manifest_x *mfx, uid_t uid)
+{
+       int ret;
+       const char *dbpath;
+       sqlite3 *db;
+
+       if (!mfx)
+               return PM_PARSER_R_EINVAL;
+       dbpath = __get_parser_db_path(uid);
+       ret = __open_db(uid, dbpath, &db, SQLITE_OPEN_READWRITE);
+       if (ret != SQLITE_OK) {
+               _LOGE("open db failed: %d", ret);
+               return PM_PARSER_R_ERROR;
+       }
+
+       __BEGIN_TRANSACTION(db);
+       __DO_TRANSACTION(db, __delete_package_plugin_execution_info(db, mfx->package));
+       __DO_TRANSACTION(db, __insert_package_plugin_execution_info(db, mfx));
+       __END_TRANSACTION(db);
+
+       sqlite3_close_v2(db);
+
+       return PM_PARSER_R_OK;
+}
+
+API int pkgmgr_parser_update_pkg_plugin_info_in_db(manifest_x *mfx)
+{
+       return pkgmgr_parser_update_pkg_plugin_info_in_usr_db(mfx, __getuid());
+}
+
+API int pkgmgr_parser_unregister_pkg_plugin_info_in_usr_db(
+               const char *pkgid, uid_t uid)
+{
+       int ret;
+       const char *dbpath;
+       sqlite3 *db;
+
+       dbpath = __get_parser_db_path(uid);
+       ret = __open_db(uid, dbpath, &db, SQLITE_OPEN_READWRITE);
+       if (ret != SQLITE_OK) {
+               _LOGE("open db failed: %d", ret);
+               return PM_PARSER_R_ERROR;
+       }
+
+       __BEGIN_TRANSACTION(db);
+       __DO_TRANSACTION(db, __delete_package_plugin_execution_info(db, pkgid));
+       __END_TRANSACTION(db);
+
+       sqlite3_close_v2(db);
+
+       return PM_PARSER_R_OK;
+}
+
+API int pkgmgr_parser_unregister_pkg_plugin_info_in_db(const char *pkgid)
+{
+       return pkgmgr_parser_unregister_pkg_plugin_info_in_usr_db(pkgid, __getuid());
+}