static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
{
pkgmgr_appinfo_x *info = data;
- pkgmgr_appinfo_x *tmp;
- while (info != NULL) {
- tmp = info->next;
+ if (info != NULL) {
if (info->package)
free((void *)info->package);
if (info->locale)
pkgmgrinfo_basic_free_application(info->app_info);
free((void *)info);
- info = tmp;
}
return;
}
}
+static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
+ GList **splashscreens)
+{
+ static const char query_raw[] =
+ "SELECT src, type, orientation, indicatordisplay, operation "
+ "FROM package_app_splash_screen WHERE app_id=%Q";
+ int ret;
+ char *query;
+ sqlite3_stmt *stmt;
+ int idx;
+ splashscreen_x *info;
+
+ query = sqlite3_mprintf(query_raw, appid);
+ 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(splashscreen_x));
+ if (info == NULL) {
+ LOGE("out of memory");
+ sqlite3_finalize(stmt);
+ return PMINFO_R_ERROR;
+ }
+ idx = 0;
+ _save_column_str(stmt, idx++, &info->src);
+ _save_column_str(stmt, idx++, &info->type);
+ _save_column_str(stmt, idx++, &info->orientation);
+ _save_column_str(stmt, idx++, &info->indicatordisplay);
+ _save_column_str(stmt, idx++, &info->operation);
+ *splashscreens = g_list_append(*splashscreens, info);
+ }
+
+ sqlite3_finalize(stmt);
+
+ return PMINFO_R_OK;
+}
+
static GList *__get_background_category(char *value)
{
GList *category_list = NULL;
}
static int _appinfo_get_application(sqlite3 *db, const char *appid,
- const char *locale, application_x **application)
+ const char *locale, application_x **application, bool is_disabled)
{
static const char query_raw[] =
"SELECT app_id, app_component, app_exec, app_nodisplay, "
"app_submode_mainid, app_launch_mode, app_ui_gadget, "
"app_support_disable, "
"component_type, package, app_process_pool, app_installed_storage, "
- "app_background_category "
- "FROM package_app_info WHERE app_id=%Q";
+ "app_background_category, app_package_type "
+ "FROM package_app_info WHERE app_id='%s' "
+ "AND (app_disable='%s' "
+ "%s app_id %s IN "
+ "(SELECT app_id from package_app_disable_for_user WHERE uid='%d'))";
int ret;
- char *query;
+ char query[MAX_QUERY_LEN] = { '\0' };
sqlite3_stmt *stmt;
int idx;
application_x *info;
char *bg_category_str = NULL;
-
- query = sqlite3_mprintf(query_raw, appid);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
+ snprintf(query, MAX_QUERY_LEN - 1, query_raw,
+ appid,
+ is_disabled ? "true" : "false",
+ is_disabled ? "OR" : "AND",
+ is_disabled ? "" : "NOT",
+ (int)getuid());
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;
_save_column_str(stmt, idx++, &info->process_pool);
_save_column_str(stmt, idx++, &info->installed_storage);
_save_column_str(stmt, idx++, &bg_category_str);
+ _save_column_str(stmt, idx++, &info->package_type);
info->background_category = __get_background_category(bg_category_str);
return PMINFO_R_ERROR;
}
+ if (_appinfo_get_splashscreens(db, info->appid, &info->splashscreens)) {
+ pkgmgrinfo_basic_free_application(info);
+ sqlite3_finalize(stmt);
+ return PMINFO_R_ERROR;
+ }
+
*application = info;
sqlite3_finalize(stmt);
}
static int _appinfo_get_appinfo(const char *appid, uid_t uid,
- pkgmgr_appinfo_x **appinfo)
+ pkgmgr_appinfo_x **appinfo, bool is_disabled)
{
int ret;
sqlite3 *db;
return PMINFO_R_ERROR;
}
- ret = _appinfo_get_application(db, appid, locale, &info->app_info);
+ ret = _appinfo_get_application(db, appid, locale, &info->app_info, is_disabled);
if (ret != PMINFO_R_OK) {
free(info);
free(locale);
return ret;
}
+API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(const char *appid, uid_t uid,
+ pkgmgrinfo_appinfo_h *handle)
+{
+ int ret;
+
+ if (appid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle, true);
+ if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
+ ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
+ (pkgmgr_appinfo_x **)handle, true);
+
+ if (ret != PMINFO_R_OK)
+ _LOGE("failed to get appinfo of %s for user %d", appid, uid);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_disabled_appinfo(const char *appid, pkgmgrinfo_appinfo_h *handle)
+{
+ return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(appid, GLOBAL_USER, handle);
+}
+
API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
pkgmgrinfo_appinfo_h *handle)
{
return PMINFO_R_EINVAL;
}
- ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle);
+ ret = _appinfo_get_appinfo(appid, uid, (pkgmgr_appinfo_x **)handle, false);
if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
- (pkgmgr_appinfo_x **)handle);
+ (pkgmgr_appinfo_x **)handle, false);
if (ret != PMINFO_R_OK)
_LOGE("failed to get appinfo of %s for user %d", appid, uid);
return pkgmgrinfo_appinfo_get_usr_appinfo(appid, GLOBAL_USER, handle);
}
+static gpointer __copy_str(gconstpointer src, gpointer data)
+{
+ const char *tmp = (const char *)src;
+ const char *buffer;
+
+ buffer = strdup(tmp);
+ if (buffer == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ return buffer;
+}
+
+static gpointer __copy_label(gconstpointer src, gpointer data)
+{
+ label_x *tmp = (label_x *)src;
+ label_x *label;
+
+ label = calloc(1, sizeof(label_x));
+ if (label == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->name)
+ label->name = strdup(tmp->name);
+ if (tmp->text)
+ label->text = strdup(tmp->text);
+ if (tmp->lang)
+ label->lang = strdup(tmp->lang);
+
+ return label;
+}
+
+static gpointer __copy_icon(gconstpointer src, gpointer data)
+{
+ icon_x *tmp = (icon_x *)src;
+ icon_x *icon;
+
+ icon = calloc(1, sizeof(icon_x));
+ if (icon== NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->text)
+ icon->text = strdup(tmp->text);
+ if (tmp->lang)
+ icon->lang = strdup(tmp->lang);
+ if (tmp->section)
+ icon->section = strdup(tmp->section);
+ if (tmp->size)
+ icon->size = strdup(tmp->size);
+ if (tmp->resolution)
+ icon->resolution = strdup(tmp->resolution);
+
+ return icon;
+}
+
+static gpointer __copy_metadata(gconstpointer src, gpointer data)
+{
+ metadata_x *tmp = (metadata_x *)src;
+ metadata_x *metadata;
+
+ metadata = calloc(1, sizeof(metadata_x));
+ if (metadata == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->key)
+ metadata->key = strdup(tmp->key);
+ if (tmp->value)
+ metadata->value = strdup(tmp->value);
+
+ return metadata;
+}
+
+static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
+{
+ datacontrol_x *tmp = (datacontrol_x *)src;
+ datacontrol_x *datacontrol;
+
+ datacontrol = calloc(1, sizeof(datacontrol_x));
+ if (datacontrol == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->providerid)
+ datacontrol->providerid = strdup(tmp->providerid);
+ if (tmp->access)
+ datacontrol->access = strdup(tmp->access);
+ if (tmp->type)
+ datacontrol->type = strdup(tmp->type);
+
+ return datacontrol;
+}
+
+static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
+{
+ appcontrol_x *tmp = (appcontrol_x *)src;
+ appcontrol_x *appcontrol;
+
+ appcontrol = calloc(1, sizeof(appcontrol_x));
+ if (appcontrol ==NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->operation)
+ appcontrol->operation = strdup(tmp->operation);
+ if (tmp->uri)
+ appcontrol->uri = strdup(tmp->uri);
+ if (tmp->mime)
+ appcontrol->mime = strdup(tmp->mime);
+
+ return appcontrol;
+}
+
+static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
+{
+ splashscreen_x *tmp = (splashscreen_x *)src;
+ splashscreen_x *splashscreen;
+
+ splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
+ if (splashscreen == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->src)
+ splashscreen->src = strdup(tmp->src);
+ if (tmp->type)
+ splashscreen->type = strdup(tmp->type);
+ if (tmp->orientation)
+ splashscreen->orientation = strdup(tmp->orientation);
+ if (tmp->indicatordisplay)
+ splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
+ if (tmp->operation)
+ splashscreen->operation = strdup(tmp->operation);
+
+ return splashscreen;
+}
+
+static int _appinfo_copy_appinfo(application_x **application, application_x *data)
+{
+ application_x *app_info;
+ int ret;
+
+ app_info = calloc(1, sizeof(application_x));
+ if (app_info == NULL) {
+ LOGE("memory alloc failed");
+ return PMINFO_R_ERROR;
+ }
+
+ if (data->appid != NULL)
+ app_info->appid = strdup(data->appid);
+ if (data->exec != NULL)
+ app_info->exec = strdup(data->exec);
+ if (data->nodisplay != NULL)
+ app_info->nodisplay = strdup(data->nodisplay);
+ if (data->multiple != NULL)
+ app_info->multiple = strdup(data->multiple);
+ if (data->taskmanage != NULL)
+ app_info->taskmanage = strdup(data->taskmanage);
+ if (data->enabled != NULL)
+ app_info->enabled = strdup(data->enabled);
+ if (data->type != NULL)
+ app_info->type = strdup(data->type);
+ if (data->categories != NULL)
+ app_info->categories = strdup(data->categories);
+ if (data->hwacceleration != NULL)
+ app_info->hwacceleration = strdup(data->hwacceleration);
+ if (data->screenreader != NULL)
+ app_info->screenreader = strdup(data->screenreader);
+ if (data->mainapp != NULL)
+ app_info->mainapp = strdup(data->mainapp);
+ if (data->package != NULL)
+ app_info->package = strdup(data->package);
+ if (data->recentimage != NULL)
+ app_info->recentimage = strdup(data->recentimage);
+ if (data->launchcondition != NULL)
+ app_info->launchcondition = strdup(data->launchcondition);
+ if (data->indicatordisplay != NULL)
+ app_info->indicatordisplay = strdup(data->indicatordisplay);
+ if (data->portraitimg != NULL)
+ app_info->portraitimg = strdup(data->portraitimg);
+ if (data->landscapeimg != NULL)
+ app_info->landscapeimg = strdup(data->landscapeimg);
+ if (data->guestmode_visibility != NULL)
+ app_info->guestmode_visibility = strdup(data->guestmode_visibility);
+ if (data->component != NULL)
+ app_info->component = strdup(data->component);
+ if (data->permission_type != NULL)
+ app_info->permission_type = strdup(data->permission_type);
+ if (data->component_type != NULL)
+ app_info->component_type = strdup(data->component_type);
+ if (data->preload != NULL)
+ app_info->preload = strdup(data->preload);
+ if (data->submode != NULL)
+ app_info->submode = strdup(data->submode);
+ if (data->submode_mainid != NULL)
+ app_info->submode_mainid = strdup(data->submode_mainid);
+ if (data->process_pool != NULL)
+ app_info->process_pool = strdup(data->process_pool);
+ if (data->installed_storage != NULL)
+ app_info->installed_storage = strdup(data->installed_storage);
+ if (data->autorestart != NULL)
+ app_info->autorestart = strdup(data->autorestart);
+ if (data->onboot != NULL)
+ app_info->onboot = strdup(data->onboot);
+ if (data->support_disable != NULL)
+ app_info->support_disable = strdup(data->support_disable);
+ if (data->ui_gadget != NULL)
+ app_info->ui_gadget = strdup(data->ui_gadget);
+ if (data->launch_mode != NULL)
+ app_info->launch_mode = strdup(data->launch_mode);
+ if (data->package_type != NULL)
+ app_info->package_type = strdup(data->package_type);
+
+ /* GList */
+ ret = 0;
+ app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->metadata = g_list_copy_deep(data->metadata, __copy_metadata, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->datacontrol = g_list_copy_deep(data->datacontrol, __copy_datacontrol, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->appcontrol = g_list_copy_deep(data->appcontrol, __copy_appcontrol, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->background_category = g_list_copy_deep(data->background_category, __copy_str, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->splashscreens = g_list_copy_deep(data->splashscreens, __copy_splashscreens, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ *application = app_info;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_appinfo_h *clone)
+{
+ pkgmgr_appinfo_x *info;
+ pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL)
+ return PMINFO_R_EINVAL;
+
+ info = calloc(1, sizeof(pkgmgr_appinfo_x));
+ if (info == NULL) {
+ LOGE("memory alloc failed");
+ return PMINFO_R_ERROR;
+ }
+
+ if (temp->package != NULL)
+ info->package = strdup(temp->package);
+ if (temp->locale != NULL)
+ info->locale = strdup(temp->locale);
+
+ info->app_component = temp->app_component;
+
+ if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
+ LOGE("appinfo copy failed");
+ if (info->package)
+ free((void *)info->package);
+ if (info->locale)
+ free(info->locale);
+ free(info);
+ return PMINFO_R_ERROR;
+ }
+
+ *clone = info;
+
+ return PMINFO_R_OK;
+}
+
static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
pkgmgrinfo_filter_x *filter, pkgmgrinfo_app_list_cb app_list_cb,
void *user_data)
for (tmp = list; tmp; tmp = tmp->next) {
appid = (char *)tmp->data;
if (stop == 0) {
- ret = _appinfo_get_appinfo(appid, uid, &info);
+ ret = _appinfo_get_appinfo(appid, uid, &info, false);
if (ret == PMINFO_R_ENOENT && uid != GLOBAL_USER)
ret = _appinfo_get_appinfo(appid, GLOBAL_USER,
- &info);
+ &info, false);
if (ret != PMINFO_R_OK) {
free(appid);
continue;
const char *comp_str = NULL;
if (handle == NULL || app_func == NULL) {
- LOGE("invalied parameter");
+ LOGE("invalid parameter");
return PMINFO_R_EINVAL;
}
return PMINFO_R_ERROR;
}
+ if (uid == GLOBAL_USER) {
+ if (pkgmgrinfo_appinfo_filter_add_int(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+ }
switch (component) {
case PMINFO_UI_APP:
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_get_pkgtype(pkgmgrinfo_appinfo_h handle, char **pkgtype)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkgtype == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ *pkgtype = (char *)info->app_info->package_type;
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
{
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
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, "(null)") ||
+ !strcasecmp(ptr->text, "") ||
strcmp(ptr->lang, locale))
continue;
*icon = (char *)ptr->text;
static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
{
- if ( strcasecmp(comp, "uiapp") == 0)
+ if (strcasecmp(comp, "uiapp") == 0)
return PMINFO_UI_APP;
- else if ( strcasecmp(comp, "svcapp") == 0)
+ else if (strcasecmp(comp, "svcapp") == 0)
return PMINFO_SVC_APP;
+ else if (strcasecmp(comp, "widgetapp") == 0)
+ return PMINFO_WIDGET_APP;
+ else if (strcasecmp(comp, "watchapp") == 0)
+ return PMINFO_WATCH_APP;
else
return -1;
}
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 ||
- info->app_info->landscapeimg == NULL)
+ if (info->app_info == NULL || (info->app_info->portraitimg == NULL
+ && info->app_info->landscapeimg == NULL))
return PMINFO_R_ERROR;
*portrait_img = (char *)info->app_info->portraitimg;
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
+ void *user_data)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ splashscreen_x *splashscreen;
+ GList *tmp;
+ int ret;
+
+ if (info == NULL || info->app_info == NULL
+ || splash_screen_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
+ splashscreen = (splashscreen_x *)tmp->data;
+ if (splashscreen == NULL)
+ continue;
+ ret = splash_screen_func(splashscreen->src,
+ splashscreen->type,
+ splashscreen->orientation,
+ splashscreen->indicatordisplay,
+ splashscreen->operation,
+ user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodisplay)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");