return 0;
}
+int _appinfo_insert_appinfo(uid_t uid, const char *appid)
+{
+ int ret;
+ struct user_appinfo *info;
+ pkgmgrinfo_appinfo_h handle;
+
+ info = __find_user_appinfo(uid);
+ if (info == NULL) {
+ _E("Failed to find user appinfo. uid(%d)", uid);
+ return -1;
+ }
+
+ if (g_hash_table_contains(info->tbl, appid)) {
+ _W("Already exists. uid(%u), appid(%s)", uid, appid);
+ return 0;
+ }
+
+ ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
+ if (ret != PMINFO_R_OK) {
+ _E("Failed to get appinfo. %u:%s, error(%d)", uid, appid, ret);
+ return -1;
+ }
+
+ ret = __insert_appinfo(handle, info);
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return ret;
+}
+
const char *_appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
{
if (!c) {
int _appinfo_insert(uid_t uid, const char *pkgid);
+int _appinfo_insert_appinfo(uid_t uid, const char *appid);
+
struct appinfo *_appinfo_find(uid_t caller_uid, const char *appid);
const char *_appinfo_get_value(const struct appinfo *c, enum appinfo_type type);
handle->appid = appid;
handle->ai = _appinfo_find(target_uid, appid);
if (handle->ai == NULL) {
- _E("Failed to find appinfo of %s", appid);
- return -ENOENT;
+ _E("Failed to find appinfo. %u:%s", target_uid, appid);
+ if (_appinfo_insert_appinfo(target_uid, appid) != 0)
+ return -ENOENT;
+
+ handle->ai = _appinfo_find(target_uid, appid);
+ if (handle->ai == NULL) {
+ _E("[SECOND] Failed to find appinfo. %u:%s",
+ target_uid, appid);
+ return -ENOENT;
+ }
}
ret = __check_executable(handle->ai);