ConnectionInfo &conn = m_connToInfo[fd];
- FdEvent fdEvent{eventId, popup_id, std::shared_ptr<IUIEvent>(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, privacies))};
+ FdEvent fdEvent{eventId, popup_id, std::shared_ptr<IUIEvent>(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, conn.appId, privacies))};
fdEvent.event->process();
m_pendingEvents.emplace_back(std::move(fdEvent));
}
class ExtUIEvent : public IUIEvent {
public:
- ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::vector<std::string> privacies)
+ ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_id, std::string app_id, std::vector<std::string> 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<std::string> m_privacies;
};
#include <aul.h>
#include <aul_svc.h>
+#include <app_manager.h>
+#include <component_manager.h>
#define PID_BUFFER_SIZE 64
namespace Notification {
-bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::vector<std::string> &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<std::string> &privacies) {
ALOGD("Launching popup app for popup_id: " << popup_id << ", pkg_id of requestor app: " << pkg_id);
char buf[PID_BUFFER_SIZE];
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;