From: Tomasz Swierczek Date: Thu, 26 Mar 2020 11:02:58 +0000 (+0100) Subject: Change popup app launch mode depending on app type X-Git-Tag: accepted/tizen/5.5/unified/20200331.051826~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e757ca35da0acac25f0cb34db573d37451502cf0;p=platform%2Fcore%2Fsecurity%2Faskuser.git Change popup app launch mode depending on app type Not all Tizen app types can be launched in a group. Change-Id: I60e148fe06798a68dc049e112c12a1fe8631e62a --- diff --git a/packaging/askuser-notification.spec b/packaging/askuser-notification.spec index 790f871..b4487bc 100644 --- a/packaging/askuser-notification.spec +++ b/packaging/askuser-notification.spec @@ -24,6 +24,8 @@ BuildRequires: pkgconfig(security-privilege-manager) BuildRequires: pkgconfig(security-manager) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(capi-appfw-component-manager) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-ui-efl-util) BuildRequires: pkgconfig(capi-system-info) diff --git a/src/notification-daemon/CMakeLists.txt b/src/notification-daemon/CMakeLists.txt index 1ea1717..dbf5e3e 100644 --- a/src/notification-daemon/CMakeLists.txt +++ b/src/notification-daemon/CMakeLists.txt @@ -11,6 +11,8 @@ PKG_CHECK_MODULES(ASKUSER_NOTIFICATION_DEP libsystemd vconf glib-2.0 + capi-appfw-app-manager + capi-appfw-component-manager capi-ui-efl-util capi-system-info efl-extension diff --git a/src/notification-daemon/Logic.cpp b/src/notification-daemon/Logic.cpp index b9ec572..993c8f1 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, privacies))}; + FdEvent fdEvent{eventId, popup_id, std::shared_ptr(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, conn.appId, 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 79003e8..f06e4fd 100644 --- a/src/notification-daemon/event/Event.h +++ b/src/notification-daemon/event/Event.h @@ -43,20 +43,21 @@ protected: class ExtUIEvent : public IUIEvent { public: - ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::vector privacies) + ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::string app_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_privacies); + (void)UIAppInvoker::invoke(m_popup_id, m_caller_app_pid, m_pkg_id, m_app_id, m_privacies); } private: int m_popup_id; pid_t m_caller_app_pid; - std::string m_pkg_id; + std::string m_pkg_id, m_app_id; std::vector m_privacies; }; diff --git a/src/notification-daemon/ui/UIAppInvoker.cpp b/src/notification-daemon/ui/UIAppInvoker.cpp index b545d1f..0778719 100644 --- a/src/notification-daemon/ui/UIAppInvoker.cpp +++ b/src/notification-daemon/ui/UIAppInvoker.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #define PID_BUFFER_SIZE 64 @@ -31,7 +33,62 @@ namespace AskUser { namespace Notification { -bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::vector &privacies) { +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) +{ + app_info_h app_info; + int ret = 0; + + ret = app_info_create(pkg_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); + return LAUNCH_MODE_SINGLE; + } + + app_info_app_component_type_e app_type; + ret = app_info_get_app_component_type(app_info, &app_type); + app_info_destroy(app_info); + + if (ret != APP_MANAGER_ERROR_NONE) { + ALOGE("Cannot get app type for pkg : " << pkg_id << " app id : " << app_id); + return LAUNCH_MODE_SINGLE; + } + + switch(app_type) { + case APP_INFO_APP_COMPONENT_TYPE_SERVICE_APP: + case APP_INFO_APP_COMPONENT_TYPE_WIDGET_APP: + case APP_INFO_APP_COMPONENT_TYPE_WATCH_APP: + return LAUNCH_MODE_SINGLE; + + case APP_INFO_APP_COMPONENT_TYPE_UI_APP : + return LAUNCH_MODE_GROUP; + + case APP_INFO_APP_COMPONENT_TYPE_COMPONENT_BASED_APP: + default: + component_info_h component; + ret = component_info_create(app_id.c_str(), &component); + + if (ret) { + ALOGE("Cannot retrieve component info for pkg : " << pkg_id << " app id : " << app_id); + return LAUNCH_MODE_SINGLE; + } + + component_info_component_type_e component_type; + ret = component_info_get_component_type(component, &component_type); + component_info_destroy(component); + + if (ret) { + ALOGE("Cannot retrieve component info for pkg : " << pkg_id << " app id : " << app_id); + return LAUNCH_MODE_SINGLE; + } + + return component_type == COMPONENT_INFO_COMPONENT_TYPE_FRAME ? LAUNCH_MODE_GROUP : LAUNCH_MODE_SINGLE; + } +} + +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) { ALOGD("Launching popup app for popup_id: " << popup_id << ", pkg_id of requestor app: " << pkg_id); char buf[PID_BUFFER_SIZE]; @@ -104,8 +161,8 @@ bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string goto error_exit; } - /* Sets App Group Launch Mode */ - ret = aul_svc_set_launch_mode(b, "group"); + /* Sets App Launch Mode */ + ret = aul_svc_set_launch_mode(b, get_app_launch_mode(pkg_id, 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 ba83eaa..7140395 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::vector &privacies); + bool invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::string &app_id, const std::vector &privacies); } // UIAppInvoker } // namespace Notification