#include <package-manager.h>
#include <dlog.h>
#include <cynara-client.h>
+#include <aul.h>
#include <aul_svc.h>
#include "app_info.h"
#define SMACK_LABEL_LEN 255
+#undef REGULAR_UID_MIN
+#define REGULAR_UID_MIN 5000
+
struct app_info_s {
char *app_id;
pkgmgrinfo_appinfo_h pkg_app_info;
void *user_data;
} foreach_res_control_context_s;
+typedef struct app_context_s {
+ char appid[256];
+ bool initialized;
+} app_context_t;
+
+static app_context_t __context;
+
static int app_info_convert_str_property(const char *property, char **converted_property)
{
if (property == NULL)
return ret;
}
+static void __app_context_initialize(void)
+{
+ if (__context.initialized)
+ return;
+
+ if (getuid() < REGULAR_UID_MIN) {
+ __context.initialized = true;
+ return;
+ }
+
+ aul_app_get_appid_bypid(getpid(), __context.appid,
+ sizeof(__context.appid));
+ __context.initialized = true;
+}
+
+static int __app_info_create_by_alias_appid(const char *app_id,
+ app_info_h app_info)
+{
+ pkgmgrinfo_appinfo_h appinfo;
+ char *real_appid = NULL;
+ int ret;
+
+ __app_context_initialize();
+ if (__context.appid != NULL && !strcmp(__context.appid, app_id))
+ return APP_MANAGER_ERROR_INVALID_PARAMETER;
+
+ ret = aul_svc_get_appid_by_alias_appid(app_id, &real_appid);
+ if (ret != AUL_SVC_RET_OK || real_appid == NULL)
+ return APP_MANAGER_ERROR_INVALID_PARAMETER;
+
+ /* LCOV_EXCL_START */
+ ret = pkgmgrinfo_appinfo_get_usr_appinfo(real_appid, getuid(),
+ &appinfo);
+ free(real_appid);
+ if (ret != PMINFO_R_OK)
+ return APP_MANAGER_ERROR_INVALID_PARAMETER;
+
+ app_info->app_id = strdup(app_id);
+ app_info->pkg_app_info = appinfo;
+ /* LCOV_EXCL_STOP */
+
+ return APP_MANAGER_ERROR_NONE;
+}
+
API int app_info_create(const char *app_id, app_info_h *app_info)
{
pkgmgrinfo_pkginfo_h pkginfo = NULL;
app_info_h info = NULL;
int retval = 0;
char *main_appid = NULL;
- char *real_appid = NULL;
if (app_id == NULL || app_info == NULL)
return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
if (info == NULL)
return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); /* LCOV_EXCL_LINE */
- if (aul_svc_get_appid_by_alias_appid(app_id, &real_appid) ==
- AUL_SVC_RET_OK && real_appid != NULL) {
- /* LCOV_EXCL_START */
- retval = pkgmgrinfo_appinfo_get_usr_appinfo(real_appid,
- getuid(), &appinfo);
- free(real_appid);
- if (!retval) {
- info->app_id = strdup(app_id);
- info->pkg_app_info = appinfo;
- *app_info = info;
- return APP_MANAGER_ERROR_NONE;
- }
- /* LCOV_EXCL_STOP */
+ retval = __app_info_create_by_alias_appid(app_id, info);
+ if (retval == APP_MANAGER_ERROR_NONE) {
+ *app_info = info;
+ return APP_MANAGER_ERROR_NONE;
}
+
retval = pkgmgrinfo_appinfo_get_usr_appinfo(app_id, getuid(), &appinfo);
if (!retval) {
info->app_id = strdup(app_id);