static bool _get_bool_value(const char *str)
{
- if (str == NULL)
- return false;
- else if (!strcasecmp(str, "true"))
+ if (str && !strcmp(str, "true"))
return true;
else
return false;
" LEFT OUTER JOIN package_app_app_metadata"
" ON ai.app_id=package_app_app_metadata.app_id ";
-static char *_get_filtered_query(const char *query_raw,
- pkgmgrinfo_filter_x *filter)
+static int _get_filtered_query(pkgmgrinfo_filter_x *filter,
+ const char *locale, char **query, GList **bind_params)
{
- char buf[MAX_QUERY_LEN] = { 0, };
- char query[MAX_QUERY_LEN];
- char *condition;
+ int joined = 0;
size_t len = 0;
+ char *condition = NULL;
+ char buf[MAX_QUERY_LEN] = { '\0' };
+ char tmp_query[MAX_QUERY_LEN] = { '\0' };
+ static const char query_pkg_disable[] = " AND ai.package IN "
+ "(SELECT package FROM package_info WHERE package_disable='false')";
GSList *list;
- GSList *head = NULL;
- int joined = 0;
- if (filter)
- head = filter->list;
+ len += strlen(" WHERE 1=1");
+ strncat(buf, " WHERE 1=1", MAX_QUERY_LEN - len - 1);
- for (list = head; list; list = list->next) {
- /* TODO: revise condition getter function */
- joined |= __get_filter_condition(list->data, &condition);
+ if (filter == NULL) {
+ strncat(buf, query_pkg_disable, MAX_QUERY_LEN - len - 1);
+ *query = strdup(buf);
+ return PMINFO_R_OK;
+ }
+
+ for (list = filter->list; list; list = list->next) {
+ joined |= __get_filter_condition(list->data, &condition, bind_params);
if (condition == NULL)
continue;
- if (buf[0] == '\0') {
- len += strlen(" WHERE ");
- strncat(buf, " WHERE ", MAX_QUERY_LEN - len - 1);
- } else {
- len += strlen(" AND ");
- strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
- }
+
+ len += strlen(" AND ");
+ strncat(buf, " AND ", MAX_QUERY_LEN - len - 1);
+
len += strlen(condition);
strncat(buf, condition, sizeof(buf) - len - 1);
free(condition);
condition = NULL;
}
- snprintf(query, sizeof(query), "%s", query_raw);
- len = strlen(query);
if (joined & E_PMINFO_APPINFO_JOIN_LOCALIZED_INFO) {
- strncat(query, join_localized_info, MAX_QUERY_LEN - len - 1);
+ strncat(tmp_query, join_localized_info, MAX_QUERY_LEN - len - 1);
len += strlen(join_localized_info);
+ *bind_params = g_list_append(*bind_params, strdup(locale));
}
if (joined & E_PMINFO_APPINFO_JOIN_CATEGORY) {
- strncat(query, join_category, MAX_QUERY_LEN - len - 1);
+ strncat(tmp_query, join_category, MAX_QUERY_LEN - len - 1);
len += strlen(join_category);
}
if (joined & E_PMINFO_APPINFO_JOIN_APP_CONTROL) {
- strncat(query, join_app_control, MAX_QUERY_LEN - len - 1);
+ strncat(tmp_query, join_app_control, MAX_QUERY_LEN - len - 1);
len += strlen(join_app_control);
}
if (joined & E_PMINFO_APPINFO_JOIN_METADATA) {
- strncat(query, join_metadata, MAX_QUERY_LEN - len - 1);
+ strncat(tmp_query, join_metadata, MAX_QUERY_LEN - len - 1);
len += strlen(join_metadata);
}
- strncat(query, buf, MAX_QUERY_LEN - len -1);
-
- return strdup(query);
-}
-
-static int _appinfo_get_label(sqlite3 *db, const char *appid,
- const char *locale, GList **label)
-{
- static const char query_raw[] =
- "SELECT app_label, app_locale "
- "FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
- int ret;
- char *query;
- sqlite3_stmt *stmt;
- int idx;
- label_x *info;
-
- query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
- sqlite3_free(query);
- if (ret != SQLITE_OK) {
- LOGE("prepare failed: %s", sqlite3_errmsg(db));
- return PMINFO_R_ERROR;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- info = calloc(1, sizeof(label_x));
- if (info == NULL) {
- LOGE("out of memory");
- sqlite3_finalize(stmt);
- return PMINFO_R_ERROR;
- }
- idx = 0;
- _save_column_str(stmt, idx++, &info->text);
- _save_column_str(stmt, idx++, &info->lang);
- *label = g_list_append(*label, info);
- }
-
- sqlite3_finalize(stmt);
-
- return PMINFO_R_OK;
-}
-
-static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
- GList **icon)
-{
- static const char query_raw[] =
- "SELECT app_icon, app_locale "
- "FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
- int ret;
- char *query;
- sqlite3_stmt *stmt;
- int idx;
- icon_x *info;
+ strncat(tmp_query, buf, MAX_QUERY_LEN - len - 1);
- query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
+ len += strlen(buf);
+ strncat(tmp_query, query_pkg_disable, MAX_QUERY_LEN - len - 1);
- ret = sqlite3_prepare_v2(db, query, strlen(query),
- &stmt, NULL);
- sqlite3_free(query);
- if (ret != SQLITE_OK) {
- LOGE("prepare failed: %s", sqlite3_errmsg(db));
+ *query = strdup(tmp_query);
+ if (*query == NULL)
return PMINFO_R_ERROR;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- info = calloc(1, sizeof(icon_x));
- if (info == NULL) {
- LOGE("out of memory");
- sqlite3_finalize(stmt);
- return PMINFO_R_ERROR;
- }
- idx = 0;
- _save_column_str(stmt, idx++, &info->text);
- _save_column_str(stmt, idx++, &info->lang);
- *icon = g_list_append(*icon, info);
- }
-
- sqlite3_finalize(stmt);
return PMINFO_R_OK;
}
pkgmgrinfo_basic_free_application((application_x *)data);
}
+static int __bind_params(sqlite3_stmt *stmt, GList *params)
+{
+ GList *tmp_list = NULL;
+ int idx = 0;
+ int ret;
+
+ if (stmt == NULL || params == NULL)
+ return PMINFO_R_EINVAL;
+
+ tmp_list = params;
+ while (tmp_list) {
+ ret = sqlite3_bind_text(stmt, ++idx, (char *)tmp_list->data, -1, SQLITE_STATIC);
+ if (ret != SQLITE_OK)
+ return PMINFO_R_ERROR;
+ tmp_list = tmp_list->next;
+ }
+
+ return PMINFO_R_OK;
+}
+
static int _appinfo_get_applications(uid_t db_uid, uid_t uid,
const char *locale, pkgmgrinfo_filter_x *filter, int flag,
GHashTable *applications)
"ai.app_installed_storage, ai.app_background_category, "
"ai.app_package_type, ai.app_root_path, ai.app_api_version, "
"ai.app_effective_appid, ai.app_disable, "
- "ai.app_splash_screen_display, "
- "ai.component_type, ai.package "
- "FROM package_app_info as ai";
- int ret;
- char *query;
- const char *dbpath;
- sqlite3 *db;
- sqlite3_stmt *stmt;
+ "ai.app_splash_screen_display, ai.app_tep_name, "
+ "ai.app_zip_mount_file, ai.component_type, ai.package, "
+ "ai.app_external_path, ai.app_package_system, ai.app_removable, "
+ "ai.app_package_installed_time";
+ static const char query_label[] =
+ ", COALESCE("
+ "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
+ "(SELECT app_label FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
+ static const char query_icon[] =
+ ", COALESCE("
+ "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale=?), "
+ "(SELECT app_icon FROM package_app_localized_info WHERE ai.app_id=app_id AND app_locale='No Locale'))";
+ static const char query_from_clause[] = " FROM package_app_info as ai";
+ int ret = PMINFO_R_ERROR;
int idx;
- application_x *info;
+ int len = 0;
+ char *dbpath;
char *bg_category_str = NULL;
+ char *constraint = NULL;
+ char *tmp_record = NULL;
+ char query[MAX_QUERY_LEN] = { '\0' };
+ application_x *info = NULL;
+ GList *bind_params = NULL;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *stmt = NULL;
dbpath = getUserPkgParserDBPathUID(db_uid);
if (dbpath == NULL)
ret = sqlite3_open_v2(dbpath, &db, SQLITE_OPEN_READONLY, NULL);
if (ret != SQLITE_OK) {
_LOGE("failed to open db: %d", ret);
+ free(dbpath);
return PMINFO_R_ERROR;
}
+ free(dbpath);
- query = _get_filtered_query(query_raw, filter);
- if (query == NULL) {
- LOGE("out of memory");
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ len = strlen(query_raw);
+ snprintf(query, MAX_QUERY_LEN - 1, "%s", query_raw);
+ if (flag & PMINFO_APPINFO_GET_LABEL) {
+ strncat(query, query_label, MAX_QUERY_LEN - len - 1);
+ len += strlen(query_label);
+ bind_params = g_list_append(bind_params, strdup(locale));
+ }
+ if (flag & PMINFO_APPINFO_GET_ICON) {
+ strncat(query, query_icon, MAX_QUERY_LEN - len - 1);
+ len += strlen(query_icon);
+ bind_params = g_list_append(bind_params, strdup(locale));
+ }
+
+ ret = _get_filtered_query(filter, locale, &constraint, &bind_params);
+ if (ret != PMINFO_R_OK) {
+ LOGE("Failed to get WHERE clause");
+ goto catch;
}
+ strncat(query, query_from_clause, MAX_QUERY_LEN - len - 1);
+ len += strlen(query_from_clause);
+
+ if (constraint)
+ strncat(query, constraint, MAX_QUERY_LEN - len - 1);
ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
- free(query);
if (ret != SQLITE_OK) {
LOGE("prepare failed: %s", sqlite3_errmsg(db));
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
+ }
+
+ if (g_list_length(bind_params) != 0) {
+ ret = __bind_params(stmt, bind_params);
+ if (ret != SQLITE_OK) {
+ LOGE("Failed to bind parameters");
+ goto catch;
+ }
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
info = calloc(1, sizeof(application_x));
if (info == NULL) {
LOGE("out of memory");
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
idx = 0;
_save_column_str(stmt, idx++, &info->appid);
_save_column_str(stmt, idx++, &info->effective_appid);
_save_column_str(stmt, idx++, &info->is_disabled);
_save_column_str(stmt, idx++, &info->splash_screen_display);
+ _save_column_str(stmt, idx++, &info->tep_name);
+ _save_column_str(stmt, idx++, &info->zip_mount_file);
_save_column_str(stmt, idx++, &info->component_type);
_save_column_str(stmt, idx++, &info->package);
+ _save_column_str(stmt, idx++, &info->external_path);
+ _save_column_str(stmt, idx++, &info->package_system);
+ _save_column_str(stmt, idx++, &info->removable);
+ _save_column_str(stmt, idx++, &info->package_installed_time);
+
info->for_all_users =
strdup((uid != GLOBAL_USER) ? "false" : "true");
free(bg_category_str);
if (flag & PMINFO_APPINFO_GET_LABEL) {
- if (_appinfo_get_label(db, info->appid, locale,
- &info->label)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ tmp_record = NULL;
+ _save_column_str(stmt, idx++, &tmp_record);
+ if (_add_label_info_into_list(locale, tmp_record, &info->label)) {
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_ICON) {
- if (_appinfo_get_icon(db, info->appid, locale,
- &info->icon)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ tmp_record = NULL;
+ _save_column_str(stmt, idx++, &tmp_record);
+ if (_add_icon_info_into_list(locale, tmp_record, &info->icon)) {
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_CATEGORY) {
if (_appinfo_get_category(db, info->appid,
&info->category)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
if (_appinfo_get_app_control(db, info->appid,
&info->appcontrol)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_DATA_CONTROL) {
if (_appinfo_get_data_control(db, info->appid,
&info->datacontrol)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_METADATA) {
if (_appinfo_get_metadata(db, info->appid,
&info->metadata)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
if (_appinfo_get_splashscreens(db, info->appid,
&info->splashscreens)) {
- pkgmgrinfo_basic_free_application(info);
- sqlite3_finalize(stmt);
- sqlite3_close_v2(db);
- return PMINFO_R_ERROR;
+ ret = PMINFO_R_ERROR;
+ goto catch;
}
}
+ if (__appinfo_check_installed_storage(info) != PMINFO_R_OK) {
+ ret = PMINFO_R_ERROR;
+ pkgmgrinfo_basic_free_application(info);
+ info = NULL;
+ continue;
+ }
+
g_hash_table_insert(applications, (gpointer)info->appid,
(gpointer)info);
}
- sqlite3_finalize(stmt);
+ ret = PMINFO_R_OK;
+
+catch:
+ if (constraint)
+ free(constraint);
+
+ if (ret != PMINFO_R_OK && info != NULL)
+ pkgmgrinfo_basic_free_application(info);
+
+ g_list_free_full(bind_params, free);
sqlite3_close_v2(db);
+ sqlite3_finalize(stmt);
- return PMINFO_R_OK;
+ return ret;
}
API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
icon_x *icon;
icon = calloc(1, sizeof(icon_x));
- if (icon== NULL) {
+ if (icon == NULL) {
LOGE("memory alloc failed");
*(int *)data = -1;
return NULL;
appcontrol_x *appcontrol;
appcontrol = calloc(1, sizeof(appcontrol_x));
- if (appcontrol ==NULL) {
+ if (appcontrol == NULL) {
LOGE("memory alloc failed");
*(int *)data = -1;
return NULL;
return PMINFO_R_EINVAL;
}
- if (pkgmgrinfo_appinfo_filter_create(&filter)) {
+ if (pkgmgrinfo_appinfo_filter_create(&filter))
return PMINFO_R_ERROR;
- }
if (pkgmgrinfo_appinfo_filter_add_bool(filter,
PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
{
- const char *locale;
- icon_x *ptr;
- GList *tmp;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ icon_x *ptr;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
- locale = info->locale;
- retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
-
if (info->app_info == NULL)
return PMINFO_R_ERROR;
- for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
- ptr = (icon_x *)tmp->data;
- if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
- !strcasecmp(ptr->text, "") ||
- strcmp(ptr->lang, locale))
- continue;
- *icon = (char *)ptr->text;
+ if (info->app_info->icon == NULL) {
+ *icon = "";
return PMINFO_R_OK;
}
- locale = DEFAULT_LOCALE;
- for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
- ptr = (icon_x *)tmp->data;
- if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
- strcmp(ptr->lang, locale))
- continue;
- *icon = (char *)ptr->text;
- return PMINFO_R_OK;
- }
+ ptr = (icon_x *)info->app_info->icon->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
- return PMINFO_R_ERROR;
+ if (ptr->text == NULL)
+ return PMINFO_R_ERROR;
+ else
+ *icon = ptr->text;
+
+ return PMINFO_R_OK;
}
API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
{
- const char *locale;
label_x *ptr;
- GList *tmp;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
- locale = info->locale;
- retvm_if(locale == NULL, PMINFO_R_ERROR, "manifest locale is NULL");
-
- if (info->app_info == NULL)
+ if (info->app_info == NULL || info->app_info->label == NULL)
return PMINFO_R_ERROR;
- for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
- ptr = (label_x *)tmp->data;
- if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
- strcmp(ptr->lang, locale))
- continue;
- *label = (char *)ptr->text;
- return PMINFO_R_OK;
- }
+ ptr = (label_x *)info->app_info->label->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
- locale = DEFAULT_LOCALE;
- for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
- ptr = (label_x *)tmp->data;
- if (ptr == NULL || ptr->text == NULL || ptr->lang == NULL ||
- strcmp(ptr->lang, locale))
- continue;
- *label = (char *)ptr->text;
- return PMINFO_R_OK;
- }
+ if (ptr->text == NULL)
+ return PMINFO_R_ERROR;
+ else
+ *label = ptr->text;
- return PMINFO_R_ERROR;
+ return PMINFO_R_OK;
}
static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
sqlite3_stmt *stmt = NULL;
sqlite3 *db = NULL;
char *val;
- const char *manifest_db;
+ char *parser_db;
- manifest_db = getUserPkgParserDBPathUID(uid);
- if (manifest_db == NULL) {
- _LOGE("Failed to get manifest db path");
+ parser_db = getUserPkgParserDBPathUID(uid);
+ if (parser_db == NULL) {
+ _LOGE("Failed to get parser db path");
goto err;
}
- if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
+ if (sqlite3_open_v2(parser_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
_LOGE("DB open fail\n");
+ free(parser_db);
goto err;
}
+ free(parser_db);
query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
if (query == NULL) {
metadata = (metadata_x *)list_md->data;
if (metadata && metadata->key) {
if (strcasecmp(metadata->key, metadata_key) == 0) {
- *metadata_value = (char*)metadata->value;
+ if (metadata->value == NULL)
+ *metadata_value = "";
+ else
+ *metadata_value = (char*)metadata->value;
return PMINFO_R_OK;
}
}
continue;
val = (char *)ptr->section;
- if (val && strcmp(val, "notification") == 0){
+ if (val && strcmp(val, "notification") == 0) {
*icon = (char *)ptr->text;
return PMINFO_R_OK;
}
retvm_if(portrait_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
retvm_if(landscape_img == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
- if (info->app_info == NULL || (info->app_info->portraitimg == NULL
- && info->app_info->landscapeimg == NULL))
+ if (info->app_info == NULL)
return PMINFO_R_ERROR;
- *portrait_img = (char *)info->app_info->portraitimg;
- *landscape_img = (char *)info->app_info->landscapeimg;
+ if (info->app_info->portraitimg == NULL)
+ *portrait_img = "";
+ else
+ *portrait_img = (char *)info->app_info->portraitimg;
+
+ if (info->app_info->landscapeimg == NULL)
+ *landscape_img = "";
+ else
+ *landscape_img = (char *)info->app_info->landscapeimg;
return PMINFO_R_OK;
}
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
- if (info->app_info == NULL || info->app_info->submode_mainid == NULL)
+ if (info->app_info == NULL)
return PMINFO_R_ERROR;
- *submode_mainid = (char *)info->app_info->submode_mainid;
+ if (info->app_info->submode_mainid == NULL)
+ *submode_mainid = "";
+ else
+ *submode_mainid = (char *)info->app_info->submode_mainid;
return PMINFO_R_OK;
}
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- if (info->app_info && info->app_info->installed_storage){
- if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
+ if (info->app_info && info->app_info->installed_storage) {
+ if (strcmp(info->app_info->installed_storage, "installed_internal") == 0)
*storage = PMINFO_INTERNAL_STORAGE;
- else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
+ else if (strcmp(info->app_info->installed_storage, "installed_external") == 0)
*storage = PMINFO_EXTERNAL_STORAGE;
else
return PMINFO_R_ERROR;
- }else
+ } else {
return PMINFO_R_ERROR;
+ }
return PMINFO_R_OK;
}
return PMINFO_R_EINVAL;
}
- if (info->app_info == NULL || info->app_info->effective_appid == NULL)
+ if (info->app_info == NULL)
return PMINFO_R_ERROR;
- *effective_appid = (char *)info->app_info->effective_appid;
+ if (info->app_info->effective_appid == NULL)
+ *effective_appid = "";
+ else
+ *effective_appid = (char *)info->app_info->effective_appid;
return PMINFO_R_OK;
}
return PMINFO_R_EINVAL;
}
- if (info->app_info == NULL || info->app_info->tep_name == NULL)
+ if (info->app_info == NULL)
return PMINFO_R_ERROR;
- *tep_name = (char *)info->app_info->tep_name;
+ if (info->app_info->tep_name == NULL)
+ *tep_name = "";
+ else
+ *tep_name = (char *)info->app_info->tep_name;
return PMINFO_R_OK;
}
return PMINFO_R_EINVAL;
}
- *zip_mount_file = (char *)info->app_info->zip_mount_file;
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->zip_mount_file == NULL)
+ *zip_mount_file = "";
+ else
+ *zip_mount_file = (char *)info->app_info->zip_mount_file;
return PMINFO_R_OK;
}
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_get_installed_time(pkgmgrinfo_appinfo_h handle, int *installed_time)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || installed_time == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->package_installed_time == NULL)
+ return PMINFO_R_ERROR;
+
+ *installed_time = atoi(info->app_info->package_installed_time);
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
{
retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
/*Start constructing query*/
query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
+ tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
/*prepare query*/
ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
/*Start constructing query*/
query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
+ tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
/*prepare query*/
ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
if (ptr == NULL)
continue;
if (ptr->key) {
- ret = metadata_func(ptr->key, ptr->value, user_data);
+ ret = metadata_func(ptr->key, ptr->value ? ptr->value : "", user_data);
if (ret < 0)
break;
}
_LOGE("invalid parameter");
return PMINFO_R_EINVAL;
}
+ if (info->app_info->ui_gadget == NULL)
+ info->app_info->ui_gadget = strdup("false");
*ui_gadget = _get_bool_value(info->app_info->ui_gadget);
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
+ bool *removable)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || removable == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ *removable = _get_bool_value(info->app_info->removable);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || system == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ *system = _get_bool_value(info->app_info->package_system);
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_is_disabled(pkgmgrinfo_appinfo_h handle, bool *disabled)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
return PMINFO_R_ERROR;
}
if (value)
- val = strndup("('true','True')", 15);
+ val = strndup("true", 4);
else
- val = strndup("('false','False')", 17);
+ val = strndup("false", 5);
if (val == NULL) {
_LOGE("Out of Memory\n");
free(node);
strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
_LOGI("Previous value is %s\n", prev);
filter->list = g_slist_delete_link(filter->list, link);
- snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s , '%s'", prev, value);
+ snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s,%s", prev, value);
strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
_LOGI("New value is %s\n", val);
node->value = val;
filter->list = g_slist_append(filter->list, (gpointer)node);
memset(temp, '\0', PKG_STRING_LEN_MAX);
} else {
- snprintf(temp, PKG_STRING_LEN_MAX - 1, "'%s'", value);
+ snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
strncpy(val, temp, PKG_STRING_LEN_MAX - 1);
_LOGI("First value is %s\n", val);
node->value = val;