From: Hwankyu Jhun Date: Tue, 15 Feb 2022 09:42:32 +0000 (+0900) Subject: Fix getting AppInfo X-Git-Tag: accepted/tizen/unified/20220218.152646~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F08%2F271108%2F3;p=platform%2Fcore%2Fappfw%2Faul-1.git Fix getting AppInfo If the pid parameter is equal to the current process ID, AppInfo::Get() tries to get a package ID and a root path using pre-initialized information. If calling aul_app_get_pkgid_bypid() or calling aul_get_preinit_root_path() is failed, the method tries to get the application information using pkgmgr-info API. Change-Id: I43c2261dc4822c66b61cccd2c7db066858c19709 Signed-off-by: Hwankyu Jhun --- diff --git a/aul/app_info/app_info.cc b/aul/app_info/app_info.cc index cac07dd..fe3dd9e 100644 --- a/aul/app_info/app_info.cc +++ b/aul/app_info/app_info.cc @@ -84,7 +84,19 @@ AppInfo* AppInfo::Get(int pid) { if (ret != AUL_R_OK) return nullptr; - return Get(app_id, getuid()); + if (pid != getpid()) + return Get(app_id, getuid()); + + char pkg_id[256] = { 0, }; + ret = aul_app_get_appid_bypid(pid, pkg_id, sizeof(pkg_id)); + if (ret != AUL_R_OK) + return Get(app_id, getuid()); + + const char* root_path = aul_get_preinit_root_path(); + if (root_path == nullptr) + return Get(app_id, getuid()); + + return Builder().SetAppId(app_id).SetPkgId(pkg_id).SetRootPath(root_path); } AppInfo::AppInfo(std::string app_id, std::string pkg_id, std::string root_path)