- int ret = -1;
- sqlite3 *pkgmgr_parser_db = NULL;
- char *query = NULL;
- char *db_path;
- const char *location_str;
-
- db_path = getUserPkgParserDBPathUID(uid);
- if (db_path == NULL) {
- _LOGE("Failed to get pkg parser db path - %d", uid);
- return PMINFO_R_ERROR;
- }
-
- //ret = __open_db(db_path, &pkgmgr_parser_db, SQLITE_OPEN_READWRITE);
- ret = 0;
- if (ret != SQLITE_OK) {
- _LOGE("connect db failed!");
- free(db_path);
- return PMINFO_R_ERROR;
- }
- free(db_path);
-
- /*Begin transaction*/
- /* Setting Manifest DB */
- ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN DEFERRED", NULL, NULL, NULL);
- tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Failed to begin transaction\n");
- _LOGD("Transaction Begin\n");
-
- if (location == INSTALL_INTERNAL)
- location_str = "installed_internal";
- else if (location == INSTALL_EXTERNAL)
- location_str = "installed_external";
- else
- location_str = "installed_extended";
- /* pkgcakge_info table */
- query = sqlite3_mprintf(
- "update package_info set installed_storage=%Q, external_path=%Q where package=%Q",
- location_str, external_pkg_path, pkgid);
-
- ret = sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, NULL);
- tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s\n", query);
- sqlite3_free(query);
-
- /* package_app_info table */
- query = sqlite3_mprintf(
- "update package_app_info set app_installed_storage=%Q, app_external_path=%Q where package=%Q",
- location_str, external_pkg_path, pkgid);
-
- ret = sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, NULL);
- tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s\n", query);
-
- /*Commit transaction*/
- ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("Failed to commit transaction. Rollback now\n");
- ret = sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
- tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s\n", query);
- }
- _LOGD("Transaction Commit and End\n");
-
- ret = PMINFO_R_OK;
-catch:
- sqlite3_close_v2(pkgmgr_parser_db);
- sqlite3_free(query);
- return ret;