*
*/
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db-util.h>
#include <glib.h>
+#include <system_info.h>
+
/* For multi-user support */
#include <tzplatform_config.h>
#define BUFSIZE 4096
#define OWNER_ROOT 0
+#define LDPI "ldpi"
+#define MDPI "mdpi"
+#define HDPI "hdpi"
+#define XHDPI "xhdpi"
+#define XXHDPI "xxhdpi"
+
+#define LDPI_MIN 0
+#define LDPI_MAX 240
+#define MDPI_MIN 241
+#define MDPI_MAX 300
+#define HDPI_MIN 301
+#define HDPI_MAX 380
+#define XHDPI_MIN 381
+#define XHDPI_MAX 480
+#define XXHDPI_MIN 481
+#define XXHDPI_MAX 600
+
#define DB_LABEL "User::Home"
#define SET_SMACK_LABEL(x) \
do { \
#define QUERY_CREATE_TABLE_PACKAGE_INFO "create table if not exists package_info " \
"(package text primary key not null, " \
- "package_type text DEFAULT 'rpm', " \
+ "package_type text DEFAULT 'tpk', " \
"package_version text, " \
"package_api_version text, " \
+ "package_tep_name text, " \
"install_location text, " \
"package_size text, " \
"package_removable text DEFAULT 'true', " \
"package_url text," \
"root_path text," \
"csc_path text," \
- "package_support_disable text DEFAULT 'false')"
+ "package_support_disable text DEFAULT 'false', " \
+ "package_disable text DEFAULT 'false')"
#define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
"(package text not null, " \
"app_preload text DEFAULT 'false', " \
"app_submode text DEFAULT 'false', " \
"app_submode_mainid text, " \
+ "app_installed_storage text, " \
+ "app_process_pool text DEFAULT 'false', " \
"app_launch_mode text NOT NULL DEFAULT 'caller', " \
"app_ui_gadget text DEFAULT 'false', " \
"app_support_disable text DEFAULT 'false', " \
+ "app_disable text DEFAULT 'false', " \
+ "app_package_type text DEFAULT 'tpk', " \
"component_type text, " \
"package text not null, " \
+ "app_tep_name text, " \
+ "app_background_category INTEGER DEFAULT 0, " \
+ "app_root_path text, " \
+ "app_api_version text, " \
+ "app_effective_appid text, " \
+ "app_splash_screen_display text DEFAULT 'true', " \
"FOREIGN KEY(package) " \
"REFERENCES package_info(package) " \
"ON DELETE CASCADE)"
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
-#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC "create table if not exists package_app_app_svc " \
- "(app_id text not null, " \
- "operation text not null, " \
- "uri_scheme text, " \
- "mime_type text, " \
- "subapp_name text, " \
- "PRIMARY KEY(app_id,operation,uri_scheme,mime_type,subapp_name) " \
- "FOREIGN KEY(app_id) " \
- "REFERENCES package_app_info(app_id) " \
- "ON DELETE CASCADE)"
-
#define QUERY_CREATE_TABLE_PACKAGE_APP_APP_CATEGORY "create table if not exists package_app_app_category " \
"(app_id text not null, " \
"category text not null, " \
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
-#define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO "create table if not exists package_cert_index_info " \
- "(cert_info text not null, " \
- "cert_id integer, " \
- "cert_ref_count integer, " \
- "PRIMARY KEY(cert_id)) "
-
-#define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO "create table if not exists package_cert_info " \
- "(package text not null, " \
- "author_root_cert integer, " \
- "author_im_cert integer, " \
- "author_signer_cert integer, " \
- "dist_root_cert integer, " \
- "dist_im_cert integer, " \
- "dist_signer_cert integer, " \
- "dist2_root_cert integer, " \
- "dist2_im_cert integer, " \
- "dist2_signer_cert integer, " \
- "PRIMARY KEY(package)) "
+/* FIXME: duplicated at pkgmgrinfo_db.c */
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INDEX_INFO \
+ "CREATE TABLE IF NOT EXISTS package_cert_index_info( " \
+ " cert_info TEXT UNIQUE, " \
+ " cert_id INTEGER PRIMARY KEY, " \
+ " cert_ref_count INTEGER NOT NULL)"
+
+#define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO \
+ "CREATE TABLE IF NOT EXISTS package_cert_info( " \
+ " package TEXT PRIMARY KEY, " \
+ " author_root_cert INTEGER, " \
+ " author_im_cert INTEGER, " \
+ " author_signer_cert INTEGER, " \
+ " dist_root_cert INTEGER, " \
+ " dist_im_cert INTEGER, " \
+ " dist_signer_cert INTEGER, " \
+ " dist2_root_cert INTEGER, " \
+ " dist2_im_cert INTEGER, " \
+ " dist2_signer_cert INTEGER)"
+
+#define QUERY_CREATE_TRIGGER_DELETE_CERT_INFO \
+ "CREATE TRIGGER IF NOT EXISTS delete_cert_info " \
+ "AFTER DELETE ON package_cert_info " \
+ "BEGIN" \
+ " UPDATE package_cert_index_info SET" \
+ " cert_ref_count = cert_ref_count - 1" \
+ " WHERE cert_id = OLD.author_root_cert" \
+ " OR cert_id = OLD.author_im_cert" \
+ " OR cert_id = OLD.author_signer_cert" \
+ " OR cert_id = OLD.dist_root_cert" \
+ " OR cert_id = OLD.dist_im_cert" \
+ " OR cert_id = OLD.dist_signer_cert" \
+ " OR cert_id = OLD.dist2_root_cert" \
+ " OR cert_id = OLD.dist2_im_cert" \
+ " OR cert_id = OLD.dist2_signer_cert;" \
+ "END;"
+
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INDEX_INFO \
+ "CREATE TRIGGER IF NOT EXISTS update_cert_index_info " \
+ "AFTER UPDATE ON package_cert_index_info " \
+ "WHEN ((SELECT cert_ref_count FROM package_cert_index_info " \
+ " WHERE cert_id = OLD.cert_id) = 0) "\
+ "BEGIN" \
+ " DELETE FROM package_cert_index_info WHERE cert_id = OLD.cert_id;" \
+ "END;"
+
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT \
+ "CREATE TRIGGER IF NOT EXISTS update_%s_info " \
+ "AFTER UPDATE ON package_cert_info " \
+ "WHEN (OLD.%s IS NOT NULL) " \
+ "BEGIN" \
+ " UPDATE package_cert_index_info SET" \
+ " cert_ref_count = cert_ref_count - 1" \
+ " WHERE cert_id = OLD.%s;" \
+ "END;"
#define QUERY_CREATE_TABLE_PACKAGE_APP_DATA_CONTROL "create table if not exists package_app_data_control " \
"(app_id text not null, " \
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
+#define QUERY_CREATE_TABLE_PACKAGE_APP_DISABLE_FOR_USER "CREATE TABLE IF NOT EXISTS package_app_disable_for_user " \
+ "(app_id text not null, " \
+ "uid text not null, " \
+ "PRIMARY KEY(app_id, uid))"
+
+#define QUERY_CREATE_TABLE_PACKAGE_APP_SPLASH_SCREEN \
+ "create table if not exists package_app_splash_screen " \
+ "(app_id text not null, " \
+ "src text not null, " \
+ "type text not null, " \
+ "orientation text not null, " \
+ "indicatordisplay text, " \
+ "operation text, " \
+ "PRIMARY KEY(app_id, orientation, operation) " \
+ "FOREIGN KEY(app_id) " \
+ "REFERENCES package_app_info(app_id) " \
+ "ON DELETE CASCADE)"
+
static int __insert_application_info(manifest_x *mfx);
-static int __insert_application_appsvc_info(manifest_x *mfx);
static int __insert_application_appcategory_info(manifest_x *mfx);
static int __insert_application_appcontrol_info(manifest_x *mfx);
static int __insert_application_appmetadata_info(manifest_x *mfx);
static int __pkgmgr_parser_create_db(sqlite3 **db_handle, const char *db_path);
static int __parserdb_change_perm(const char *db_file, uid_t uid);
+#define REGULAR_USER 5000
+static inline uid_t _getuid(void)
+{
+ uid_t uid = getuid();
+
+ if (uid < REGULAR_USER)
+ return tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ else
+ return uid;
+}
+
static int __delete_subpkg_list_cb(void *data, int ncols, char **coltxt, char **colname)
{
if (coltxt[0])
}
}
if (appid == NULL) {
+ if(status != NULL)
+ free(status);
_LOGD("app id is NULL\n");
return -1;
}
char *error_message = NULL;
if (SQLITE_OK !=
sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n", query,
+ _LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
return -1;
}
-static GList *__create_icon_list(GList *locale, GList *icns)
+static GList *__create_icon_list(GList *appicon, GList *icns)
{
GList *tmp;
icon_x *icn;
if (icn == NULL)
continue;
if (icn->section)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)icn->section, __comparefunc, NULL);
+ appicon = g_list_insert_sorted_with_data(appicon, (gpointer)icn->section, __comparefunc, NULL);
}
- return locale;
+ return appicon;
}
-static GList *__create_image_list(GList *locale, GList *imgs)
+static GList *__create_image_list(GList *appimage, GList *imgs)
{
GList *tmp;
image_x *img;
if (img == NULL)
continue;
if (img->section)
- locale = g_list_insert_sorted_with_data(locale, (gpointer)img->section, __comparefunc, NULL);
+ appimage = g_list_insert_sorted_with_data(appimage, (gpointer)img->section, __comparefunc, NULL);
}
- return locale;
+ return appimage;
}
static void __trimfunc(GList* trim_list)
return 0;
}
+static int __check_dpi(const char *dpi_char, int dpi_int)
+{
+ if (dpi_char == NULL)
+ return -1;
+
+ if (strcasecmp(dpi_char, LDPI) == 0) {
+ if (dpi_int >= LDPI_MIN && dpi_int <= LDPI_MAX)
+ return 0;
+ else
+ return -1;
+ } else if (strcasecmp(dpi_char, MDPI) == 0) {
+ if (dpi_int >= MDPI_MIN && dpi_int <= MDPI_MAX)
+ return 0;
+ else
+ return -1;
+ } else if (strcasecmp(dpi_char, HDPI) == 0) {
+ if (dpi_int >= HDPI_MIN && dpi_int <= HDPI_MAX)
+ return 0;
+ else
+ return -1;
+ } else if (strcasecmp(dpi_char, XHDPI) == 0) {
+ if (dpi_int >= XHDPI_MIN && dpi_int <= XHDPI_MAX)
+ return 0;
+ else
+ return -1;
+ } else if (strcasecmp(dpi_char, XXHDPI) == 0) {
+ if (dpi_int >= XXHDPI_MIN && dpi_int <= XXHDPI_MAX)
+ return 0;
+ else
+ return -1;
+ } else
+ return -1;
+}
+
+static gint __check_icon_folder(const char *orig_icon_path, char **new_icon_path)
+{
+ char *dpi_path[2];
+ char *icon_filename = NULL;
+ char modified_iconpath[BUFSIZE] = { '\0' };
+ char icon_path[BUFSIZE] = { '\0' };
+ int i;
+ int dpi = -1;
+
+ if (orig_icon_path == NULL)
+ return -1;
+
+ system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
+ if (!dpi)
+ return -1;
+
+ if (dpi >= LDPI_MIN && dpi <= LDPI_MAX) {
+ dpi_path[0] = "LDPI";
+ dpi_path[1] = "ldpi";
+ } else if (dpi >= MDPI_MIN && dpi <= MDPI_MAX) {
+ dpi_path[0] = "MDPI";
+ dpi_path[1] = "mdpi";
+ } else if (dpi >= HDPI_MIN && dpi <= HDPI_MAX) {
+ dpi_path[0] = "HDPI";
+ dpi_path[1] = "hdpi";
+ } else if (dpi >= XHDPI_MIN && dpi <= XHDPI_MAX) {
+ dpi_path[0] = "XHDPI";
+ dpi_path[1] = "xhdpi";
+ } else if (dpi >= XXHDPI_MIN && dpi <= XXHDPI_MAX) {
+ dpi_path[0] = "XXHDPI";
+ dpi_path[1] = "xxhdpi";
+ } else {
+ _LOGE("Unidentified dpi[%d]", dpi);
+ return -1;
+ }
+
+ icon_filename = strrchr(orig_icon_path, '/');
+ if (icon_filename == NULL)
+ return -1;
+
+ snprintf(icon_path, strlen(orig_icon_path) - (strlen(icon_filename) - 1), "%s", orig_icon_path);
+ for (i = 0; i < 2; i++) {
+ snprintf(modified_iconpath, BUFSIZE - 1, "%s/%s%s", icon_path, dpi_path[i], icon_filename);
+ if (access(modified_iconpath, F_OK) != -1) {
+ // if exists, return modified icon path
+ *new_icon_path = strdup(modified_iconpath);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static gint __compare_icon(gconstpointer a, gconstpointer b)
+{
+ icon_x *icon = (icon_x *)a;
+
+ char *icon_folder_path = NULL;
+
+ if (icon->lang != NULL && strcasecmp(icon->lang, DEFAULT_LOCALE) != 0)
+ return -1;
+
+ if (icon->dpi != NULL)
+ return -1;
+
+ if (__check_icon_folder(icon->text, &icon_folder_path) == 0) {
+ free(icon->text);
+ icon->text = icon_folder_path;
+ }
+
+ return 0;
+}
+
+static gint __compare_icon_with_dpi(gconstpointer a, gconstpointer b)
+{
+ icon_x *icon = (icon_x *)a;
+ int dpi = GPOINTER_TO_INT(b);
+
+ if (icon->lang != NULL && strcasecmp(icon->lang, DEFAULT_LOCALE) != 0)
+ return -1;
+
+ if (icon->dpi == NULL)
+ return -1;
+
+ if (__check_dpi(icon->dpi, dpi) == 0)
+ return 0;
+
+ return -1;
+}
+
+static gint __compare_icon_with_lang(gconstpointer a, gconstpointer b)
+{
+ icon_x *icon = (icon_x *)a;
+ char *lang = (char *)b;
+ char *icon_folder_path = NULL;
+
+ if (icon->dpi != NULL)
+ return -1;
+
+ if (strcasecmp(icon->lang, lang) == 0) {
+ if (strcasecmp(icon->lang, DEFAULT_LOCALE) == 0) {
+ //icon for no locale. check existance of folder-hierachied default icons
+ if (__check_icon_folder(icon->text, &icon_folder_path) == 0) {
+ free(icon->text);
+ icon->text = icon_folder_path;
+ }
+ }
+ return 0;
+ }
+
+ return -1;
+}
+
+static gint __compare_icon_with_lang_dpi(gconstpointer a, gconstpointer b)
+{
+ icon_x *icon = (icon_x *)a;
+ char *lang = (char *)b;
+ int dpi = -1;
+
+ system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
+ if (!dpi)
+ return -1;
+
+ if (strcasecmp(icon->lang, lang) == 0 && __check_dpi(icon->dpi, dpi) == 0)
+ return 0;
+
+ return -1;
+}
+
+static char *__find_icon(GList *icons, const char *lang)
+{
+ GList *tmp;
+ icon_x *icon = NULL;
+ int dpi = 0;
+
+ // first, find icon whose locale and dpi with given lang and system's dpi has matched
+ tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang_dpi);
+ if (tmp != NULL) {
+ icon = (icon_x *)tmp->data;
+ return (char *)icon->text;
+ }
+
+ // if first has failed, find icon whose locale has matched
+ tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang);
+ if (tmp != NULL) {
+ icon = (icon_x *)tmp->data;
+ return (char *)icon->text;
+ }
+
+ // if second has failed, find icon whose dpi has matched with system's dpi
+ system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
+ if (!dpi)
+ return NULL;
+ tmp = g_list_find_custom(icons, GINT_TO_POINTER(dpi), (GCompareFunc)__compare_icon_with_dpi);
+ if (tmp != NULL) {
+ icon = (icon_x *)tmp->data;
+ return (char *)icon->text;
+ }
+
+ // last, find default icon marked as "No Locale"
+ tmp = g_list_find_custom(icons, NULL, (GCompareFunc)__compare_icon);
+ if (tmp != NULL) {
+ icon = (icon_x *)tmp->data;
+ return (char *)icon->text;
+ }
+
+ return NULL;
+}
+
static void __extract_data(gpointer data, GList *lbls, GList *lcns, GList *icns, GList *dcns, GList *aths,
char **label, char **license, char **icon, char **description, char **author)
{
GList *tmp;
label_x *lbl;
license_x *lcn;
- icon_x *icn;
description_x *dcn;
author_x *ath;
for (tmp = lbls; tmp; tmp = tmp->next) {
}
}
}
- for (tmp = icns; tmp; tmp = tmp->next) {
- icn = (icon_x *)tmp->data;
- if (icn == NULL)
- continue;
- if (icn->lang) {
- if (strcmp(icn->lang, (char *)data) == 0) {
- *icon = (char*)icn->text;
- break;
- }
- }
- }
+
+ *icon = __find_icon(icns, (char *)data);
+
for (tmp = dcns; tmp; tmp = tmp->next) {
dcn = (description_x *)tmp->data;
if (dcn == NULL)
char *description = NULL;
char *license = NULL;
char *author = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
+ char *query = NULL;
manifest_x *mfx = (manifest_x *)userdata;
GList *lbl = mfx->label;
if (!label && !description && !icon && !license && !author)
return;
- sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
+ query = sqlite3_mprintf("insert into package_localized_info(package, package_locale, " \
"package_label, package_icon, package_description, package_license, package_author) values " \
- "('%q', '%q', '%q', '%q', '%s', '%s', '%s')",
+ "(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
mfx->package,
(char*)data,
- label,
- icon,
+ __get_str(label),
+ __get_str(icon),
__get_str(description),
__get_str(license),
__get_str(author));
ret = __exec_query(query);
if (ret == -1)
_LOGD("Package Localized Info DB Insert failed\n");
+
+ sqlite3_free(query);
}
static void __insert_application_locale_info(gpointer data, gpointer userdata)
int ret = -1;
char *label = NULL;
char *icon = NULL;
- char query[MAX_QUERY_LEN] = {'\0'};
+ char *query = NULL;
application_x *app = (application_x*)userdata;
GList *lbl = app->label;
__extract_data(data, lbl, NULL, icn, NULL, NULL, &label, NULL, &icon, NULL, NULL);
if (!label && !icon)
return;
- sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_app_localized_info(app_id, app_locale, " \
+
+ query = sqlite3_mprintf("insert into package_app_localized_info(app_id, app_locale, " \
"app_label, app_icon) values " \
- "('%q', '%q', '%q', '%q')", app->appid, (char*)data,
- label, icon);
+ "(%Q, %Q, %Q, %Q)", app->appid, (char*)data,
+ __get_str(label), __get_str(icon));
ret = __exec_query(query);
if (ret == -1)
_LOGD("Package UiApp Localized Info DB Insert failed\n");
+ sqlite3_free(query);
+
/*insert ui app locale info to pkg locale to get mainapp data */
if (strcasecmp(app->mainapp, "true")==0) {
- sqlite3_snprintf(MAX_QUERY_LEN, query, "insert into package_localized_info(package, package_locale, " \
+ query = sqlite3_mprintf("insert into package_localized_info(package, package_locale, " \
"package_label, package_icon, package_description, package_license, package_author) values " \
- "('%q', '%q', '%q', '%q', '%q', '%q', '%q')",
+ "(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
app->package,
(char*)data,
- label,
- icon,
+ __get_str(label),
+ __get_str(icon),
PKGMGR_PARSER_EMPTY_STR,
PKGMGR_PARSER_EMPTY_STR,
PKGMGR_PARSER_EMPTY_STR);
ret = __exec_query_no_msg(query);
+ sqlite3_free(query);
if (icon != NULL) {
- sqlite3_snprintf(MAX_QUERY_LEN, query, "update package_localized_info set package_icon='%s' "\
- "where package='%s' and package_locale='%s'", icon, app->package, (char*)data);
+ query = sqlite3_mprintf("update package_localized_info set package_icon=%Q "\
+ "where package=%Q and package_locale=%Q", icon, app->package, (char*)data);
ret = __exec_query_no_msg(query);
+ sqlite3_free(query);
}
}
}
return 0;
}
+
+static int __convert_background_category(GList *category_list)
+{
+ int ret = 0;
+ GList *tmp_list = category_list;
+ char *category_data = NULL;
+
+ if (category_list == NULL)
+ return 0;
+
+ while (tmp_list != NULL) {
+ category_data = (char *)tmp_list->data;
+ if (strcmp(category_data, APP_BG_CATEGORY_MEDIA_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_MEDIA_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_DOWNLOAD_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_DOWNLOAD_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_BGNETWORK_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_BGNETWORK_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_LOCATION_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_LOCATION_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_SENSOR_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_SENSOR_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_IOTCOMM_STR) == 0) {
+ ret = ret | APP_BG_CATEGORY_IOTCOMM_VAL;
+ } else if (strcmp(category_data, APP_BG_CATEGORY_SYSTEM) == 0) {
+ ret = ret | APP_BG_CATEGORY_SYSTEM_VAL;
+ } else {
+ _LOGE("Unidentified category [%s]", category_data);
+ }
+ tmp_list = g_list_next(tmp_list);
+ }
+
+ return ret;
+}
+
+static const char *__find_effective_appid(GList *metadata_list)
+{
+ GList *tmp_list;
+ metadata_x *md;
+
+ for (tmp_list = metadata_list; tmp_list; tmp_list = tmp_list->next) {
+ md = (metadata_x *)tmp_list->data;
+ if (md == NULL || md->key == NULL)
+ continue;
+
+ if (strcmp(md->key, "http://tizen.org/metadata/effective-appid") == 0) {
+ if (md->value)
+ return md->value;
+ }
+ }
+
+ return NULL;
+}
+
/* _PRODUCT_LAUNCHING_ENHANCED_
* app->indicatordisplay, app->portraitimg, app->landscapeimg, app->guestmode_appstatus
*/
GList *tmp;
application_x *app;
int ret = -1;
+ int background_value = 0;
char query[MAX_QUERY_LEN] = {'\0'};
+ char *type = NULL;
+ const char *effective_appid;
+
+ if (mfx->type)
+ type = strdup(mfx->type);
+ else
+ type = strdup("tpk");
+
for (tmp = mfx->application; tmp; tmp = tmp->next) {
app = (application_x *)tmp->data;
if (app == NULL)
continue;
+
+ background_value = __convert_background_category(app->background_category);
+ if (background_value < 0) {
+ _LOGE("Failed to retrieve background value[%d]", background_value);
+ background_value = 0;
+ }
+
+ effective_appid = __find_effective_appid(app->metadata);
+
snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
- "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_screenreader, app_mainapp , app_recentimage, " \
- "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\
- "app_preload, app_submode, app_submode_mainid, app_launch_mode, app_ui_gadget, app_support_disable, component_type, package) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- app->appid,
- app->component_type,
- app->exec,
- app->nodisplay,
- app->type,
- app->onboot,
- app->multiple,
- app->autorestart,
- app->taskmanage,
- app->enabled,
- app->hwacceleration,
- app->screenreader,
- app->mainapp,
- __get_str(app->recentimage),
- app->launchcondition,
- app->indicatordisplay,
- __get_str(app->portraitimg),
- __get_str(app->landscapeimg),
- app->guestmode_visibility,
- app->permission_type,
- mfx->preload,
- app->submode,
- __get_str(app->submode_mainid),
- app->launch_mode,
- app->ui_gadget,
- mfx->support_disable,
- app->component_type,
- mfx->package);
+ "insert into package_app_info(" \
+ "app_id, app_component, app_exec, app_nodisplay, app_type, " \
+ "app_onboot, app_multiple, app_autorestart, app_taskmanage, app_enabled, " \
+ "app_hwacceleration, app_screenreader, app_mainapp, app_recentimage, app_launchcondition, " \
+ "app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, " \
+ "app_preload, app_submode, app_submode_mainid, app_installed_storage, app_process_pool, " \
+ "app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, " \
+ "app_tep_name, app_background_category, app_package_type, app_root_path, app_api_version, " \
+ "app_effective_appid, app_splash_screen_display) " \
+ "values(" \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%d', '%s', '%s', '%s', " \
+ "'%s', '%s')", \
+ app->appid, app->component_type, app->exec, app->nodisplay, app->type,
+ app->onboot, app->multiple, app->autorestart, app->taskmanage, app->enabled,
+ app->hwacceleration, app->screenreader, app->mainapp, __get_str(app->recentimage), app->launchcondition,
+ app->indicatordisplay, __get_str(app->portraitimg), __get_str(app->landscapeimg),
+ app->guestmode_visibility, app->permission_type,
+ mfx->preload, app->submode, __get_str(app->submode_mainid), mfx->installed_storage, app->process_pool,
+ app->launch_mode, app->ui_gadget, mfx->support_disable, app->component_type, mfx->package,
+ __get_str(mfx->tep_name), background_value, type, mfx->root_path, __get_str(mfx->api_version),
+ __get_str(effective_appid), app->splash_screen_display);
ret = __exec_query(query);
if (ret == -1) {
_LOGD("Package UiApp Info DB Insert Failed\n");
+ if (type)
+ free(type);
return -1;
}
memset(query, '\0', MAX_QUERY_LEN);
}
+
+ if (type)
+ free(type);
+
return 0;
}
return 0;
}
-/* FIXME: should be changed to app_control */
-static int __insert_application_appsvc_info(manifest_x *mfx)
-{
- GList *app_tmp;
- application_x *app;
- GList *asvc_tmp;
- appsvc_x *asvc;
- int ret = -1;
- char query[MAX_QUERY_LEN] = {'\0'};
- for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
- app = (application_x *)app_tmp->data;
- if (app == NULL)
- continue;
- for (asvc_tmp = app->appsvc; asvc_tmp; asvc_tmp = asvc_tmp->next) {
- asvc = (appsvc_x *)asvc_tmp->data;
- if (asvc == NULL)
- continue;
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_app_svc(app_id, operation, uri_scheme, mime_type, subapp_name) " \
- "values('%s', '%s', '%s', '%s', '%s')",\
- app->appid,
- asvc->operation,
- __get_str(asvc->uri),
- __get_str(asvc->mime),
- __get_str(asvc->subapp));
-
- ret = __exec_query(query);
- if (ret == -1) {
- _LOGD("Package UiApp AppSvc DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- }
- }
- return 0;
-}
-
static int __insert_application_datacontrol_info(manifest_x *mfx)
{
GList *app_tmp;
return 0;
}
-static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
+static gint __compare_splashscreen_with_orientation_dpi(gconstpointer a, gconstpointer b)
{
- GList *tmp;
- application_x *app;
- const char *pv = NULL;
- char query[MAX_QUERY_LEN] = { '\0' };
- int ret = -1;
- author_x *author;
- const char *auth_name = NULL;
- const char *auth_email = NULL;
- const char *auth_href = NULL;
-
- GList *pkglocale = NULL;
- GList *applocale = NULL;
- GList *appicon = NULL;
- GList *appimage = NULL;
+ splashscreen_x *ss = (splashscreen_x *)a;
+ const char *orientation = (const char *)b;
+ int dpi = -1;
- if (mfx->author && mfx->author->data) {
- author = (author_x *)mfx->author->data;
- if (author->text)
- auth_name = author->text;
- if (author->email)
- auth_email = author->email;
- if (author->href)
- auth_href = author->href;
- }
- /*Insert in the package_cert_info CERT_DB*/
- pkgmgrinfo_instcertinfo_h cert_handle = NULL;
- ret = pkgmgrinfo_set_cert_value(&cert_handle, PMINFO_SET_AUTHOR_ROOT_CERT, "author root certificate");
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_destroy_certinfo_set_handle(cert_handle);
- _LOGE("Cert Info DB create handle failed\n");
+ if (ss->operation || ss->dpi == NULL)
return -1;
- }
- ret = pkgmgrinfo_save_certinfo(mfx->package, &cert_handle, uid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_destroy_certinfo_set_handle(cert_handle);
- _LOGE("Cert Info DB Insert Failed\n");
+
+ system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
+ if (!dpi)
return -1;
- }
- /*Insert in the package_info DB*/
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_info(package, package_type, package_version, package_api_version, install_location, package_size, " \
- "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, package_system," \
- "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path, package_support_disable) " \
- "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
- mfx->package,
- mfx->type,
- mfx->version,
- __get_str(mfx->api_version),
- __get_str(mfx->installlocation),
- __get_str(mfx->package_size),
- mfx->removable,
- mfx->preload,
- mfx->readonly,
- mfx->update,
- mfx->appsetting,
- mfx->nodisplay_setting,
- mfx->system,
- __get_str(auth_name),
- __get_str(auth_email),
- __get_str(auth_href),
- mfx->installed_time,
- mfx->installed_storage,
- __get_str(mfx->storeclient_id),
- mfx->mainapp_id,
- __get_str(mfx->package_url),
- mfx->root_path,
- __get_str(mfx->csc_path),
- mfx->support_disable);
+ if (strcasecmp(ss->orientation, orientation) == 0 && __check_dpi(ss->dpi, dpi) == 0)
+ return 0;
- ret = __exec_query(query);
- if (ret == -1) {
- _LOGD("Package Info DB Insert Failed\n");
+ return -1;
+}
+
+static gint __compare_splashscreen_with_orientation(gconstpointer a, gconstpointer b)
+{
+ splashscreen_x *ss = (splashscreen_x *)a;
+ const char *orientation = (const char *)b;
+
+ if (ss->operation || ss->dpi)
return -1;
- }
- /*Insert in the package_privilege_info DB*/
- for (tmp = mfx->privileges; tmp; tmp = tmp->next) {
- pv = (const char *)tmp->data;
- if (pv == NULL)
- continue;
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_privilege_info(package, privilege) " \
- "values('%s','%s')",\
- mfx->package, pv);
- ret = __exec_query(query);
- if (ret == -1) {
- _LOGD("Package Privilege Info DB Insert Failed\n");
- return -1;
- }
- }
+ if (strcasecmp(ss->orientation, orientation) == 0)
+ return 0;
- if (mfx->application != NULL) {
- ret = __insert_mainapp_info(mfx);
- if (ret == -1)
- return -1;
- }
+ return -1;
+}
- /*Insert the package locale*/
- pkglocale = __create_locale_list(pkglocale, mfx->label, mfx->license, mfx->icon, mfx->description, mfx->author);
- /*remove duplicated data in pkglocale*/
- __trimfunc(pkglocale);
+static splashscreen_x *__find_default_splashscreen(GList *splashscreens,
+ const char *orientation)
+{
+ GList *tmp;
- /*Insert the app locale, icon, image info */
- for (tmp = mfx->application; tmp; tmp = tmp->next) {
- app = (application_x *)tmp->data;
- if (app == NULL)
- continue;
- applocale = __create_locale_list(applocale, app->label, NULL, app->icon, NULL, NULL);
- appicon = __create_icon_list(appicon, app->icon);
- appimage = __create_image_list(appimage, app->image);
+ tmp = g_list_find_custom(splashscreens, orientation,
+ (GCompareFunc)__compare_splashscreen_with_orientation_dpi);
+ if (tmp)
+ return (splashscreen_x *)tmp->data;
+
+ tmp = g_list_find_custom(splashscreens, orientation,
+ (GCompareFunc)__compare_splashscreen_with_orientation);
+ if (tmp)
+ return (splashscreen_x *)tmp->data;
+
+ return NULL;
+}
+
+static void __find_appcontrol_splashscreen_with_dpi(gpointer data, gpointer user_data)
+{
+ splashscreen_x *ss = (splashscreen_x *)data;
+ GList **list = (GList **)user_data;
+ int dpi = -1;
+
+ if (ss->operation == NULL || ss->dpi == NULL)
+ return;
+
+ system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
+ if (!dpi)
+ return;
+
+ if (__check_dpi(ss->dpi, dpi) != 0)
+ return;
+
+ *list = g_list_append(*list, ss);
+}
+
+static void __find_appcontrol_splashscreen(gpointer data, gpointer user_data)
+{
+ splashscreen_x *ss = (splashscreen_x *)data;
+ GList **list = (GList **)user_data;
+ splashscreen_x *ss_tmp;
+ GList *tmp;
+
+ if (ss->operation == NULL || ss->dpi)
+ return;
+
+ for (tmp = *list; tmp; tmp = tmp->next) {
+ ss_tmp = (splashscreen_x *)tmp->data;
+ if (ss_tmp->operation
+ && strcmp(ss_tmp->operation, ss->operation) == 0
+ && strcmp(ss_tmp->orientation, ss->orientation) == 0)
+ return;
+ }
+
+ *list = g_list_append(*list, ss);
+}
+
+static GList *__find_splashscreens(GList *splashscreens)
+{
+ GList *list = NULL;
+ splashscreen_x *ss;
+
+ g_list_foreach(splashscreens,
+ __find_appcontrol_splashscreen_with_dpi, &list);
+ g_list_foreach(splashscreens,
+ __find_appcontrol_splashscreen, &list);
+
+ ss = __find_default_splashscreen(splashscreens, "portrait");
+ if (ss)
+ list = g_list_append(list, ss);
+ ss = __find_default_splashscreen(splashscreens, "landscape");
+ if (ss)
+ list = g_list_append(list, ss);
+
+ return list;
+}
+
+static int __insert_application_splashscreen_info(manifest_x *mfx)
+{
+ GList *app_tmp;
+ application_x *app;
+ GList *ss_tmp;
+ splashscreen_x *ss;
+ GList *tmp;
+ int ret = -1;
+ char query[MAX_QUERY_LEN];
+
+ for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
+ app = (application_x *)app_tmp->data;
+ if (app == NULL || app->splashscreens == NULL)
+ continue;
+
+ ss_tmp = __find_splashscreens(app->splashscreens);
+ if (ss_tmp == NULL)
+ continue;
+
+ for (tmp = ss_tmp; tmp; tmp = tmp->next) {
+ ss = (splashscreen_x *)tmp->data;
+ snprintf(query, sizeof(query),
+ "insert into package_app_splash_screen" \
+ "(app_id, src, type, orientation, indicatordisplay, operation) " \
+ "values('%s', '%s', '%s', '%s', '%s', '%s')",
+ app->appid, ss->src, ss->type, ss->orientation,
+ ss->indicatordisplay, __get_str(ss->operation));
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp Splash Screen DB Insert Failed");
+ return -1;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ g_list_free(ss_tmp);
+ }
+ return 0;
+}
+
+static int __insert_application_legacy_splashscreen_info(manifest_x *mfx)
+{
+ GList *app_tmp;
+ application_x *app;
+ int ret = -1;
+ char query[MAX_QUERY_LEN];
+ char *tmp;
+ const char *image_type;
+ const char *indicatordisplay;
+ const char *orientation;
+ const char *operation = NULL;
+
+ for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
+ app = (application_x *)app_tmp->data;
+ if (app == NULL ||
+ (app->portraitimg == NULL && app->landscapeimg == NULL))
+ continue;
+ image_type = "img"; /* default */
+ if (app->effectimage_type) {
+ tmp = strstr(app->effectimage_type, "edj");
+ if (tmp)
+ image_type = "edj";
+ }
+ indicatordisplay = "true"; /* default */
+ if (app->indicatordisplay)
+ indicatordisplay = app->indicatordisplay;
+ if (app->portraitimg) {
+ orientation = "portrait";
+ snprintf(query, sizeof(query),
+ "insert into package_app_splash_screen" \
+ "(app_id, src, type, orientation, indicatordisplay, operation) " \
+ "values('%s', '%s', '%s', '%s', '%s', '%s')",
+ app->appid, app->portraitimg, image_type,
+ orientation, indicatordisplay, __get_str(operation));
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp Splash Screen DB Insert Failed");
+ return -1;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ if (app->landscapeimg) {
+ orientation = "landscape";
+ snprintf(query, sizeof(query),
+ "insert into package_app_splash_screen" \
+ "(app_id, src, type, orientation, indicatordisplay, operation) " \
+ "values('%s', '%s', '%s', '%s', '%s', '%s')",
+ app->appid, app->landscapeimg, image_type,
+ orientation, indicatordisplay, __get_str(operation));
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp Splash Screen DB Insert Failed");
+ return -1;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ }
+ return 0;
+}
+
+static int __insert_application_metadata_splashscreen_info(manifest_x *mfx)
+{
+ GList *app_tmp;
+ application_x *app;
+ GList *md_tmp;
+ metadata_x *md;
+ int ret;
+ char query[MAX_QUERY_LEN];
+ char *token;
+ char *tmpptr = NULL;
+ const char *operation;
+ const char *portraitimg;
+ const char *landscapeimg;
+ const char *indicatordisplay;
+ const char *orientation;
+ const char *image_type;
+
+ for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
+ app = (application_x *)app_tmp->data;
+ if (app == NULL)
+ continue;
+
+ for (md_tmp = app->metadata; md_tmp; md_tmp = md_tmp->next) {
+ md = (metadata_x *)md_tmp->data;
+ if (md == NULL || md->key == NULL || md->value == NULL)
+ continue;
+
+ if (strcasestr(md->key, "operation_effect=")) {
+ operation = index(md->key, '=');
+ if ((operation + 1) != NULL)
+ operation++;
+ else
+ operation = NULL;
+ } else if (strcasestr(md->key, "launch_effect")) {
+ operation = NULL;
+ } else {
+ continue;
+ }
+
+ portraitimg = NULL;
+ landscapeimg = NULL;
+ indicatordisplay = "true"; /* default */
+ token = strtok_r(md->value, "|", &tmpptr);
+ while (token != NULL) {
+ if (strcasestr(token, "portrait-effectimage=")) {
+ portraitimg = index(token, '=');
+ if ((portraitimg + 1) != NULL)
+ portraitimg++;
+ else
+ portraitimg = NULL;
+ } else if (strcasestr(token, "landscape-effectimage=")) {
+ landscapeimg = index(token, '=');
+ if ((landscapeimg + 1) != NULL)
+ landscapeimg++;
+ else
+ landscapeimg = NULL;
+ } else if (strcasestr(token, "indicatordisplay=")) {
+ indicatordisplay = index(token, '=');
+ if ((indicatordisplay + 1) != NULL)
+ indicatordisplay++;
+ else
+ indicatordisplay = "true";
+ }
+
+ token = strtok_r(NULL, "|", &tmpptr);
+ }
+
+ if (portraitimg) {
+ orientation = "portrait";
+ image_type = "img";
+ if (strcasestr(portraitimg, "edj"))
+ image_type = "edj";
+ snprintf(query, sizeof(query),
+ "insert into package_app_splash_screen" \
+ "(app_id, src, type, orientation, indicatordisplay, operation) " \
+ "values('%s', '%s', '%s', '%s', '%s', '%s')",
+ app->appid, portraitimg, image_type,
+ orientation, indicatordisplay, __get_str(operation));
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp Splash Screen DB Insert Failed");
+ return -1;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ if (landscapeimg) {
+ orientation = "landscape";
+ image_type = "img";
+ if (strcasestr(landscapeimg, "edj"))
+ image_type = "edj";
+ snprintf(query, sizeof(query),
+ "insert into package_app_splash_screen" \
+ "(app_id, src, type, orientation, indicatordisplay, operation) " \
+ "values('%s', '%s', '%s', '%s', '%s', '%s')",
+ app->appid, landscapeimg, image_type,
+ orientation, indicatordisplay, __get_str(operation));
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp Splash Screen DB Insert Failed");
+ return -1;
+ }
+ memset(query, '\0', MAX_QUERY_LEN);
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int __insert_manifest_info_in_db(manifest_x *mfx, uid_t uid)
+{
+ GList *tmp;
+ application_x *app;
+ const char *pv = NULL;
+ char query[MAX_QUERY_LEN] = { '\0' };
+ int ret = -1;
+ author_x *author;
+ const char *auth_name = NULL;
+ const char *auth_email = NULL;
+ const char *auth_href = NULL;
+
+ GList *pkglocale = NULL;
+ GList *applocale = NULL;
+ GList *appicon = NULL;
+ GList *appimage = NULL;
+
+ if (mfx->author && mfx->author->data) {
+ author = (author_x *)mfx->author->data;
+ if (author->text)
+ auth_name = author->text;
+ if (author->email)
+ auth_email = author->email;
+ if (author->href)
+ auth_href = author->href;
+ }
+
+ /*Insert in the package_cert_info CERT_DB*/
+ pkgmgrinfo_instcertinfo_h cert_handle = NULL;
+ ret = pkgmgrinfo_set_cert_value(&cert_handle, PMINFO_SET_AUTHOR_ROOT_CERT, "author root certificate");
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_destroy_certinfo_set_handle(cert_handle);
+ _LOGE("Cert Info DB create handle failed\n");
+ return -1;
+ }
+ ret = pkgmgrinfo_save_certinfo(mfx->package, &cert_handle, uid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_destroy_certinfo_set_handle(cert_handle);
+ _LOGE("Cert Info DB Insert Failed\n");
+ return -1;
+ }
+
+ /*Insert in the package_info DB*/
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into package_info(" \
+ "package, package_type, package_version, package_api_version, package_tep_name, " \
+ "install_location, package_size, package_removable, package_preload, package_readonly, " \
+ "package_update, package_appsetting, package_nodisplay, package_system, author_name, " \
+ "author_email, author_href, installed_time, installed_storage, storeclient_id, " \
+ "mainapp_id, package_url, root_path, csc_path, package_support_disable) " \
+ "values(" \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s', " \
+ "'%s', '%s', '%s', '%s', '%s')", \
+ mfx->package, mfx->type, mfx->version, __get_str(mfx->api_version), __get_str(mfx->tep_name),
+ __get_str(mfx->installlocation), __get_str(mfx->package_size), mfx->removable, mfx->preload, mfx->readonly,
+ mfx->update, mfx->appsetting, mfx->nodisplay_setting, mfx->system, __get_str(auth_name),
+ __get_str(auth_email), __get_str(auth_href), mfx->installed_time, mfx->installed_storage,
+ __get_str(mfx->storeclient_id),
+ mfx->mainapp_id, __get_str(mfx->package_url), mfx->root_path, __get_str(mfx->csc_path), mfx->support_disable);
+
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package Info DB Insert Failed\n");
+ return -1;
+ }
+
+ /*Insert in the package_privilege_info DB*/
+ for (tmp = mfx->privileges; tmp; tmp = tmp->next) {
+ pv = (const char *)tmp->data;
+ if (pv == NULL)
+ continue;
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into package_privilege_info(package, privilege) " \
+ "values('%s','%s')",\
+ mfx->package, pv);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package Privilege Info DB Insert Failed\n");
+ return -1;
+ }
+ }
+
+ if (mfx->application != NULL) {
+ ret = __insert_mainapp_info(mfx);
+ if (ret == -1)
+ return -1;
+ }
+
+ /*Insert the package locale*/
+ pkglocale = __create_locale_list(pkglocale, mfx->label, mfx->license, mfx->icon, mfx->description, mfx->author);
+ /*remove duplicated data in pkglocale*/
+ __trimfunc(pkglocale);
+
+ /*Insert the app locale, icon, image info */
+ for (tmp = mfx->application; tmp; tmp = tmp->next) {
+ app = (application_x *)tmp->data;
+ if (app == NULL)
+ continue;
+ applocale = __create_locale_list(applocale, app->label, NULL, app->icon, NULL, NULL);
+ appicon = __create_icon_list(appicon, app->icon);
+ appimage = __create_image_list(appimage, app->image);
}
/*remove duplicated data in applocale*/
__trimfunc(applocale);
if (ret == -1)
return -1;
- /*Insert in the package_app_app_svc DB*/
- ret = __insert_application_appsvc_info(mfx);
- if (ret == -1)
- return -1;
-
/*Insert in the package_app_share_allowed DB*/
ret = __insert_application_share_allowed_info(mfx);
if (ret == -1)
if (ret == -1)
return -1;
+ /*Insert in the package_app_splash_screen DB (backward compatibility)*/
+ ret = __insert_application_legacy_splashscreen_info(mfx);
+ if (ret == -1)
+ return -1;
+
+ /*Insert in the package_app_splash_screen DB (backward compatibility)*/
+ ret = __insert_application_metadata_splashscreen_info(mfx);
+ if (ret == -1)
+ return -1;
+
+ /*Insert in the package_app_splash_screen DB*/
+ ret = __insert_application_splashscreen_info(mfx);
+ if (ret == -1)
+ return -1;
+
return 0;
}
ret = __delete_appinfo_from_db("package_app_image_info", appid);
if (ret < 0)
return ret;
- ret = __delete_appinfo_from_db("package_app_app_svc", appid);
- if (ret < 0)
- return ret;
ret = __delete_appinfo_from_db("package_app_app_control", appid);
if (ret < 0)
return ret;
ret = __delete_appinfo_from_db("package_app_data_control", appid);
if (ret < 0)
return ret;
+ ret = __delete_appinfo_from_db("package_app_splash_screen", appid);
+ if (ret < 0)
+ return ret;
return 0;
}
GList *tmp;
application_x *app;
/*Delete from cert table*/
- if (uid != GLOBAL_USER)
- ret = pkgmgrinfo_delete_usr_certinfo(mfx->package, uid);
- else
- ret = pkgmgrinfo_delete_certinfo(mfx->package);
+ ret = pkgmgrinfo_delete_certinfo(mfx->package);
if (ret) {
_LOGD("Cert Info DB Delete Failed\n");
return -1;
ret = __delete_appinfo_from_db("package_app_image_info", app->appid);
if (ret < 0)
return ret;
- ret = __delete_appinfo_from_db("package_app_app_svc", app->appid);
- if (ret < 0)
- return ret;
ret = __delete_appinfo_from_db("package_app_app_control", app->appid);
if (ret < 0)
return ret;
ret = __delete_appinfo_from_db("package_app_data_control", app->appid);
if (ret < 0)
return ret;
+ ret = __delete_appinfo_from_db("package_app_splash_screen", app->appid);
+ if (ret < 0)
+ return ret;
}
/* if main package has sub pkg, delete sub pkg data*/
return 0;
}
+static int __disable_app(const char *appid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ sqlite3_snprintf(MAX_QUERY_LEN, query,
+ "UPDATE package_app_info set app_disable='true' where app_id=%Q",
+ appid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Insert global app disable failed\n");
+
+ return ret;
+}
+
+static int __enable_app(const char *appid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ sqlite3_snprintf(MAX_QUERY_LEN, query,
+ "UPDATE package_app_info set app_disable='false' where app_id=%Q",
+ appid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Insert global app disable failed\n");
+
+ return ret;
+}
+
+static int __disable_global_app_for_user(const char *appid, uid_t uid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+
+ sqlite3_snprintf(MAX_QUERY_LEN, query, "INSERT INTO " \
+ "package_app_disable_for_user(app_id, uid) VALUES(%Q, '%d')",
+ appid, (int)uid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Insert global app disable failed\n");
+
+ return ret;
+}
+
+static int __enable_global_app_for_user(const char *appid, uid_t uid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+
+ sqlite3_snprintf(MAX_QUERY_LEN, query, "DELETE FROM " \
+ "package_app_disable_for_user WHERE app_id=%Q AND uid='%d'",
+ appid, (int)uid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Delete global app disable failed\n");
+
+ return ret;
+}
+
static int __update_preload_condition_in_db()
{
int ret = -1;
API int pkgmgr_parser_initialize_db(uid_t uid)
{
int ret = -1;
+ int i;
+ char query[MAX_QUERY_LEN];
+ static const char *columns[] = {
+ "author_root_cert", "author_im_cert", "author_signer_cert",
+ "dist_root_cert", "dist_im_cert", "dist_signer_cert",
+ "dist2_root_cert", "dist2_im_cert", "dist2_signer_cert",
+ NULL};
+
/*Manifest DB*/
ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
if (ret == -1) {
_LOGD("package app app permission DB initialization failed\n");
return ret;
}
- ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_APP_SVC);
- if (ret == -1) {
- _LOGD("package app app svc DB initialization failed\n");
- return ret;
- }
ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SHARE_ALLOWED);
if (ret == -1) {
_LOGD("package app share allowed DB initialization failed\n");
_LOGD("package app data control DB initialization failed\n");
return ret;
}
+
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_DISABLE_FOR_USER);
+ if (ret == -1) {
+ _LOGD("package app disable for user DB initialization failed\n");
+ return ret;
+ }
+
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_SPLASH_SCREEN);
+ if (ret == -1) {
+ _LOGD("package app splash screen DB initialization failed\n");
+ return ret;
+ }
+
/*Cert DB*/
+ /* TODO: refactor this code */
ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
if (ret == -1) {
_LOGD("package cert info DB initialization failed\n");
_LOGD("package cert index info DB initialization failed\n");
return ret;
}
-
- if( 0 != __parserdb_change_perm(getUserPkgCertDBPathUID(uid), uid)) {
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_DELETE_CERT_INFO);
+ if (ret == -1) {
+ _LOGD("package cert info DB initialization failed\n");
+ return ret;
+ }
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_UPDATE_CERT_INDEX_INFO);
+ if (ret == -1) {
+ _LOGD("package cert index info DB initialization failed\n");
+ return ret;
+ }
+ for (i = 0; columns[i] != NULL; i++) {
+ snprintf(query, sizeof(query),
+ QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT,
+ columns[i], columns[i], columns[i]);
+ ret = __initialize_db(pkgmgr_cert_db, query);
+ if (ret == -1) {
+ _LOGD("package cert index info DB initialization failed\n");
+ return ret;
+ }
+ }
+
+ if( 0 != __parserdb_change_perm(getUserPkgCertDBPathUID(GLOBAL_USER), GLOBAL_USER)) {
_LOGD("Failed to change cert db permission\n");
}
if( 0 != __parserdb_change_perm(getUserPkgParserDBPathUID(uid), uid)) {
static int __parserdb_change_perm(const char *db_file, uid_t uid)
{
char buf[BUFSIZE];
+ char pwuid_buf[1024];
char journal_file[BUFSIZE];
char *files[3];
int ret, i;
- struct passwd *userinfo = NULL;
+ struct passwd userinfo, *result = NULL;
files[0] = (char *)db_file;
files[1] = journal_file;
files[2] = NULL;
+ mode_t mode;
if (db_file == NULL)
return -1;
snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
if (uid == OWNER_ROOT)
uid = GLOBAL_USER;
- userinfo = getpwuid(uid);
- if (!userinfo) {
+ ret = getpwuid_r(uid, &userinfo, pwuid_buf, sizeof(pwuid_buf), &result);
+ if (ret != 0 || result == NULL) {
_LOGE("FAIL: user %d doesn't exist", uid);
return -1;
}
snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
for (i = 0; files[i]; i++) {
- ret = chown(files[i], uid, userinfo->pw_gid);
+ ret = chown(files[i], uid, userinfo.pw_gid);
if (ret == -1) {
if (strerror_r(errno, buf, sizeof(buf)))
- strcpy(buf, "");
+ strncpy(buf, "", BUFSIZE - 1);
_LOGD("FAIL : chown %s %d.%d : %s", files[i], uid,
- userinfo->pw_gid, buf);
+ userinfo.pw_gid, buf);
return -1;
}
- ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
+ mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
+ if (!strcmp(db_file, getUserPkgCertDBPathUID(GLOBAL_USER)))
+ mode |= S_IWOTH;
+ ret = chmod(files[i], mode);
if (ret == -1) {
if (strerror_r(errno, buf, sizeof(buf)))
- strcpy(buf, "");
+ strncpy(buf, "", BUFSIZE - 1);
_LOGD("FAIL : chmod %s 0664 : %s", files[i], buf);
return -1;
}
}
/*Cert DB*/
- ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, getUserPkgCertDBPathUID(uid));
+ ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, getUserPkgCertDBPathUID(GLOBAL_USER));
if (ret) {
_LOGD("Cert DB creation Failed\n");
return -1;
return ret;
}
+API int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path)
+{
+ return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, _getuid());
+}
+
+API int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid)
+{
+ if (pkgid == NULL || tep_path == NULL) {
+ _LOGE("invalid parameter");
+ return -1;
+ }
+
+ int ret = -1;
+ char *query = NULL;
+
+ ret = pkgmgr_parser_check_and_create_db(uid);
+ if (ret == -1) {
+ _LOGD("Failed to open DB\n");
+ return ret;
+ }
+ ret = pkgmgr_parser_initialize_db(uid);
+ if (ret == -1)
+ goto err;
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to begin transaction\n");
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Begin\n");
+
+
+ /* Updating TEP info in "package_info" table */
+ query = sqlite3_mprintf("UPDATE package_info "\
+ "SET package_tep_name = %Q "\
+ "WHERE package = %Q", tep_path, pkgid);
+
+ ret = __exec_query(query);
+ sqlite3_free(query);
+ if (ret != SQLITE_OK) {
+ ret = PM_PARSER_R_ERROR;
+ _LOGE("sqlite exec failed to insert entries into package_info!!");
+ goto err;
+ }
+
+ /* Updating TEP info in "package_app_info" table */
+ query = sqlite3_mprintf("UPDATE package_app_info "\
+ "SET app_tep_name = %Q "\
+ "WHERE package = %Q", tep_path, pkgid);
+
+ ret = __exec_query(query);
+ sqlite3_free(query);
+ if (ret != SQLITE_OK) {
+ ret = PM_PARSER_R_ERROR;
+ _LOGE("sqlite exec failed to insert entries into package_app_info!!");
+ goto err;
+ }
+
+ /*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);
+ if (ret != SQLITE_OK)
+ _LOGE("Failed to Rollback\n");
+
+ ret = PM_PARSER_R_ERROR;
+ goto err;
+ }
+ _LOGD("Transaction Commit and End\n");
+ ret = PM_PARSER_R_OK;
+
+err:
+ pkgmgr_parser_close_db();
+ return ret;
+}
+
+
API int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
{
if (mfx == NULL) {
API int pkgmgr_parser_update_manifest_info_in_db(manifest_x *mfx)
{
- return pkgmgr_parser_update_manifest_info_in_usr_db(mfx, GLOBAL_USER);
+ return pkgmgr_parser_update_manifest_info_in_usr_db(mfx, _getuid());
}
API int pkgmgr_parser_delete_manifest_info_from_usr_db(manifest_x *mfx, uid_t uid)
API int pkgmgr_parser_delete_manifest_info_from_db(manifest_x *mfx)
{
- return pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, GLOBAL_USER);
+ return pkgmgr_parser_delete_manifest_info_from_usr_db(mfx, _getuid());
}
API int pkgmgr_parser_update_preload_info_in_db()
pkgmgr_parser_close_db();
return ret;
}
+
+API int pkgmgr_parser_update_global_app_disable_for_uid_info_in_db(const char *appid, uid_t uid, int is_disable)
+{
+ int ret = -1;
+
+ ret = pkgmgr_parser_check_and_create_db(GLOBAL_USER);
+ if (ret == -1) {
+ _LOGD("Failed to open DB\n");
+ return ret;
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to begin transaction\n");
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Begin\n");
+ if (is_disable)
+ ret = __disable_global_app_for_user(appid, uid);
+ else
+ ret = __enable_global_app_for_user(appid, uid);
+ if (ret == -1) {
+ _LOGD("__update_global_app_disable_condition_in_db failed. Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ goto err;
+ }
+ /*Commit transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Commit and End\n");
+err:
+ pkgmgr_parser_close_db();
+ return ret;
+
+}
+
+API int pkgmgr_parser_update_app_disable_info_in_db(const char *appid, int is_disable)
+{
+ return pkgmgr_parser_update_app_disable_info_in_usr_db(appid, _getuid(), is_disable);
+}
+
+API int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable)
+{
+ int ret = -1;
+
+ ret = pkgmgr_parser_check_and_create_db(uid);
+ if (ret == -1) {
+ _LOGD("Failed to open DB\n");
+ return ret;
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to begin transaction\n");
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Begin\n");
+ if (is_disable)
+ ret = __disable_app(appid);
+ else
+ ret = __enable_app(appid);
+ if (ret == -1) {
+ _LOGD("__update_app_disable_condition_in_db failed. Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ goto err;
+ }
+ /*Commit transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Commit and End\n");
+err:
+ pkgmgr_parser_close_db();
+ return ret;
+
+}