Use real app ID when getting app component type 01/231001/3
authorYunjin Lee <yunjin-.lee@samsung.com>
Thu, 16 Apr 2020 11:51:46 +0000 (20:51 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Fri, 17 Apr 2020 07:11:56 +0000 (16:11 +0900)
- 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 <yunjin-.lee@samsung.com>
src/notification-daemon/Logic.cpp
src/notification-daemon/event/Event.h
src/notification-daemon/ui/UIAppInvoker.cpp
src/notification-daemon/ui/UIAppInvoker.h

index 993c8f162b7892e7d0097a7baef73a039903eedb..b9ec572bc12e82e987fb41b6c455fbd8ea53579e 100644 (file)
@@ -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<IUIEvent>(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, conn.appId, privacies))};
+    FdEvent fdEvent{eventId, popup_id, std::shared_ptr<IUIEvent>(new ExtUIEvent(popup_id, conn.pid, conn.pkgId, privacies))};
     fdEvent.event->process();
     m_pendingEvents.emplace_back(std::move(fdEvent));
 }
index f06e4fd7f894c1203d2e029b97dc9ce732d1c2cc..79003e87c41d96850d96a18022bc2bd57c74d658 100644 (file)
@@ -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<std::string> privacies)
+    ExtUIEvent(int popup_id, pid_t caller_app_pid, std::string pkg_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_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<std::string> m_privacies;
 };
 
index 0778719e5666a34ac4290f891bdbeea138fd3e44..01929463e363cc74e67967dac2f0393deee9278e 100644 (file)
@@ -28,6 +28,7 @@
 #include <component_manager.h>
 
 #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<std::string> &privacies) {
+bool UIAppInvoker::invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_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];
@@ -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;
index 71403950390e8cd3967a0315834886e2999644fa..ba83eaa65c2ccf7b7c02345bf86b8cbe120a811b 100644 (file)
@@ -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<std::string> &privacies);
+    bool invoke(int popup_id, pid_t caller_app_pid, const std::string &pkg_id, const std::vector<std::string> &privacies);
 } // UIAppInvoker
 
 } // namespace Notification