From: Yunjin Lee Date: Thu, 16 Apr 2020 11:51:46 +0000 (+0900) Subject: Use real app ID when getting app component type X-Git-Tag: submit/tizen/20200420.103808~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72c4b76a0e030f290c50cfe9dadc4fc7b8de270f;p=platform%2Fcore%2Fsecurity%2Faskuser.git Use real app ID when getting app component type - In current implementation, appid is application's main app ID not real app ID for caller app pid. It can cause problem when getting app component type of widget app that is included in the UI app package. It misguide app component type as UI app and cause aul_app_forward() failure. Change-Id: I248631661dfa73e5452021b7bf2cf9584499fcc0 Signed-off-by: Yunjin Lee --- diff --git a/src/notification-daemon/Logic.cpp b/src/notification-daemon/Logic.cpp index 993c8f1..b9ec572 100644 --- a/src/notification-daemon/Logic.cpp +++ b/src/notification-daemon/Logic.cpp @@ -195,7 +195,7 @@ void Logic::addEvent(Protocol::ConnectionFd fd, Protocol::RequestId id, Protocol ConnectionInfo &conn = m_connToInfo[fd]; - FdEvent fdEvent{eventId, popup_id, std::shared_ptr(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, conn.appId, privacies))}; + FdEvent fdEvent{eventId, popup_id, std::shared_ptr(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, privacies))}; fdEvent.event->process(); m_pendingEvents.emplace_back(std::move(fdEvent)); } diff --git a/src/notification-daemon/event/Event.h b/src/notification-daemon/event/Event.h index f06e4fd..79003e8 100644 --- a/src/notification-daemon/event/Event.h +++ b/src/notification-daemon/event/Event.h @@ -43,21 +43,20 @@ protected: class ExtUIEvent : public IUIEvent { public: - ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::string app_id, std::vector privacies) + ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::vector privacies) : IUIEvent(NULL), m_popup_id(popup_id), m_caller_app_pid(caller_app_pid), m_pkg_id(pkg_id), - m_app_id(app_id), m_privacies(privacies) {} virtual void process() { - (void)UIAppInvoker::invoke(m_popup_id, m_caller_app_pid, m_pkg_id, m_app_id, m_privacies); + (void)UIAppInvoker::invoke(m_popup_id, m_caller_app_pid, m_pkg_id, m_privacies); } private: int m_popup_id; pid_t m_caller_app_pid; - std::string m_pkg_id, m_app_id; + std::string m_pkg_id; std::vector m_privacies; }; diff --git a/src/notification-daemon/ui/UIAppInvoker.cpp b/src/notification-daemon/ui/UIAppInvoker.cpp index 0778719..0192946 100644 --- a/src/notification-daemon/ui/UIAppInvoker.cpp +++ b/src/notification-daemon/ui/UIAppInvoker.cpp @@ -28,6 +28,7 @@ #include #define PID_BUFFER_SIZE 64 +#define APPID_BUFFER_SIZE 1024 namespace AskUser { @@ -36,14 +37,15 @@ namespace Notification { const char* LAUNCH_MODE_GROUP = "group"; const char* LAUNCH_MODE_SINGLE = "single"; -const char* get_app_launch_mode(const std::string &pkg_id, const std::string &app_id) +const char* get_app_launch_mode(const std::string &app_id) { + ALOGD("Get app launch mode for app id : " << app_id); app_info_h app_info; int ret = 0; - ret = app_info_create(pkg_id.c_str(), &app_info); + ret = app_info_create(app_id.c_str(), &app_info); if (ret != APP_MANAGER_ERROR_NONE) { - ALOGE("Cannot retrieve app launch mode for pkg : " << pkg_id << " app id : " << app_id); + ALOGE("Cannot retrieve app launch mode for app id : " << app_id); return LAUNCH_MODE_SINGLE; } @@ -52,7 +54,7 @@ const char* get_app_launch_mode(const std::string &pkg_id, const std::string &ap app_info_destroy(app_info); if (ret != APP_MANAGER_ERROR_NONE) { - ALOGE("Cannot get app type for pkg : " << pkg_id << " app id : " << app_id); + ALOGE("Cannot get app type for app id : " << app_id); return LAUNCH_MODE_SINGLE; } @@ -71,7 +73,7 @@ const char* get_app_launch_mode(const std::string &pkg_id, const std::string &ap ret = component_info_create(app_id.c_str(), &component); if (ret) { - ALOGE("Cannot retrieve component info for pkg : " << pkg_id << " app id : " << app_id); + ALOGE("Cannot retrieve component info for app id : " << app_id); return LAUNCH_MODE_SINGLE; } @@ -80,7 +82,7 @@ const char* get_app_launch_mode(const std::string &pkg_id, const std::string &ap component_info_destroy(component); if (ret) { - ALOGE("Cannot retrieve component info for pkg : " << pkg_id << " app id : " << app_id); + ALOGE("Cannot retrieve component info for app id : " << app_id); return LAUNCH_MODE_SINGLE; } @@ -88,7 +90,7 @@ const char* get_app_launch_mode(const std::string &pkg_id, const std::string &ap } } -bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::string &app_id, const std::vector &privacies) { +bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::vector &privacies) { ALOGD("Launching popup app for popup_id: " << popup_id << ", pkg_id of requestor app: " << pkg_id); char buf[PID_BUFFER_SIZE]; @@ -96,6 +98,7 @@ bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string char** privacies_c = NULL; int ret = -1; size_t i = 0; + char real_app_id[APPID_BUFFER_SIZE]; b = bundle_create(); @@ -162,7 +165,13 @@ bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string } /* Sets App Launch Mode */ - ret = aul_svc_set_launch_mode(b, get_app_launch_mode(pkg_id, app_id)); + ret = aul_app_get_appid_bypid(caller_app_pid, real_app_id, APPID_BUFFER_SIZE); + if (ret < 0) { + ALOGE("aul_app_get_appid_bypid() failed. ret = " << ret); + goto error_exit; + } + + ret = aul_svc_set_launch_mode(b, get_app_launch_mode(real_app_id)); if (ret < 0) { ALOGE("aul_svc_set_launch_mode() failed. ret = " << ret); goto error_exit; diff --git a/src/notification-daemon/ui/UIAppInvoker.h b/src/notification-daemon/ui/UIAppInvoker.h index 7140395..ba83eaa 100644 --- a/src/notification-daemon/ui/UIAppInvoker.h +++ b/src/notification-daemon/ui/UIAppInvoker.h @@ -31,7 +31,7 @@ namespace AskUser { namespace Notification { namespace UIAppInvoker { - bool invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::string &app_id, const std::vector &privacies); + bool invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::vector &privacies); } // UIAppInvoker } // namespace Notification