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,
};
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;
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)
{
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);
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());
+}