4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
27 #include <sys/types.h>
28 #include <sys/smack.h>
37 #include <system_info.h>
39 /* For multi-user support */
40 #include <tzplatform_config.h>
42 #include "pkgmgr-info.h"
43 #include "pkgmgrinfo_basic.h"
44 #include "pkgmgrinfo_debug.h"
45 #include "pkgmgr_parser_internal.h"
46 #include "pkgmgr_parser_db.h"
51 #define LOG_TAG "PKGMGR_PARSER"
53 #define PKGMGR_PARSER_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
54 #define PKGMGR_CERT_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
55 #define MAX_QUERY_LEN 4096
63 #define XXHDPI "xxhdpi"
73 #define XXHDPI_MIN 481
74 #define XXHDPI_MAX 600
76 #define DB_LABEL "User::Home"
77 #define SET_SMACK_LABEL(x) \
79 if (smack_setlabel((x), DB_LABEL, SMACK_LABEL_ACCESS)) \
80 _LOGE("failed chsmack -a %s %s", DB_LABEL, x); \
82 _LOGD("chsmack -a %s %s", DB_LABEL, x); \
85 sqlite3 *pkgmgr_parser_db;
86 sqlite3 *pkgmgr_cert_db;
89 #define QUERY_CREATE_TABLE_PACKAGE_INFO "CREATE TABLE IF NOT EXISTS package_info " \
90 "(package TEXT PRIMARY KEY NOT NULL, " \
91 "package_type TEXT DEFAULT 'tpk', " \
92 "package_version TEXT, " \
93 "package_api_version TEXT, " \
94 "package_tep_name TEXT, " \
95 "package_zip_mount_file TEXT, " \
96 "install_location TEXT NOT NULL , " \
97 "package_size TEXT, " \
98 "package_removable TEXT NOT NULL DEFAULT 'true', " \
99 "package_preload TEXT NOT NULL DEFAULT 'false', " \
100 "package_readonly TEXT NOT NULL DEFAULT 'false', " \
101 "package_update TEXT NOT NULL DEFAULT 'false', " \
102 "package_appsetting TEXT NOT NULL DEFAULT 'false', " \
103 "package_nodisplay TEXT NOT NULL DEFAULT 'false', " \
104 "package_system TEXT NOT NULL DEFAULT 'false', " \
105 "author_name TEXT, " \
106 "author_email TEXT, " \
107 "author_href TEXT," \
108 "installed_time TEXT, " \
109 "installed_storage TEXT, " \
110 "storeclient_id TEXT, " \
111 "mainapp_id TEXT, " \
112 "package_url TEXT, " \
115 "package_support_disable TEXT NOT NULL DEFAULT 'false', " \
116 "package_disable TEXT NOT NULL DEFAULT 'false')"
118 #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "CREATE TABLE IF NOT EXISTS package_localized_info " \
119 "(package TEXT NOT NULL, " \
120 "package_locale TEXT NOT NULL DEFAULT 'No Locale', " \
121 "package_label TEXT, " \
122 "package_icon TEXT, " \
123 "package_description TEXT, " \
124 "package_license TEXT, " \
125 "package_author TEXT, " \
126 "PRIMARY KEY(package, package_locale), " \
127 "FOREIGN KEY(package) " \
128 "REFERENCES package_info(package) " \
131 #define QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO "CREATE TABLE IF NOT EXISTS package_privilege_info " \
132 "(package TEXT NOT NULL, " \
133 "privilege TEXT NOT NULL, " \
134 "PRIMARY KEY(package, privilege) " \
135 "FOREIGN KEY(package) " \
136 "REFERENCES package_info(package) " \
139 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO "CREATE TABLE IF NOT EXISTS package_app_info " \
140 "(app_id TEXT PRIMARY KEY NOT NULL, " \
141 "app_component TEXT NOT NULL, " \
143 "app_nodisplay TEXT NOT NULL DEFAULT 'false', " \
145 "app_onboot TEXT NOT NULL DEFAULT 'false', " \
146 "app_multiple TEXT NOT NULL DEFAULT 'false', " \
147 "app_autorestart TEXT NOT NULL DEFAULT 'false', " \
148 "app_taskmanage TEXT NOT NULL DEFAULT 'false', " \
149 "app_enabled TEXT NOT NULL DEFAULT 'true', " \
150 "app_hwacceleration TEXT NOT NULL DEFAULT 'use-system-setting', " \
151 "app_screenreader TEXT NOT NULL DEFAULT 'use-system-setting', " \
152 "app_mainapp TEXT NOT NULL, " \
153 "app_recentimage TEXT NOT NULL DEFAULT 'false', " \
154 "app_launchcondition TEXT, " \
155 "app_indicatordisplay TEXT NOT NULL DEFAULT 'true', " \
156 "app_portraitimg TEXT, " \
157 "app_landscapeimg TEXT, " \
158 "app_guestmodevisibility TEXT NOT NULL DEFAULT 'true', " \
159 "app_permissiontype TEXT NOT NULL DEFAULT 'normal', " \
160 "app_preload TEXT NOT NULL DEFAULT 'false', " \
161 "app_submode TEXT NOT NULL DEFAULT 'false', " \
162 "app_submode_mainid TEXT, " \
163 "app_installed_storage TEXT NOT NULL, " \
164 "app_process_pool TEXT NOT NULL DEFAULT 'false', " \
165 "app_launch_mode TEXT NOT NULL DEFAULT 'caller', " \
166 "app_ui_gadget TEXT NOT NULL DEFAULT 'false', " \
167 "app_support_disable TEXT NOT NULL DEFAULT 'false', " \
168 "app_disable TEXT NOT NULL DEFAULT 'false', " \
169 "app_package_type TEXT DEFAULT 'tpk', " \
170 "component_type TEXT, " \
171 "package TEXT NOT NULL, " \
172 "app_tep_name TEXT, " \
173 "app_zip_mount_file TEXT, " \
174 "app_background_category INTEGER DEFAULT 0, " \
175 "app_root_path TEXT, " \
176 "app_api_version TEXT, " \
177 "app_effective_appid TEXT, " \
178 "app_splash_screen_display TEXT NOT NULL DEFAULT 'true', " \
179 "FOREIGN KEY(package) " \
180 "REFERENCES package_info(package) " \
183 #define QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO "CREATE TABLE IF NOT EXISTS package_app_localized_info " \
184 "(app_id TEXT NOT NULL, " \
185 "app_locale TEXT NOT NULL DEFAULT 'No Locale', " \
188 "PRIMARY KEY(app_id,app_locale) " \
189 "FOREIGN KEY(app_id) " \
190 "REFERENCES package_app_info(app_id) " \
193 #define QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO "CREATE TABLE IF NOT EXISTS package_app_icon_section_info " \
194 "(app_id TEXT NOT NULL, " \
196 "app_icon_section TEXT NOT NULL, " \
197 "app_icon_resolution TEXT NOT NULL, " \
198 "PRIMARY KEY(app_id,app_icon_section,app_icon_resolution) " \
199 "FOREIGN KEY(app_id) " \
200 "REFERENCES package_app_info(app_id) " \
203 #define QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO "CREATE TABLE IF NOT EXISTS package_app_image_info " \
204 "(app_id TEXT NOT NULL, " \
205 "app_locale TEXT DEFAULT 'No Locale', " \
206 "app_image_section TEXT NOT NULL, " \
208 "PRIMARY KEY(app_id,app_image_section) " \
209 "FOREIGN KEY(app_id) " \
210 "REFERENCES package_app_info(app_id) " \
213 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL "CREATE TABLE IF NOT EXISTS package_app_app_control " \
214 "(app_id TEXT NOT NULL, " \
215 "app_control TEXT NOT NULL, " \
216 "PRIMARY KEY(app_id,app_control) " \
217 "FOREIGN KEY(app_id) " \
218 "REFERENCES package_app_info(app_id) " \
221 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "CREATE TABLE IF NOT EXISTS package_app_app_category " \
222 "(app_id TEXT NOT NULL, " \
223 "category TEXT NOT NULL, " \
224 "PRIMARY KEY(app_id,category) " \
225 "FOREIGN KEY(app_id) " \
226 "REFERENCES package_app_info(app_id) " \
229 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA "CREATE TABLE IF NOT EXISTS package_app_app_metadata " \
230 "(app_id TEXT NOT NULL, " \
231 "md_key TEXT NOT NULL, " \
233 "PRIMARY KEY(app_id, md_key) " \
234 "FOREIGN KEY(app_id) " \
235 "REFERENCES package_app_info(app_id) " \
238 #define QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION "CREATE TABLE IF NOT EXISTS package_app_app_permission " \
239 "(app_id TEXT NOT NULL, " \
240 "pm_type TEXT NOT NULL, " \
241 "pm_value TEXT NOT NULL, " \
242 "PRIMARY KEY(app_id, pm_type, pm_value) " \
243 "FOREIGN KEY(app_id) " \
244 "REFERENCES package_app_info(app_id) " \
247 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED "CREATE TABLE IF NOT EXISTS package_app_share_allowed " \
248 "(app_id TEXT NOT NULL, " \
249 "data_share_path TEXT NOT NULL, " \
250 "data_share_allowed TEXT NOT NULL, " \
251 "PRIMARY KEY(app_id,data_share_path,data_share_allowed) " \
252 "FOREIGN KEY(app_id) " \
253 "REFERENCES package_app_info(app_id) " \
256 #define QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST "CREATE TABLE IF NOT EXISTS package_app_share_request " \
257 "(app_id TEXT NOT NULL, " \
258 "data_share_request TEXT NOT NULL, " \
259 "PRIMARY KEY(app_id,data_share_request) " \
260 "FOREIGN KEY(app_id) " \
261 "REFERENCES package_app_info(app_id) " \
264 #define QUERY_CREATE_TABLE_PACKAGE_APP_DATA_CONTROL "CREATE TABLE IF NOT EXISTS package_app_data_control " \
265 "(app_id TEXT NOT NULL, " \
266 "providerid TEXT NOT NULL, " \
267 "access TEXT NOT NULL, " \
268 "type TEXT NOT NULL, " \
269 "PRIMARY KEY(app_id, providerid, access, type) " \
270 "FOREIGN KEY(app_id) " \
271 "REFERENCES package_app_info(app_id) " \
274 #define QUERY_CREATE_TABLE_PACKAGE_APP_INFO_FOR_UID "CREATE TABLE IF NOT EXISTS package_app_info_for_uid " \
275 "(app_id TEXT NOT NULL, " \
276 "uid INTEGER NOT NULL, " \
277 "is_disabled TEXT NOT NULL DEFAULT 'false', " \
278 "is_splash_screen_enabled TEXT NOT NULL, " \
279 "PRIMARY KEY(app_id, uid))"
281 #define QUERY_CREATE_TRIGGER_UPDATE_PACKAGE_APP_INFO_FOR_UID \
282 "CREATE TRIGGER IF NOT EXISTS update_package_appinfo_for_uid "\
283 "AFTER UPDATE ON package_app_info_for_uid " \
285 " DELETE FROM package_app_info_for_uid WHERE " \
286 " is_splash_screen_enabled=" \
287 " (SELECT package_app_info.app_splash_screen_display FROM " \
288 " package_app_info, package_app_info_for_uid WHERE " \
289 " package_app_info.app_id=OLD.app_id) AND is_disabled='false';" \
292 #define QUERY_CREATE_TABLE_PACKAGE_APP_SPLASH_SCREEN \
293 "CREATE TABLE IF NOT EXISTS package_app_splash_screen " \
294 "(app_id TEXT NOT NULL, " \
295 "src TEXT NOT NULL, " \
296 "type TEXT NOT NULL, " \
297 "orientation TEXT NOT NULL, " \
298 "indicatordisplay TEXT, " \
300 "color_depth TEXT NOT NULL DEFAULT '24', " \
301 "PRIMARY KEY(app_id, orientation) " \
302 "FOREIGN KEY(app_id) " \
303 "REFERENCES package_app_info(app_id) " \
307 /* FIXME: duplicated at pkgmgrinfo_db.c */
308 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO \
309 "CREATE TABLE IF NOT EXISTS package_cert_index_info( " \
310 " cert_info TEXT UNIQUE, " \
311 " cert_id INTEGER PRIMARY KEY, " \
312 " cert_ref_count INTEGER NOT NULL)"
314 #define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO \
315 "CREATE TABLE IF NOT EXISTS package_cert_info( " \
316 " package TEXT PRIMARY KEY, " \
317 " author_root_cert INTEGER, " \
318 " author_im_cert INTEGER, " \
319 " author_signer_cert INTEGER, " \
320 " dist_root_cert INTEGER, " \
321 " dist_im_cert INTEGER, " \
322 " dist_signer_cert INTEGER, " \
323 " dist2_root_cert INTEGER, " \
324 " dist2_im_cert INTEGER, " \
325 " dist2_signer_cert INTEGER)"
327 #define QUERY_CREATE_TRIGGER_DELETE_CERT_INFO \
328 "CREATE TRIGGER IF NOT EXISTS delete_cert_info " \
329 "AFTER DELETE ON package_cert_info " \
331 " UPDATE package_cert_index_info SET" \
332 " cert_ref_count = cert_ref_count - 1" \
333 " WHERE cert_id = OLD.author_root_cert" \
334 " OR cert_id = OLD.author_im_cert" \
335 " OR cert_id = OLD.author_signer_cert" \
336 " OR cert_id = OLD.dist_root_cert" \
337 " OR cert_id = OLD.dist_im_cert" \
338 " OR cert_id = OLD.dist_signer_cert" \
339 " OR cert_id = OLD.dist2_root_cert" \
340 " OR cert_id = OLD.dist2_im_cert" \
341 " OR cert_id = OLD.dist2_signer_cert;" \
344 #define QUERY_CREATE_TRIGGER_UPDATE_CERT_INDEX_INFO \
345 "CREATE TRIGGER IF NOT EXISTS update_cert_index_info " \
346 "AFTER UPDATE ON package_cert_index_info " \
347 "WHEN ((SELECT cert_ref_count FROM package_cert_index_info " \
348 " WHERE cert_id = OLD.cert_id) = 0) "\
350 " DELETE FROM package_cert_index_info WHERE cert_id = OLD.cert_id;" \
353 #define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT \
354 "CREATE TRIGGER IF NOT EXISTS update_%s_info " \
355 "AFTER UPDATE ON package_cert_info " \
356 "WHEN (OLD.%s IS NOT NULL) " \
358 " UPDATE package_cert_index_info SET" \
359 " cert_ref_count = cert_ref_count - 1" \
360 " WHERE cert_id = OLD.%s;" \
363 static int __insert_application_info(manifest_x *mfx);
364 static int __insert_application_appcategory_info(manifest_x *mfx);
365 static int __insert_application_appcontrol_info(manifest_x *mfx);
366 static int __insert_application_appmetadata_info(manifest_x *mfx);
367 static int __insert_application_share_allowed_info(manifest_x *mfx);
368 static int __insert_application_share_request_info(manifest_x *mfx);
369 static int __insert_application_datacontrol_info(manifest_x *mfx);
370 static void __insert_application_locale_info(gpointer data, gpointer userdata);
371 static void __insert_pkglocale_info(gpointer data, gpointer userdata);
372 static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid);
373 static int __delete_manifest_info_from_db(manifest_x *mfx, uid_t uid);
374 static int __delete_subpkg_info_from_db(char *appid);
375 static int __delete_appinfo_from_db(char *db_table, const char *appid);
376 static int __initialize_db(sqlite3 *db_handle, const char *db_query);
377 static int __exec_query(char *query);
378 static void __extract_data(gpointer data, GList *lbl, GList *lcn, GList *icn, GList *dcn, GList *ath,
379 char **label, char **license, char **icon, char **description, char **author);
380 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata);
381 static GList *__create_locale_list(GList *locale, GList *lbl, GList *lcn, GList *icn, GList *dcn, GList *ath);
382 static void __preserve_guestmode_visibility_value(manifest_x *mfx);
383 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname);
384 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
385 static int __parserdb_change_perm(const char *db_file, uid_t uid);
387 #define REGULAR_USER 5000
388 static inline uid_t _getuid(void)
390 uid_t uid = getuid();
392 if (uid < REGULAR_USER)
393 return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
398 static int __delete_subpkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
401 __delete_subpkg_info_from_db(coltxt[0]);
406 static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path)
411 char *error_message = NULL;
413 ret = db_util_open(db_path, &handle, DB_UTIL_REGISTER_HOOK_METHOD);
414 if (ret != SQLITE_OK) {
415 _LOGD("connect db [%s] failed!\n", db_path);
420 /* add user_version for db upgrade*/
421 query = sqlite3_mprintf("PRAGMA user_version=%d", (atoi(TIZEN_MAJOR_VER) * 10000 + atoi(TIZEN_MINOR_VER) * 100 + atoi(TIZEN_PATCH_VER)));
423 sqlite3_exec(handle, query, NULL, NULL, &error_message)) {
424 _LOGE("Don't execute query = %s error message = %s\n", query,
427 sqlite3_free(error_message);
433 static int __guestmode_visibility_cb(void *data, int ncols, char **coltxt, char **colname)
435 manifest_x *mfx = (manifest_x *)data;
441 if (mfx->application == NULL)
443 app = (application_x *)mfx->application->data;
444 for(i = 0; i < ncols; i++)
446 if (strcmp(colname[i], "app_id") == 0) {
448 appid = strdup(coltxt[i]);
449 } else if (strcmp(colname[i], "app_guestmodevisibility") == 0) {
451 status = strdup(coltxt[i]);
457 _LOGD("app id is NULL\n");
460 /*update guest mode visibility*/
461 for (tmp = mfx->application; tmp; tmp = tmp->next) {
462 app = (application_x *)tmp->data;
465 if (strcmp(app->appid, appid) == 0) {
466 free((void *)app->guestmode_visibility);
467 app->guestmode_visibility = strdup(status);
483 static void __preserve_guestmode_visibility_value(manifest_x *mfx)
485 char *error_message = NULL;
486 char query[MAX_QUERY_LEN] = {'\0'};
487 sqlite3_snprintf(MAX_QUERY_LEN, query,
488 "SELECT app_id, app_guestmodevisibility FROM package_app_info " \
489 "WHERE package=%Q", mfx->package);
491 sqlite3_exec(pkgmgr_parser_db, query,
492 __guestmode_visibility_cb, (void *)mfx, &error_message)) {
493 _LOGD("Don't execute query = %s error message = %s\n",
494 query, error_message);
495 sqlite3_free(error_message);
500 static int __initialize_db(sqlite3 *db_handle, const char *db_query)
502 char *error_message = NULL;
504 sqlite3_exec(db_handle, db_query,
505 NULL, NULL, &error_message)) {
506 _LOGD("Don't execute query = %s error message = %s\n",
507 db_query, error_message);
508 sqlite3_free(error_message);
511 sqlite3_free(error_message);
515 static int __exec_query(char *query)
517 char *error_message = NULL;
519 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
520 _LOGE("Don't execute query = %s error message = %s\n", query,
522 sqlite3_free(error_message);
525 sqlite3_free(error_message);
529 static int __exec_query_no_msg(char *query)
531 char *error_message = NULL;
533 sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
534 sqlite3_free(error_message);
537 sqlite3_free(error_message);
541 static GList *__create_locale_list(GList *locale, GList *lbls, GList *lcns, GList *icns, GList *dcns, GList *aths)
549 for (tmp = lbls; tmp; tmp = tmp->next) {
550 lbl = (label_x *)tmp->data;
554 locale = g_list_insert_sorted_with_data(locale, (gpointer)lbl->lang, __comparefunc, NULL);
556 for (tmp = lcns; tmp; tmp = tmp->next) {
557 lcn = (license_x *)tmp->data;
561 locale = g_list_insert_sorted_with_data(locale, (gpointer)lcn->lang, __comparefunc, NULL);
563 for (tmp = icns; tmp; tmp = tmp->next) {
564 icn = (icon_x *)tmp->data;
568 locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->lang, __comparefunc, NULL);
570 for (tmp = dcns; tmp; tmp = tmp->next) {
571 dcn = (description_x *)tmp->data;
575 locale = g_list_insert_sorted_with_data(locale, (gpointer)dcn->lang, __comparefunc, NULL);
577 for (tmp = aths; tmp; tmp = tmp->next) {
578 ath = (author_x *)tmp->data;
582 locale = g_list_insert_sorted_with_data(locale, (gpointer)ath->lang, __comparefunc, NULL);
588 static GList *__create_icon_list(GList *appicon, GList *icns)
593 for (tmp = icns; tmp; tmp = tmp->next) {
594 icn = (icon_x *)tmp->data;
598 appicon = g_list_insert_sorted_with_data(appicon, (gpointer)icn->section, __comparefunc, NULL);
603 static GList *__create_image_list(GList *appimage, GList *imgs)
608 for (tmp = imgs; tmp; tmp = tmp->next) {
609 img = (image_x *)tmp->data;
613 appimage = g_list_insert_sorted_with_data(appimage, (gpointer)img->section, __comparefunc, NULL);
618 static void __trimfunc(GList* trim_list)
620 char *trim_data = NULL;
624 list = g_list_first(trim_list);
627 trim_data = (char *)list->data;
630 if (strcmp(trim_data, prev) == 0) {
631 trim_list = g_list_remove(trim_list, trim_data);
632 list = g_list_first(trim_list);
641 list = g_list_next(list);
645 static gint __comparefunc(gconstpointer a, gconstpointer b, gpointer userdata)
647 if (a == NULL || b == NULL)
649 if (strcmp((char*)a, (char*)b) == 0)
651 if (strcmp((char*)a, (char*)b) < 0)
653 if (strcmp((char*)a, (char*)b) > 0)
658 static int __check_dpi(const char *dpi_char, int dpi_int)
660 if (dpi_char == NULL)
663 if (strcasecmp(dpi_char, LDPI) == 0) {
664 if (dpi_int >= LDPI_MIN && dpi_int <= LDPI_MAX)
668 } else if (strcasecmp(dpi_char, MDPI) == 0) {
669 if (dpi_int >= MDPI_MIN && dpi_int <= MDPI_MAX)
673 } else if (strcasecmp(dpi_char, HDPI) == 0) {
674 if (dpi_int >= HDPI_MIN && dpi_int <= HDPI_MAX)
678 } else if (strcasecmp(dpi_char, XHDPI) == 0) {
679 if (dpi_int >= XHDPI_MIN && dpi_int <= XHDPI_MAX)
683 } else if (strcasecmp(dpi_char, XXHDPI) == 0) {
684 if (dpi_int >= XXHDPI_MIN && dpi_int <= XXHDPI_MAX)
692 static gint __check_icon_folder(const char *orig_icon_path, char **new_icon_path)
695 char *icon_filename = NULL;
696 char modified_iconpath[BUFSIZE] = { '\0' };
697 char icon_path[BUFSIZE] = { '\0' };
701 if (orig_icon_path == NULL)
704 system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
708 if (dpi >= LDPI_MIN && dpi <= LDPI_MAX) {
709 dpi_path[0] = "LDPI";
710 dpi_path[1] = "ldpi";
711 } else if (dpi >= MDPI_MIN && dpi <= MDPI_MAX) {
712 dpi_path[0] = "MDPI";
713 dpi_path[1] = "mdpi";
714 } else if (dpi >= HDPI_MIN && dpi <= HDPI_MAX) {
715 dpi_path[0] = "HDPI";
716 dpi_path[1] = "hdpi";
717 } else if (dpi >= XHDPI_MIN && dpi <= XHDPI_MAX) {
718 dpi_path[0] = "XHDPI";
719 dpi_path[1] = "xhdpi";
720 } else if (dpi >= XXHDPI_MIN && dpi <= XXHDPI_MAX) {
721 dpi_path[0] = "XXHDPI";
722 dpi_path[1] = "xxhdpi";
724 _LOGE("Unidentified dpi[%d]", dpi);
728 icon_filename = strrchr(orig_icon_path, '/');
729 if (icon_filename == NULL)
732 snprintf(icon_path, strlen(orig_icon_path) - (strlen(icon_filename) - 1), "%s", orig_icon_path);
733 for (i = 0; i < 2; i++) {
734 snprintf(modified_iconpath, BUFSIZE - 1, "%s/%s%s", icon_path, dpi_path[i], icon_filename);
735 if (access(modified_iconpath, F_OK) != -1) {
736 // if exists, return modified icon path
737 *new_icon_path = strdup(modified_iconpath);
745 static gint __compare_icon(gconstpointer a, gconstpointer b)
747 icon_x *icon = (icon_x *)a;
749 char *icon_folder_path = NULL;
751 if (icon->lang != NULL && strcasecmp(icon->lang, DEFAULT_LOCALE) != 0)
754 if (icon->dpi != NULL)
757 if (__check_icon_folder(icon->text, &icon_folder_path) == 0) {
759 icon->text = icon_folder_path;
765 static gint __compare_icon_with_dpi(gconstpointer a, gconstpointer b)
767 icon_x *icon = (icon_x *)a;
768 int dpi = GPOINTER_TO_INT(b);
770 if (icon->lang != NULL && strcasecmp(icon->lang, DEFAULT_LOCALE) != 0)
773 if (icon->dpi == NULL)
776 if (__check_dpi(icon->dpi, dpi) == 0)
782 static gint __compare_icon_with_lang(gconstpointer a, gconstpointer b)
784 icon_x *icon = (icon_x *)a;
785 char *lang = (char *)b;
786 char *icon_folder_path = NULL;
788 if (icon->dpi != NULL)
791 if (strcasecmp(icon->lang, lang) == 0) {
792 if (strcasecmp(icon->lang, DEFAULT_LOCALE) == 0) {
793 //icon for no locale. check existance of folder-hierachied default icons
794 if (__check_icon_folder(icon->text, &icon_folder_path) == 0) {
796 icon->text = icon_folder_path;
805 static gint __compare_icon_with_lang_dpi(gconstpointer a, gconstpointer b)
807 icon_x *icon = (icon_x *)a;
808 char *lang = (char *)b;
811 system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
815 if (strcasecmp(icon->lang, lang) == 0 && __check_dpi(icon->dpi, dpi) == 0)
821 static char *__find_icon(GList *icons, const char *lang)
828 // first, find icon whose locale and dpi with given lang and system's dpi has matched
829 tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang_dpi);
831 icon = (icon_x *)tmp->data;
832 return (char *)icon->text;
835 // if first has failed, find icon whose locale has matched
836 tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang);
838 icon = (icon_x *)tmp->data;
839 return (char *)icon->text;
842 // if second has failed, find icon whose dpi has matched with system's dpi
843 ret = system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
844 if (ret == SYSTEM_INFO_ERROR_NONE) {
845 tmp = g_list_find_custom(icons, GINT_TO_POINTER(dpi), (GCompareFunc)__compare_icon_with_dpi);
847 icon = (icon_x *)tmp->data;
848 return (char *)icon->text;
852 // last, find default icon marked as "No Locale"
853 tmp = g_list_find_custom(icons, NULL, (GCompareFunc)__compare_icon);
855 icon = (icon_x *)tmp->data;
856 return (char *)icon->text;
862 static void __extract_data(gpointer data, GList *lbls, GList *lcns, GList *icns, GList *dcns, GList *aths,
863 char **label, char **license, char **icon, char **description, char **author)
870 for (tmp = lbls; tmp; tmp = tmp->next) {
871 lbl = (label_x *)tmp->data;
875 if (strcmp(lbl->lang, (char *)data) == 0) {
876 *label = (char*)lbl->text;
881 for (tmp = lcns; tmp; tmp = tmp->next) {
882 lcn = (license_x *)tmp->data;
886 if (strcmp(lcn->lang, (char *)data) == 0) {
887 *license = (char*)lcn->text;
893 *icon = __find_icon(icns, (char *)data);
895 for (tmp = dcns; tmp; tmp = tmp->next) {
896 dcn = (description_x *)tmp->data;
900 if (strcmp(dcn->lang, (char *)data) == 0) {
901 *description = (char*)dcn->text;
906 for (tmp = aths; tmp; tmp = tmp->next) {
907 ath = (author_x *)tmp->data;
911 if (strcmp(ath->lang, (char *)data) == 0) {
912 *author = (char*)ath->text;
920 static void __extract_icon_data(gpointer data, GList *icns, char **icon, char **resolution)
924 for (tmp = icns; tmp; tmp = tmp->next) {
925 icn = (icon_x *)tmp->data;
929 if (strcmp(icn->section, (char *)data) == 0) {
930 *icon = (char*)icn->text;
931 *resolution = (char*)icn->resolution;
938 static void __extract_image_data(gpointer data, GList *imgs, char **lang, char **image)
942 for (tmp = imgs; tmp; tmp = tmp->next) {
943 img = (image_x *)tmp->data;
947 if (strcmp(img->section, (char *)data) == 0) {
948 *lang = (char*)img->lang;
949 *image = (char*)img->text;
956 static void __insert_pkglocale_info(gpointer data, gpointer userdata)
961 char *description = NULL;
962 char *license = NULL;
966 manifest_x *mfx = (manifest_x *)userdata;
967 GList *lbl = mfx->label;
968 GList *lcn = mfx->license;
969 GList *icn = mfx->icon;
970 GList *dcn = mfx->description;
971 GList *ath = mfx->author;
973 __extract_data(data, lbl, lcn, icn, dcn, ath, &label, &license, &icon, &description, &author);
974 if (!label && !description && !icon && !license && !author)
977 query = sqlite3_mprintf("INSERT INTO package_localized_info(package, package_locale, " \
978 "package_label, package_icon, package_description, package_license, package_author) VALUES" \
979 "(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
988 ret = __exec_query(query);
990 _LOGD("Package Localized Info DB Insert failed\n");
995 static void __insert_application_locale_info(gpointer data, gpointer userdata)
1002 application_x *app = (application_x*)userdata;
1003 GList *lbl = app->label;
1004 GList *icn = app->icon;
1006 __extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
1007 if (!label && !icon)
1010 query = sqlite3_mprintf("INSERT INTO package_app_localized_info(app_id, app_locale, " \
1011 "app_label, app_icon) VALUES" \
1012 "(%Q, %Q, %Q, %Q)", app->appid, (char*)data,
1014 ret = __exec_query(query);
1016 _LOGD("Package UiApp Localized Info DB Insert failed\n");
1018 sqlite3_free(query);
1020 /*insert ui app locale info to pkg locale to get mainapp data */
1021 if (strcasecmp(app->mainapp, "true")==0) {
1022 query = sqlite3_mprintf("INSERT INTO package_localized_info(package, package_locale, " \
1023 "package_label, package_icon, package_description, package_license, package_author) VALUES" \
1024 "(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1033 ret = __exec_query_no_msg(query);
1034 sqlite3_free(query);
1037 query = sqlite3_mprintf("UPDATE package_localized_info SET package_icon=%Q "\
1038 "WHERE package=%Q AND package_locale=%Q", icon, app->package, (char*)data);
1039 ret = __exec_query_no_msg(query);
1040 sqlite3_free(query);
1045 static void __insert_application_icon_section_info(gpointer data, gpointer userdata)
1049 char *resolution = NULL;
1050 char query[MAX_QUERY_LEN] = {'\0'};
1052 application_x *app = (application_x*)userdata;
1053 GList *icn = app->icon;
1055 __extract_icon_data(data, icn, &icon, &resolution);
1056 if (!icon && !resolution)
1058 sqlite3_snprintf(MAX_QUERY_LEN, query, "INSERT INTO package_app_icon_section_info(app_id, " \
1059 "app_icon, app_icon_section, app_icon_resolution) VALUES " \
1060 "(%Q, %Q, %Q, %Q)", app->appid,
1061 icon, (char*)data, resolution);
1063 ret = __exec_query(query);
1065 _LOGD("Package UiApp Localized Info DB Insert failed\n");
1069 static void __insert_application_image_info(gpointer data, gpointer userdata)
1074 char query[MAX_QUERY_LEN] = {'\0'};
1076 application_x *app = (application_x*)userdata;
1077 GList *image = app->image;
1079 __extract_image_data(data, image, &lang, &img);
1082 sqlite3_snprintf(MAX_QUERY_LEN, query,
1083 "INSERT INTO package_app_image_info(app_id, app_locale, " \
1084 "app_image_section, app_image) VALUES" \
1085 "(%Q, %Q, %Q, %Q)", app->appid, lang, (char*)data, img);
1087 ret = __exec_query(query);
1089 _LOGD("Package UiApp image Info DB Insert failed\n");
1094 static int __insert_mainapp_info(manifest_x *mfx)
1099 char query[MAX_QUERY_LEN] = {'\0'};
1100 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1101 app = (application_x *)tmp->data;
1105 sqlite3_snprintf(MAX_QUERY_LEN, query,
1106 "UPDATE package_app_info SET app_mainapp=%Q WHERE app_id=%Q",
1107 app->mainapp, app->appid);
1108 ret = __exec_query(query);
1110 _LOGD("Package App Info DB Insert Failed\n");
1113 if (strcasecmp(app->mainapp, "True")==0)
1114 mfx->mainapp_id = strdup(app->appid);
1117 if (mfx->mainapp_id == NULL) {
1118 if (mfx->application == NULL)
1120 app = (application_x *)mfx->application->data;
1124 sqlite3_snprintf(MAX_QUERY_LEN, query,
1125 "UPDATE package_app_info SET app_mainapp='true' WHERE app_id=%Q",
1128 _LOGD("Not valid appid\n");
1132 ret = __exec_query(query);
1134 _LOGD("Package UiApp Info DB Insert Failed\n");
1138 free((void *)app->mainapp);
1139 app->mainapp= strdup("true");
1140 mfx->mainapp_id = strdup(app->appid);
1143 memset(query, '\0', MAX_QUERY_LEN);
1144 sqlite3_snprintf(MAX_QUERY_LEN, query,
1145 "UPDATE package_info SET mainapp_id=%Q WHERE package=%Q", mfx->mainapp_id, mfx->package);
1146 ret = __exec_query(query);
1148 _LOGD("Package Info DB update Failed\n");
1155 static int __convert_background_category(GList *category_list)
1158 GList *tmp_list = category_list;
1159 char *category_data = NULL;
1161 if (category_list == NULL)
1164 while (tmp_list != NULL) {
1165 category_data = (char *)tmp_list->data;
1166 if (strcmp(category_data, APP_BG_CATEGORY_MEDIA_STR) == 0) {
1167 ret = ret | APP_BG_CATEGORY_MEDIA_VAL;
1168 } else if (strcmp(category_data, APP_BG_CATEGORY_DOWNLOAD_STR) == 0) {
1169 ret = ret | APP_BG_CATEGORY_DOWNLOAD_VAL;
1170 } else if (strcmp(category_data, APP_BG_CATEGORY_BGNETWORK_STR) == 0) {
1171 ret = ret | APP_BG_CATEGORY_BGNETWORK_VAL;
1172 } else if (strcmp(category_data, APP_BG_CATEGORY_LOCATION_STR) == 0) {
1173 ret = ret | APP_BG_CATEGORY_LOCATION_VAL;
1174 } else if (strcmp(category_data, APP_BG_CATEGORY_SENSOR_STR) == 0) {
1175 ret = ret | APP_BG_CATEGORY_SENSOR_VAL;
1176 } else if (strcmp(category_data, APP_BG_CATEGORY_IOTCOMM_STR) == 0) {
1177 ret = ret | APP_BG_CATEGORY_IOTCOMM_VAL;
1178 } else if (strcmp(category_data, APP_BG_CATEGORY_SYSTEM) == 0) {
1179 ret = ret | APP_BG_CATEGORY_SYSTEM_VAL;
1181 _LOGE("Unidentified category [%s]", category_data);
1183 tmp_list = g_list_next(tmp_list);
1189 static const char *__find_effective_appid(GList *metadata_list)
1194 for (tmp_list = metadata_list; tmp_list; tmp_list = tmp_list->next) {
1195 md = (metadata_x *)tmp_list->data;
1196 if (md == NULL || md->key == NULL)
1199 if (strcmp(md->key, "http://tizen.org/metadata/effective-appid") == 0) {
1208 static char *__get_bool(char *value, bool is_true)
1210 if (value != NULL) {
1211 if (!strcmp(value, ""))
1212 return (is_true) ? "true" : "false";
1216 return (is_true) ? "true" : "false";
1219 /* _PRODUCT_LAUNCHING_ENHANCED_
1220 * app->indicatordisplay, app->portraitimg, app->landscapeimg, app->guestmode_appstatus
1222 static int __insert_application_info(manifest_x *mfx)
1227 int background_value = 0;
1228 char query[MAX_QUERY_LEN] = {'\0'};
1230 const char *effective_appid;
1233 type = strdup(mfx->type);
1235 type = strdup("tpk");
1237 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1238 app = (application_x *)tmp->data;
1242 background_value = __convert_background_category(app->background_category);
1243 if (background_value < 0) {
1244 _LOGE("Failed to retrieve background value[%d]", background_value);
1245 background_value = 0;
1248 effective_appid = __find_effective_appid(app->metadata);
1250 sqlite3_snprintf(MAX_QUERY_LEN, query,
1251 "INSERT INTO package_app_info(" \
1252 "app_id, app_component, app_exec, app_nodisplay, app_type, " \
1253 "app_onboot, app_multiple, app_autorestart, app_taskmanage, app_enabled, " \
1254 "app_hwacceleration, app_screenreader, app_mainapp, app_recentimage, app_launchcondition, " \
1255 "app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, " \
1256 "app_preload, app_submode, app_submode_mainid, app_installed_storage, app_process_pool, " \
1257 "app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, " \
1258 "app_tep_name, app_zip_mount_file, app_background_category, app_package_type, app_root_path, " \
1259 "app_api_version, app_effective_appid, app_splash_screen_display) " \
1261 "%Q, %Q, %Q, LOWER(%Q), %Q, " \
1262 "LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), " \
1263 "%Q, %Q, %Q, %Q, %Q, " \
1264 "LOWER(%Q), %Q, %Q, LOWER(%Q), %Q, " \
1265 "LOWER(%Q), LOWER(%Q), %Q, %Q, LOWER(%Q), " \
1266 "COALESCE(%Q, 'caller'), LOWER(%Q), LOWER(%Q), %Q, %Q, " \
1267 "%Q, %Q, %d, %Q, %Q, " \
1268 "%Q, %Q, LOWER(%Q))", \
1269 app->appid, app->component_type, app->exec, __get_bool(app->nodisplay, false), app->type,
1270 __get_bool(app->onboot, false), __get_bool(app->multiple, false), __get_bool(app->autorestart, false), __get_bool(app->taskmanage, false), __get_bool(app->enabled, true),
1271 app->hwacceleration, app->screenreader, app->mainapp, app->recentimage, app->launchcondition,
1272 __get_bool(app->indicatordisplay, true), app->portraitimg, app->landscapeimg,
1273 __get_bool(app->guestmode_visibility, true), app->permission_type,
1274 __get_bool(mfx->preload, false), __get_bool(app->submode, false), app->submode_mainid, mfx->installed_storage, __get_bool(app->process_pool, false),
1275 app->launch_mode, __get_bool(app->ui_gadget, false), __get_bool(mfx->support_disable, false), app->component_type, mfx->package,
1276 mfx->tep_name, mfx->zip_mount_file, background_value, type, mfx->root_path, mfx->api_version,
1277 effective_appid, __get_bool(app->splash_screen_display, false));
1279 ret = __exec_query(query);
1281 _LOGD("Package UiApp Info DB Insert Failed\n");
1286 memset(query, '\0', MAX_QUERY_LEN);
1295 static int __insert_application_appcategory_info(manifest_x *mfx)
1302 char query[MAX_QUERY_LEN] = {'\0'};
1303 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1304 app = (application_x *)app_tmp->data;
1307 for (ct_tmp = app->category; ct_tmp; ct_tmp = ct_tmp->next) {
1308 ct = (const char *)ct_tmp->data;
1311 sqlite3_snprintf(MAX_QUERY_LEN, query,
1312 "INSERT INTO package_app_app_category(app_id, category) " \
1315 ret = __exec_query(query);
1317 _LOGD("Package UiApp Category Info DB Insert Failed\n");
1320 memset(query, '\0', MAX_QUERY_LEN);
1326 static int __insert_application_appmetadata_info(manifest_x *mfx)
1333 char query[MAX_QUERY_LEN] = {'\0'};
1334 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1335 app = (application_x *)app_tmp->data;
1338 for (md_tmp = app->metadata; md_tmp; md_tmp = md_tmp->next) {
1339 md = (metadata_x *)md_tmp->data;
1343 sqlite3_snprintf(MAX_QUERY_LEN, query,
1344 "INSERT INTO package_app_app_metadata(app_id, md_key, md_value) " \
1345 "VALUES(%Q, %Q, %Q)",\
1346 app->appid, md->key, md->value ? md->value : NULL);
1347 ret = __exec_query(query);
1349 _LOGD("Package UiApp Metadata Info DB Insert Failed\n");
1353 memset(query, '\0', MAX_QUERY_LEN);
1359 static int __insert_application_apppermission_info(manifest_x *mfx)
1366 char query[MAX_QUERY_LEN] = {'\0'};
1367 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1368 app = (application_x *)app_tmp->data;
1371 for (pm_tmp = app->permission; pm_tmp; pm_tmp = pm_tmp->next) {
1372 pm = (permission_x *)pm_tmp->data;
1375 sqlite3_snprintf(MAX_QUERY_LEN, query,
1376 "INSERT INTO package_app_app_permission(app_id, pm_type, pm_value) " \
1377 "VALUES(%Q, %Q, %Q)",\
1378 app->appid, pm->type, pm->value);
1379 ret = __exec_query(query);
1381 _LOGD("Package UiApp permission Info DB Insert Failed\n");
1384 memset(query, '\0', MAX_QUERY_LEN);
1390 static int __insert_application_appcontrol_info(manifest_x *mfx)
1394 GList *acontrol_tmp;
1395 appcontrol_x *acontrol;
1397 char query[MAX_QUERY_LEN] = {'\0'};
1398 char buf[BUFSIZE] = {'\0'};
1399 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1400 app = (application_x *)app_tmp->data;
1403 for (acontrol_tmp = app->appcontrol; acontrol_tmp; acontrol_tmp = acontrol_tmp->next) {
1404 acontrol = (appcontrol_x *)acontrol_tmp->data;
1405 if (acontrol == NULL)
1407 snprintf(buf, BUFSIZE, "%s|%s|%s",\
1408 acontrol->operation ? (strlen(acontrol->operation) > 0 ? acontrol->operation : "NULL") : "NULL",
1409 acontrol->uri ? (strlen(acontrol->uri) > 0 ? acontrol->uri : "NULL") : "NULL",
1410 acontrol->mime ? (strlen(acontrol->mime) > 0 ? acontrol->mime : "NULL") : "NULL");
1411 sqlite3_snprintf(MAX_QUERY_LEN, query,
1412 "INSERT INTO package_app_app_control(app_id, app_control) " \
1415 ret = __exec_query(query);
1417 _LOGD("Package UiApp AppSvc DB Insert Failed\n");
1420 memset(query, '\0', MAX_QUERY_LEN);
1426 static int __insert_application_datacontrol_info(manifest_x *mfx)
1433 char query[MAX_QUERY_LEN] = {'\0'};
1435 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1436 app = (application_x *)app_tmp->data;
1439 for (dc_tmp = app->datacontrol; dc_tmp; dc_tmp = dc_tmp->next) {
1440 dc = (datacontrol_x *)dc_tmp->data;
1443 sqlite3_snprintf(MAX_QUERY_LEN, query,
1444 "INSERT INTO package_app_data_control(app_id, providerid, access, type) " \
1445 "VALUES(%Q, %Q, %Q, %Q)",\
1451 ret = __exec_query(query);
1453 _LOGD("Package UiApp Data Control DB Insert Failed\n");
1456 memset(query, '\0', MAX_QUERY_LEN);
1462 static int __insert_application_share_request_info(manifest_x *mfx)
1471 char query[MAX_QUERY_LEN] = {'\0'};
1472 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1473 app = (application_x *)app_tmp->data;
1476 for (ds_tmp = app->datashare; ds_tmp; ds_tmp = ds_tmp->next) {
1477 ds = (datashare_x *)ds_tmp->data;
1480 for (rq_tmp = ds->request; rq_tmp; rq_tmp = rq_tmp->next) {
1481 rq = (const char *)rq_tmp->data;
1484 sqlite3_snprintf(MAX_QUERY_LEN, query,
1485 "INSERT INTO package_app_share_request(app_id, data_share_request) " \
1488 ret = __exec_query(query);
1490 _LOGD("Package UiApp Share Request DB Insert Failed\n");
1493 memset(query, '\0', MAX_QUERY_LEN);
1500 static int __insert_application_share_allowed_info(manifest_x *mfx)
1511 char query[MAX_QUERY_LEN] = {'\0'};
1512 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1513 app = (application_x *)app_tmp->data;
1516 for (ds_tmp = app->datashare; ds_tmp; ds_tmp = ds_tmp->next) {
1517 ds = (datashare_x *)ds_tmp->data;
1520 for (df_tmp = ds->define; df_tmp; df_tmp = df_tmp->next) {
1521 df = (define_x *)df_tmp->data;
1524 for (al_tmp = df->allowed; al_tmp; al_tmp = al_tmp->next) {
1525 al = (const char *)al_tmp->data;
1528 sqlite3_snprintf(MAX_QUERY_LEN, query,
1529 "INSERT INTO package_app_share_allowed(app_id, data_share_path, data_share_allowed) " \
1530 "VALUES(%Q, %Q, %Q)",\
1531 app->appid, df->path, al);
1532 ret = __exec_query(query);
1534 _LOGD("Package UiApp Share Allowed DB Insert Failed\n");
1537 memset(query, '\0', MAX_QUERY_LEN);
1545 static gint __compare_splashscreen_with_orientation_dpi(gconstpointer a, gconstpointer b)
1547 splashscreen_x *ss = (splashscreen_x *)a;
1548 const char *orientation = (const char *)b;
1551 if (ss->operation || ss->dpi == NULL)
1554 system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
1558 if (strcasecmp(ss->orientation, orientation) == 0 && __check_dpi(ss->dpi, dpi) == 0)
1564 static gint __compare_splashscreen_with_orientation(gconstpointer a, gconstpointer b)
1566 splashscreen_x *ss = (splashscreen_x *)a;
1567 const char *orientation = (const char *)b;
1569 if (ss->operation || ss->dpi)
1572 if (strcasecmp(ss->orientation, orientation) == 0)
1578 static splashscreen_x *__find_default_splashscreen(GList *splashscreens,
1579 const char *orientation)
1583 tmp = g_list_find_custom(splashscreens, orientation,
1584 (GCompareFunc)__compare_splashscreen_with_orientation_dpi);
1586 return (splashscreen_x *)tmp->data;
1588 tmp = g_list_find_custom(splashscreens, orientation,
1589 (GCompareFunc)__compare_splashscreen_with_orientation);
1591 return (splashscreen_x *)tmp->data;
1596 static void __find_appcontrol_splashscreen_with_dpi(gpointer data, gpointer user_data)
1598 splashscreen_x *ss = (splashscreen_x *)data;
1599 GList **list = (GList **)user_data;
1602 if (ss->operation == NULL || ss->dpi == NULL)
1605 system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
1609 if (__check_dpi(ss->dpi, dpi) != 0)
1612 *list = g_list_append(*list, ss);
1615 static void __find_appcontrol_splashscreen(gpointer data, gpointer user_data)
1617 splashscreen_x *ss = (splashscreen_x *)data;
1618 GList **list = (GList **)user_data;
1619 splashscreen_x *ss_tmp;
1622 if (ss->operation == NULL || ss->dpi)
1625 for (tmp = *list; tmp; tmp = tmp->next) {
1626 ss_tmp = (splashscreen_x *)tmp->data;
1627 if (ss_tmp->operation
1628 && strcmp(ss_tmp->operation, ss->operation) == 0
1629 && strcmp(ss_tmp->orientation, ss->orientation) == 0)
1633 *list = g_list_append(*list, ss);
1636 static GList *__find_splashscreens(GList *splashscreens)
1641 g_list_foreach(splashscreens,
1642 __find_appcontrol_splashscreen_with_dpi, &list);
1643 g_list_foreach(splashscreens,
1644 __find_appcontrol_splashscreen, &list);
1646 ss = __find_default_splashscreen(splashscreens, "portrait");
1648 list = g_list_append(list, ss);
1649 ss = __find_default_splashscreen(splashscreens, "landscape");
1651 list = g_list_append(list, ss);
1656 static int __insert_application_splashscreen_info(manifest_x *mfx)
1664 char query[MAX_QUERY_LEN] = {'\0'};
1666 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1667 app = (application_x *)app_tmp->data;
1668 if (app == NULL || app->splashscreens == NULL)
1671 ss_tmp = __find_splashscreens(app->splashscreens);
1675 for (tmp = ss_tmp; tmp; tmp = tmp->next) {
1676 ss = (splashscreen_x *)tmp->data;
1677 sqlite3_snprintf(MAX_QUERY_LEN, query,
1678 "INSERT INTO package_app_splash_screen" \
1679 "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
1680 "VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1681 app->appid, ss->src, ss->type, ss->orientation,
1682 ss->indicatordisplay, ss->operation,
1684 ret = __exec_query(query);
1686 _LOGD("Package UiApp Splash Screen DB Insert Failed");
1689 memset(query, '\0', MAX_QUERY_LEN);
1691 g_list_free(ss_tmp);
1696 static int __insert_application_legacy_splashscreen_info(manifest_x *mfx)
1701 char query[MAX_QUERY_LEN] = {'\0'};
1703 const char *image_type;
1704 const char *indicatordisplay;
1705 const char *orientation;
1706 const char *operation = NULL;
1707 const char *color_depth = "24"; /* default */
1709 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1710 app = (application_x *)app_tmp->data;
1712 (app->portraitimg == NULL && app->landscapeimg == NULL))
1714 image_type = "img"; /* default */
1715 if (app->effectimage_type) {
1716 tmp = strstr(app->effectimage_type, "edj");
1720 indicatordisplay = "true"; /* default */
1721 if (app->indicatordisplay)
1722 indicatordisplay = app->indicatordisplay;
1723 if (app->portraitimg) {
1724 orientation = "portrait";
1725 sqlite3_snprintf(MAX_QUERY_LEN, query,
1726 "INSERT INTO package_app_splash_screen" \
1727 "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
1728 "VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1729 app->appid, app->portraitimg, image_type,
1730 orientation, indicatordisplay, operation,
1732 ret = __exec_query(query);
1734 _LOGD("Package UiApp Splash Screen DB Insert Failed");
1737 memset(query, '\0', MAX_QUERY_LEN);
1739 if (app->landscapeimg) {
1740 orientation = "landscape";
1741 sqlite3_snprintf(MAX_QUERY_LEN, query,
1742 "INSERT INTO package_app_splash_screen" \
1743 "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
1744 "VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1745 app->appid, app->landscapeimg, image_type,
1746 orientation, indicatordisplay, operation,
1748 ret = __exec_query(query);
1750 _LOGD("Package UiApp Splash Screen DB Insert Failed");
1753 memset(query, '\0', MAX_QUERY_LEN);
1759 static int __insert_application_metadata_splashscreen_info(manifest_x *mfx)
1766 char query[MAX_QUERY_LEN] = {'\0'};
1768 char *tmpptr = NULL;
1769 const char *operation;
1770 const char *portraitimg;
1771 const char *landscapeimg;
1772 const char *indicatordisplay;
1773 const char *orientation;
1774 const char *image_type;
1775 const char *color_depth = "24"; /* default */
1777 for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
1778 app = (application_x *)app_tmp->data;
1782 for (md_tmp = app->metadata; md_tmp; md_tmp = md_tmp->next) {
1783 md = (metadata_x *)md_tmp->data;
1784 if (md == NULL || md->key == NULL || md->value == NULL)
1787 if (strcasestr(md->key, "operation_effect=")) {
1788 operation = index(md->key, '=');
1789 if (operation && operation[1] != '\0')
1793 } else if (strcasestr(md->key, "launch_effect")) {
1800 landscapeimg = NULL;
1801 indicatordisplay = "true"; /* default */
1802 token = strtok_r(md->value, "|", &tmpptr);
1803 while (token != NULL) {
1804 if (strcasestr(token, "portrait-effectimage=")) {
1805 portraitimg = index(token, '=');
1806 if (portraitimg && portraitimg[1] != '\0')
1810 } else if (strcasestr(token, "landscape-effectimage=")) {
1811 landscapeimg = index(token, '=');
1812 if (landscapeimg && landscapeimg[1] != '\0')
1815 landscapeimg = NULL;
1816 } else if (strcasestr(token, "indicatordisplay=")) {
1817 indicatordisplay = index(token, '=');
1818 if (indicatordisplay && indicatordisplay[1] != '\0')
1821 indicatordisplay = "true";
1824 token = strtok_r(NULL, "|", &tmpptr);
1828 orientation = "portrait";
1830 if (strcasestr(portraitimg, "edj"))
1832 sqlite3_snprintf(MAX_QUERY_LEN, query,
1833 "INSERT INTO package_app_splash_screen" \
1834 "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
1835 "VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1836 app->appid, portraitimg, image_type,
1837 orientation, indicatordisplay, operation,
1839 ret = __exec_query(query);
1841 _LOGD("Package UiApp Splash Screen DB Insert Failed");
1844 memset(query, '\0', MAX_QUERY_LEN);
1847 orientation = "landscape";
1849 if (strcasestr(landscapeimg, "edj"))
1851 sqlite3_snprintf(MAX_QUERY_LEN, query,
1852 "INSERT INTO package_app_splash_screen" \
1853 "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
1854 "VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
1855 app->appid, landscapeimg, image_type,
1856 orientation, indicatordisplay, operation,
1858 ret = __exec_query(query);
1860 _LOGD("Package UiApp Splash Screen DB Insert Failed");
1863 memset(query, '\0', MAX_QUERY_LEN);
1871 static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
1875 const char *pv = NULL;
1876 char query[MAX_QUERY_LEN] = { '\0' };
1879 const char *auth_name = NULL;
1880 const char *auth_email = NULL;
1881 const char *auth_href = NULL;
1883 GList *pkglocale = NULL;
1884 GList *applocale = NULL;
1885 GList *appicon = NULL;
1886 GList *appimage = NULL;
1888 if (mfx->author && mfx->author->data) {
1889 author = (author_x *)mfx->author->data;
1891 auth_name = author->text;
1893 auth_email = author->email;
1895 auth_href = author->href;
1898 /*Insert in the package_info DB*/
1899 sqlite3_snprintf(MAX_QUERY_LEN, query,
1900 "INSERT INTO package_info(" \
1901 "package, package_type, package_version, package_api_version, package_tep_name, package_zip_mount_file, " \
1902 "install_location, package_size, package_removable, package_preload, package_readonly, " \
1903 "package_update, package_appsetting, package_nodisplay, package_system, author_name, " \
1904 "author_email, author_href, installed_time, installed_storage, storeclient_id, " \
1905 "mainapp_id, package_url, root_path, csc_path, package_support_disable) " \
1907 "%Q, %Q, %Q, %Q, %Q, %Q, " \
1908 "%Q, %Q, LOWER(%Q), LOWER(%Q), LOWER(%Q), " \
1909 "LOWER(%Q), LOWER(%Q), LOWER(%Q), LOWER(%Q), %Q, " \
1910 "%Q, %Q, %Q, %Q, %Q, " \
1911 "%Q, %Q, %Q, %Q, LOWER(%Q))",
1912 mfx->package, mfx->type, mfx->version, mfx->api_version, mfx->tep_name, mfx->zip_mount_file,
1913 mfx->installlocation, mfx->package_size, __get_bool(mfx->removable, true), __get_bool(mfx->preload, false), __get_bool(mfx->readonly, false),
1914 __get_bool(mfx->update, false), __get_bool(mfx->appsetting, false), __get_bool(mfx->nodisplay_setting, false), __get_bool(mfx->system, false), auth_name,
1915 auth_email, auth_href, mfx->installed_time, mfx->installed_storage,
1916 mfx->storeclient_id,
1917 mfx->mainapp_id, mfx->package_url, mfx->root_path, mfx->csc_path, __get_bool(mfx->support_disable, false));
1919 ret = __exec_query(query);
1921 _LOGD("Package Info DB Insert Failed\n");
1925 /*Insert in the package_privilege_info DB*/
1926 for (tmp = mfx->privileges; tmp; tmp = tmp->next) {
1927 pv = (const char *)tmp->data;
1930 memset(query, '\0', MAX_QUERY_LEN);
1931 sqlite3_snprintf(MAX_QUERY_LEN, query,
1932 "INSERT INTO package_privilege_info(package, privilege) " \
1935 ret = __exec_query(query);
1937 _LOGD("Package Privilege Info DB Insert Failed\n");
1942 if (mfx->application != NULL) {
1943 ret = __insert_mainapp_info(mfx);
1948 /*Insert the package locale*/
1949 pkglocale = __create_locale_list(pkglocale, mfx->label, mfx->license, mfx->icon, mfx->description, mfx->author);
1950 /*remove duplicated data in pkglocale*/
1951 __trimfunc(pkglocale);
1953 /*Insert the app locale, icon, image info */
1954 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1955 app = (application_x *)tmp->data;
1958 applocale = __create_locale_list(applocale, app->label, NULL, app->icon, NULL, NULL);
1959 appicon = __create_icon_list(appicon, app->icon);
1960 appimage = __create_image_list(appimage, app->image);
1962 /*remove duplicated data in applocale*/
1963 __trimfunc(applocale);
1964 __trimfunc(appicon);
1965 __trimfunc(appimage);
1967 g_list_foreach(pkglocale, __insert_pkglocale_info, (gpointer)mfx);
1969 /*native app locale info*/
1970 for (tmp = mfx->application; tmp; tmp = tmp->next) {
1971 app = (application_x *)tmp->data;
1974 g_list_foreach(applocale, __insert_application_locale_info, (gpointer)app);
1975 g_list_foreach(appicon, __insert_application_icon_section_info, (gpointer)app);
1976 g_list_foreach(appimage, __insert_application_image_info, (gpointer)app);
1979 g_list_free(pkglocale);
1981 g_list_free(applocale);
1983 g_list_free(appicon);
1985 g_list_free(appimage);
1988 /*Insert in the package_app_info DB*/
1989 ret = __insert_application_info(mfx);
1992 /*Insert in the package_app_app_control DB*/
1993 ret = __insert_application_appcontrol_info(mfx);
1997 /*Insert in the package_app_app_category DB*/
1998 ret = __insert_application_appcategory_info(mfx);
2002 /*Insert in the package_app_app_metadata DB*/
2003 ret = __insert_application_appmetadata_info(mfx);
2007 /*Insert in the package_app_app_permission DB*/
2008 ret = __insert_application_apppermission_info(mfx);
2012 /*Insert in the package_app_share_allowed DB*/
2013 ret = __insert_application_share_allowed_info(mfx);
2017 /*Insert in the package_app_share_request DB*/
2018 ret = __insert_application_share_request_info(mfx);
2022 /*Insert in the package_app_data_control DB*/
2023 ret = __insert_application_datacontrol_info(mfx);
2027 /*Insert in the package_app_splash_screen DB (backward compatibility)*/
2028 ret = __insert_application_legacy_splashscreen_info(mfx);
2032 /*Insert in the package_app_splash_screen DB (backward compatibility)*/
2033 ret = __insert_application_metadata_splashscreen_info(mfx);
2037 /*Insert in the package_app_splash_screen DB*/
2038 ret = __insert_application_splashscreen_info(mfx);
2046 static int __delete_appinfo_from_db(char *db_table, const char *appid)
2048 char query[MAX_QUERY_LEN] = { '\0' };
2051 sqlite3_snprintf(MAX_QUERY_LEN, query,
2052 "DELETE FROM %q where app_id=%Q", db_table, appid);
2053 ret = __exec_query(query);
2055 _LOGD("DB Deletion from table (%s) Failed\n", db_table);
2061 static int __delete_subpkg_info_from_db(char *appid)
2065 ret = __delete_appinfo_from_db("package_app_info", appid);
2068 ret = __delete_appinfo_from_db("package_app_localized_info", appid);
2071 ret = __delete_appinfo_from_db("package_app_icon_section_info", appid);
2074 ret = __delete_appinfo_from_db("package_app_image_info", appid);
2077 ret = __delete_appinfo_from_db("package_app_app_control", appid);
2080 ret = __delete_appinfo_from_db("package_app_app_category", appid);
2083 ret = __delete_appinfo_from_db("package_app_app_metadata", appid);
2086 ret = __delete_appinfo_from_db("package_app_app_permission", appid);
2089 ret = __delete_appinfo_from_db("package_app_share_allowed", appid);
2092 ret = __delete_appinfo_from_db("package_app_share_request", appid);
2095 ret = __delete_appinfo_from_db("package_app_data_control", appid);
2098 ret = __delete_appinfo_from_db("package_app_splash_screen", appid);
2105 static int __delete_subpkg_from_db(manifest_x *mfx)
2107 char query[MAX_QUERY_LEN] = { '\0' };
2108 char *error_message = NULL;
2110 sqlite3_snprintf(MAX_QUERY_LEN, query, "SELECT app_id FROM package_app_info WHERE package=%Q", mfx->package);
2112 sqlite3_exec(pkgmgr_parser_db, query, __delete_subpkg_list_cb, NULL, &error_message)) {
2113 _LOGE("Don't execute query = %s error message = %s\n", query,
2115 sqlite3_free(error_message);
2118 sqlite3_free(error_message);
2123 static int __delete_manifest_info_from_db(manifest_x *mfx, uid_t uid)
2125 char query[MAX_QUERY_LEN] = { '\0' };
2129 /*Delete from cert table*/
2130 ret = pkgmgrinfo_delete_certinfo(mfx->package);
2132 _LOGD("Cert Info DB Delete Failed\n");
2136 /*Delete from Package Info DB*/
2137 sqlite3_snprintf(MAX_QUERY_LEN, query,
2138 "DELETE FROM package_info WHERE package=%Q", mfx->package);
2139 ret = __exec_query(query);
2141 _LOGD("Package Info DB Delete Failed\n");
2144 memset(query, '\0', MAX_QUERY_LEN);
2146 /*Delete from Package Localized Info*/
2147 sqlite3_snprintf(MAX_QUERY_LEN, query,
2148 "DELETE FROM package_localized_info WHERE package=%Q", mfx->package);
2149 ret = __exec_query(query);
2151 _LOGD("Package Localized Info DB Delete Failed\n");
2155 /*Delete from Package Privilege Info*/
2156 sqlite3_snprintf(MAX_QUERY_LEN, query,
2157 "DELETE FROM package_privilege_info WHERE package=%Q", mfx->package);
2158 ret = __exec_query(query);
2160 _LOGD("Package Privilege Info DB Delete Failed\n");
2164 for (tmp = mfx->application; tmp; tmp = tmp->next) {
2165 app = (application_x *)tmp->data;
2168 ret = __delete_appinfo_from_db("package_app_info", app->appid);
2171 ret = __delete_appinfo_from_db("package_app_localized_info", app->appid);
2174 ret = __delete_appinfo_from_db("package_app_icon_section_info", app->appid);
2177 ret = __delete_appinfo_from_db("package_app_image_info", app->appid);
2180 ret = __delete_appinfo_from_db("package_app_app_control", app->appid);
2183 ret = __delete_appinfo_from_db("package_app_app_category", app->appid);
2186 ret = __delete_appinfo_from_db("package_app_app_metadata", app->appid);
2189 ret = __delete_appinfo_from_db("package_app_app_permission", app->appid);
2192 ret = __delete_appinfo_from_db("package_app_share_allowed", app->appid);
2195 ret = __delete_appinfo_from_db("package_app_share_request", app->appid);
2198 ret = __delete_appinfo_from_db("package_app_data_control", app->appid);
2201 ret = __delete_appinfo_from_db("package_app_splash_screen", app->appid);
2206 /* if main package has sub pkg, delete sub pkg data*/
2207 __delete_subpkg_from_db(mfx);
2212 static int __disable_app(const char *appid)
2215 char query[MAX_QUERY_LEN] = {'\0'};
2216 sqlite3_snprintf(MAX_QUERY_LEN, query,
2217 "UPDATE package_app_info SET app_disable='true' WHERE app_id=%Q",
2219 ret = __exec_query(query);
2221 _LOGD("Insert global app disable failed\n");
2226 static int __enable_app(const char *appid)
2229 char query[MAX_QUERY_LEN] = {'\0'};
2230 sqlite3_snprintf(MAX_QUERY_LEN, query,
2231 "UPDATE package_app_info SET app_disable='false' WHERE app_id=%Q",
2233 ret = __exec_query(query);
2235 _LOGD("Insert global app disable failed\n");
2240 static int __check_appinfo_for_uid_table(const char *appid, uid_t uid)
2243 char query[MAX_QUERY_LEN] = { '\0', };
2245 const char *val = NULL;
2250 sqlite3_snprintf(MAX_QUERY_LEN, query,
2251 "SELECT COUNT(*) FROM "
2252 "package_app_info_for_uid WHERE app_id=%Q "
2253 "AND uid=%d", appid, (int)uid);
2255 ret = sqlite3_prepare_v2(pkgmgr_parser_db, query, strlen(query), &stmt, NULL);
2256 if (ret != SQLITE_OK) {
2257 LOGE("prepare failed: %s", sqlite3_errmsg(pkgmgr_parser_db));
2258 return PMINFO_R_ERROR;
2261 if (sqlite3_step(stmt) != SQLITE_ROW) {
2262 LOGE("failed to step");
2263 sqlite3_finalize(stmt);
2264 return PMINFO_R_ERROR;
2267 val = (const char *)sqlite3_column_text(stmt, 0);
2269 sqlite3_finalize(stmt);
2274 static int __disable_global_app_for_user(const char *appid, uid_t uid)
2277 char query[MAX_QUERY_LEN] = { '\0', };
2279 ret = __check_appinfo_for_uid_table(appid, uid);
2281 _LOGE("Failed to check package_app_info_for_uid with appid[%s], uid[%d]",
2284 } else if (ret == 0) {
2285 sqlite3_snprintf(MAX_QUERY_LEN, query, "INSERT INTO "
2286 "package_app_info_for_uid(app_id, uid, is_disabled, is_splash_screen_enabled) "
2287 "VALUES(%Q, %d, 'true', "
2288 "(SELECT app_splash_screen_display FROM package_app_info WHERE appid='%Q'))",
2289 appid, (int)uid, appid);
2291 sqlite3_snprintf(MAX_QUERY_LEN, query, "UPDATE "
2292 "package_app_info_for_uid SET is_disabled='true' "
2293 "WHERE app_id=%Q AND uid=%d", appid, (int)uid);
2296 ret = __exec_query(query);
2298 _LOGD("Add global app disable info failed\n");
2303 static int __enable_global_app_for_user(const char *appid, uid_t uid)
2306 char query[MAX_QUERY_LEN] = {'\0'};
2308 ret = __check_appinfo_for_uid_table(appid, uid);
2310 _LOGE("Failed to check package_app_info_for_uid with appid[%s], uid[%d]",
2313 } else if (ret > 0) {
2314 sqlite3_snprintf(MAX_QUERY_LEN, query,
2315 "UPDATE package_app_info_for_uid SET "
2316 "is_disabled='false' WHERE app_id=%Q AND "
2317 "uid=%d", appid, (int)uid);
2320 ret = __exec_query(query);
2322 _LOGD("Remove global app disable info failed\n");
2327 static int __update_global_app_splash_screen_for_user(const char *appid,
2328 uid_t uid, int flag)
2331 char query[MAX_QUERY_LEN] = { '\0', };
2333 ret = __check_appinfo_for_uid_table(appid, uid);
2335 _LOGE("Failed to check package_app_info_for_uid with appid[%s], uid[%d]",
2338 } else if (ret == 0) {
2339 sqlite3_snprintf(MAX_QUERY_LEN, query, "INSERT INTO "
2340 "package_app_info_for_uid(app_id, uid, is_splash_screen_enabled) "
2341 "VALUES(%Q, %d, %Q)", appid, (int)uid,
2342 flag ? "true" : "false");
2344 sqlite3_snprintf(MAX_QUERY_LEN, query,
2345 "UPDATE package_app_info_for_uid SET "
2346 "is_splash_screen_enabled=%Q WHERE app_id=%Q AND "
2347 "uid=%d", flag ? "true" : "false", appid, (int)uid);
2350 ret = __exec_query(query);
2352 _LOGD("update global app splash screen info failed\n");
2357 static int __disable_app_splash_screen(const char *appid)
2360 char query[MAX_QUERY_LEN] = {'\0'};
2362 sqlite3_snprintf(MAX_QUERY_LEN, query,
2363 "UPDATE package_app_info SET app_splash_screen_display='false' WHERE app_id=%Q",
2365 ret = __exec_query(query);
2367 _LOGD("Failed to update app_palsh_screen_display");
2372 static int __enable_app_splash_screen(const char *appid)
2375 char query[MAX_QUERY_LEN] = {'\0'};
2377 sqlite3_snprintf(MAX_QUERY_LEN, query,
2378 "UPDATE package_app_info SET app_splash_screen_display='true' WHERE app_id=%Q",
2380 ret = __exec_query(query);
2382 _LOGD("Failed to update app_splash_screen_display");
2387 API int pkgmgr_parser_initialize_db(uid_t uid)
2391 char query[MAX_QUERY_LEN];
2392 static const char *columns[] = {
2393 "author_root_cert", "author_im_cert", "author_signer_cert",
2394 "dist_root_cert", "dist_im_cert", "dist_signer_cert",
2395 "dist2_root_cert", "dist2_im_cert", "dist2_signer_cert",
2399 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
2401 _LOGD("package info DB initialization failed\n");
2404 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO);
2406 _LOGD("package localized info DB initialization failed\n");
2409 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_PRIVILEGE_INFO);
2411 _LOGD("package app app privilege DB initialization failed\n");
2414 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO);
2416 _LOGD("package app info DB initialization failed\n");
2419 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_LOCALIZED_INFO);
2421 _LOGD("package app localized info DB initialization failed\n");
2424 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_ICON_SECTION_INFO);
2426 _LOGD("package app icon localized info DB initialization failed\n");
2429 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_IMAGE_INFO);
2431 _LOGD("package app image info DB initialization failed\n");
2434 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CONTROL);
2436 _LOGD("package app app control DB initialization failed\n");
2439 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY);
2441 _LOGD("package app app category DB initialization failed\n");
2444 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_METADATA);
2446 _LOGD("package app app category DB initialization failed\n");
2449 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_PERMISSION);
2451 _LOGD("package app app permission DB initialization failed\n");
2454 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
2456 _LOGD("package app share allowed DB initialization failed\n");
2459 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_REQUEST);
2461 _LOGD("package app share request DB initialization failed\n");
2464 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_DATA_CONTROL);
2466 _LOGD("package app data control DB initialization failed\n");
2470 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_INFO_FOR_UID);
2472 _LOGD("package_app_info_for_uid for user DB initialization failed\n");
2476 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SPLASH_SCREEN);
2478 _LOGD("package app splash screen DB initialization failed\n");
2482 /* Trigger package_app_info_for_uid */
2483 ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TRIGGER_UPDATE_PACKAGE_APP_INFO_FOR_UID);
2485 _LOGD("package app info for uid DB initialization failed\n");
2490 /* TODO: refactor this code */
2491 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
2493 _LOGD("package cert info DB initialization failed\n");
2496 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO);
2498 _LOGD("package cert index info DB initialization failed\n");
2501 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_DELETE_CERT_INFO);
2503 _LOGD("package cert info DB initialization failed\n");
2506 ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_UPDATE_CERT_INDEX_INFO);
2508 _LOGD("package cert index info DB initialization failed\n");
2511 for (i = 0; columns[i] != NULL; i++) {
2512 snprintf(query, sizeof(query),
2513 QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT,
2514 columns[i], columns[i], columns[i]);
2515 ret = __initialize_db(pkgmgr_cert_db, query);
2517 _LOGD("package cert index info DB initialization failed\n");
2522 if( 0 != __parserdb_change_perm(getUserPkgCertDBPathUID(GLOBAL_USER), GLOBAL_USER)) {
2523 _LOGD("Failed to change cert db permission\n");
2525 if( 0 != __parserdb_change_perm(getUserPkgParserDBPathUID(uid), uid)) {
2526 _LOGD("Failed to change parser db permission\n");
2532 static int __parserdb_change_perm(const char *db_file, uid_t uid)
2535 char pwuid_buf[1024];
2536 char journal_file[BUFSIZE];
2541 struct passwd userinfo, *result = NULL;
2542 files[0] = (char *)db_file;
2543 files[1] = journal_file;
2547 if (db_file == NULL)
2550 if (getuid() != OWNER_ROOT) //At this time we should be root to apply this
2552 snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
2553 if (uid == OWNER_ROOT)
2555 ret = getpwuid_r(uid, &userinfo, pwuid_buf, sizeof(pwuid_buf), &result);
2556 if (ret != 0 || result == NULL) {
2557 _LOGE("FAIL: user %d doesn't exist", uid);
2560 snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
2562 for (i = 0; files[i]; i++) {
2563 fd = open(files[i], O_RDONLY);
2565 if (strerror_r(errno, buf, sizeof(buf)))
2566 strncpy(buf, "", BUFSIZE - 1);
2567 _LOGD("FAIL : open %s : %s", files[i], buf);
2570 ret = fstat(fd, &sb);
2572 if (strerror_r(errno, buf, sizeof(buf)))
2573 strncpy(buf, "", BUFSIZE - 1);
2574 _LOGD("FAIL : fstat %s : %s", files[i], buf);
2578 if (S_ISLNK(sb.st_mode)) {
2579 _LOGE("FAIL : %s is symlink!", files[i]);
2583 ret = fchown(fd, uid, userinfo.pw_gid);
2585 if (strerror_r(errno, buf, sizeof(buf)))
2586 strncpy(buf, "", BUFSIZE - 1);
2587 _LOGD("FAIL : fchown %s %d.%d : %s", files[i], uid,
2588 userinfo.pw_gid, buf);
2593 mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
2594 if (!strcmp(db_file, getUserPkgCertDBPathUID(GLOBAL_USER)))
2596 ret = fchmod(fd, mode);
2598 if (strerror_r(errno, buf, sizeof(buf)))
2599 strncpy(buf, "", BUFSIZE - 1);
2600 _LOGD("FAIL : fchmod %s 0664 : %s", files[i], buf);
2605 SET_SMACK_LABEL(files[i]);
2610 API int pkgmgr_parser_create_and_initialize_db(uid_t uid)
2614 if (getuid() != OWNER_ROOT) {
2615 _LOGE("Only root user is allowed");
2619 if (access(getUserPkgParserDBPathUID(uid), F_OK) != -1) {
2620 _LOGE("Manifest db for user %d is already exists", uid);
2624 if (access(getUserPkgCertDBPathUID(uid), F_OK) != -1) {
2625 _LOGE("Cert db for user %d is already exists", uid);
2629 ret = pkgmgr_parser_check_and_create_db(uid);
2632 ret = pkgmgr_parser_initialize_db(uid);
2634 pkgmgr_parser_close_db();
2637 pkgmgr_parser_close_db();
2642 API int pkgmgr_parser_check_and_create_db(uid_t uid)
2646 ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, getUserPkgParserDBPathUID(uid));
2648 _LOGD("Manifest DB creation Failed\n");
2653 ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, getUserPkgCertDBPathUID(GLOBAL_USER));
2655 _LOGD("Cert DB creation Failed\n");
2661 void pkgmgr_parser_close_db(void)
2663 sqlite3_close(pkgmgr_parser_db);
2664 sqlite3_close(pkgmgr_cert_db);
2668 API int pkgmgr_parser_insert_manifest_info_in_db(manifest_x *mfx)
2670 _LOGD("pkgmgr_parser_insert_manifest_info_in_db\n");
2672 _LOGD("manifest pointer is NULL\n");
2676 ret = pkgmgr_parser_check_and_create_db(GLOBAL_USER);
2678 _LOGD("Failed to open DB\n");
2681 ret = pkgmgr_parser_initialize_db(GLOBAL_USER);
2684 /*Begin transaction*/
2685 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2686 if (ret != SQLITE_OK) {
2687 _LOGD("Failed to begin transaction\n");
2691 _LOGD("Transaction Begin\n");
2692 ret = __insert_manifest_info_in_db(mfx, GLOBAL_USER);
2694 _LOGD("Insert into DB failed. Rollback now\n");
2695 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2698 /*Commit transaction*/
2699 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2700 if (ret != SQLITE_OK) {
2701 _LOGD("Failed to commit transaction. Rollback now\n");
2702 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2706 _LOGD("Transaction Commit and End\n");
2708 pkgmgr_parser_close_db();
2712 API int pkgmgr_parser_insert_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
2714 _LOGD("pkgmgr_parser_insert_manifest_info_in_usr_db\n");
2716 _LOGD("manifest pointer is NULL\n");
2720 ret = pkgmgr_parser_check_and_create_db(uid);
2722 _LOGD("Failed to open DB\n");
2725 ret = pkgmgr_parser_initialize_db(uid);
2728 /*Begin transaction*/
2729 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2730 if (ret != SQLITE_OK) {
2731 _LOGD("Failed to begin transaction\n");
2735 _LOGD("Transaction Begin\n");
2736 ret = __insert_manifest_info_in_db(mfx, uid);
2738 _LOGD("Insert into DB failed. Rollback now\n");
2739 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2742 /*Commit transaction*/
2743 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2744 if (ret != SQLITE_OK) {
2745 _LOGD("Failed to commit transaction. Rollback now\n");
2746 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2750 _LOGD("Transaction Commit and End\n");
2752 pkgmgr_parser_close_db();
2756 API int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path)
2758 return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, _getuid());
2761 API int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid)
2763 if (pkgid == NULL || tep_path == NULL) {
2764 _LOGE("invalid parameter");
2771 ret = pkgmgr_parser_check_and_create_db(uid);
2773 _LOGD("Failed to open DB\n");
2776 ret = pkgmgr_parser_initialize_db(uid);
2780 /*Begin transaction*/
2781 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2782 if (ret != SQLITE_OK) {
2783 _LOGD("Failed to begin transaction\n");
2787 _LOGD("Transaction Begin\n");
2790 /* Updating TEP info in "package_info" table */
2791 query = sqlite3_mprintf("UPDATE package_info "\
2792 "SET package_tep_name = %Q "\
2793 "WHERE package = %Q", tep_path, pkgid);
2795 ret = __exec_query(query);
2796 sqlite3_free(query);
2797 if (ret != SQLITE_OK) {
2798 ret = PM_PARSER_R_ERROR;
2799 _LOGE("sqlite exec failed to insert entries into package_info!!");
2803 /* Updating TEP info in "package_app_info" table */
2804 query = sqlite3_mprintf("UPDATE package_app_info "\
2805 "SET app_tep_name = %Q "\
2806 "WHERE package = %Q", tep_path, pkgid);
2808 ret = __exec_query(query);
2809 sqlite3_free(query);
2810 if (ret != SQLITE_OK) {
2811 ret = PM_PARSER_R_ERROR;
2812 _LOGE("sqlite exec failed to insert entries into package_app_info!!");
2816 /*Commit transaction*/
2817 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2818 if (ret != SQLITE_OK) {
2819 _LOGE("Failed to commit transaction, Rollback now\n");
2820 ret = sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2821 if (ret != SQLITE_OK)
2822 _LOGE("Failed to Rollback\n");
2824 ret = PM_PARSER_R_ERROR;
2827 _LOGD("Transaction Commit and End\n");
2828 ret = PM_PARSER_R_OK;
2831 pkgmgr_parser_close_db();
2836 API int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
2839 _LOGD("manifest pointer is NULL\n");
2843 ret = pkgmgr_parser_check_and_create_db(uid);
2845 _LOGD("Failed to open DB\n");
2848 ret = pkgmgr_parser_initialize_db(uid);
2851 /*Preserve guest mode visibility*/
2852 __preserve_guestmode_visibility_value( mfx);
2853 /*Begin transaction*/
2854 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2855 if (ret != SQLITE_OK) {
2856 _LOGD("Failed to begin transaction\n");
2860 _LOGD("Transaction Begin\n");
2861 ret = __delete_manifest_info_from_db(mfx, uid);
2863 _LOGD("Delete from DB failed. Rollback now\n");
2864 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2867 ret = __insert_manifest_info_in_db(mfx, uid);
2869 _LOGD("Insert into DB failed. Rollback now\n");
2870 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2874 /*Commit transaction*/
2875 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2876 if (ret != SQLITE_OK) {
2877 _LOGD("Failed to commit transaction. Rollback now\n");
2878 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2882 _LOGD("Transaction Commit and End\n");
2884 pkgmgr_parser_close_db();
2888 API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
2890 return pkgmgr_parser_update_manifest_info_in_usr_db(mfx, _getuid());
2893 API int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid)
2896 _LOGD("manifest pointer is NULL\n");
2900 ret = pkgmgr_parser_check_and_create_db(uid);
2902 _LOGD("Failed to open DB\n");
2905 /*Begin transaction*/
2906 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2907 if (ret != SQLITE_OK) {
2908 _LOGD("Failed to begin transaction\n");
2912 _LOGD("Transaction Begin\n");
2913 ret = __delete_manifest_info_from_db(mfx, uid);
2915 _LOGD("Delete from DB failed. Rollback now\n");
2916 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2919 /*Commit transaction*/
2920 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2921 if (ret != SQLITE_OK) {
2922 _LOGD("Failed to commit transaction, Rollback now\n");
2923 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2927 _LOGD("Transaction Commit and End\n");
2929 pkgmgr_parser_close_db();
2933 API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
2935 return pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, _getuid());
2938 API int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable)
2942 ret = pkgmgr_parser_check_and_create_db(GLOBAL_USER);
2944 _LOGD("Failed to open DB\n");
2948 /*Begin transaction*/
2949 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2950 if (ret != SQLITE_OK) {
2951 _LOGD("Failed to begin transaction\n");
2955 _LOGD("Transaction Begin\n");
2957 ret = __disable_global_app_for_user(appid, uid);
2959 ret = __enable_global_app_for_user(appid, uid);
2961 _LOGD("__update_global_app_disable_condition_in_db failed. Rollback now\n");
2962 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2965 /*Commit transaction*/
2966 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
2967 if (ret != SQLITE_OK) {
2968 _LOGD("Failed to commit transaction, Rollback now\n");
2969 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
2973 _LOGD("Transaction Commit and End\n");
2975 pkgmgr_parser_close_db();
2980 API int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable)
2982 return pkgmgr_parser_update_app_disable_info_in_usr_db(appid, _getuid(), is_disable);
2985 API int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable)
2989 ret = pkgmgr_parser_check_and_create_db(uid);
2991 _LOGD("Failed to open DB\n");
2995 /*Begin transaction*/
2996 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
2997 if (ret != SQLITE_OK) {
2998 _LOGD("Failed to begin transaction\n");
3002 _LOGD("Transaction Begin\n");
3004 ret = __disable_app(appid);
3006 ret = __enable_app(appid);
3008 _LOGD("__update_app_disable_condition_in_db failed. Rollback now\n");
3009 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3012 /*Commit transaction*/
3013 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
3014 if (ret != SQLITE_OK) {
3015 _LOGD("Failed to commit transaction, Rollback now\n");
3016 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3020 _LOGD("Transaction Commit and End\n");
3022 pkgmgr_parser_close_db();
3027 API int pkgmgr_parser_update_global_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
3031 if (appid == NULL) {
3032 _LOGD("Invalid parameter");
3036 ret = pkgmgr_parser_check_and_create_db(GLOBAL_USER);
3038 _LOGD("Failed to open DB\n");
3042 /* Begin transaction */
3043 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
3044 if (ret != SQLITE_OK) {
3045 _LOGD("Failed to begin transaction\n");
3049 _LOGD("Transaction Begin\n");
3051 ret = __update_global_app_splash_screen_for_user(appid, uid, flag);
3053 _LOGD("__update_splash_screen_disable_condition_in_db failed. Rollback now\n");
3054 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3057 /* Commit transaction */
3058 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
3059 if (ret != SQLITE_OK) {
3060 _LOGD("Failed to commit transaction, Rollback now\n");
3061 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3065 _LOGD("Transaction Commit and End\n");
3067 pkgmgr_parser_close_db();
3071 API int pkgmgr_parser_update_app_splash_screen_display_info_in_db(const char *appid, int flag)
3073 return pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(appid, _getuid(), flag);
3076 API int pkgmgr_parser_update_app_splash_screen_display_info_in_usr_db(const char *appid, uid_t uid, int flag)
3080 if (appid == NULL) {
3081 _LOGD("Invalid parameter");
3085 ret = pkgmgr_parser_check_and_create_db(uid);
3087 _LOGD("Failed to open DB");
3091 /* Begin transaction */
3092 ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
3093 if (ret != SQLITE_OK) {
3094 _LOGD("Failed to begin transaction");
3098 _LOGD("Transaction Begin");
3101 ret = __enable_app_splash_screen(appid);
3103 ret = __disable_app_splash_screen(appid);
3105 _LOGD("__update_app_splash_screen_condition_in_db. Rollback now");
3106 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3109 /* Commit transaction */
3110 ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
3111 if (ret != SQLITE_OK) {
3112 _LOGD("Failed to commit transaction, Rollback now");
3113 sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
3117 _LOGD("Transaction Commit and End");
3120 pkgmgr_parser_close_db();