Fixed the default viewer app to run async 20/146220/4
authorMyungki Lee <mk5004.lee@samsung.com>
Fri, 25 Aug 2017 09:46:44 +0000 (18:46 +0900)
committerMyungki Lee <mk5004.lee@samsung.com>
Mon, 28 Aug 2017 04:52:17 +0000 (13:52 +0900)
Change-Id: I1de15c4dc9a62aad35b1b899d21e625c1caff375
Signed-off-by: Myungki Lee <mk5004.lee@samsung.com>
include/notification_viewer.h
src/notification_viewer.c

index f1ed4c84264180d9e7a1fc18de08064bc73f4a33..f75bdf40fc712af01401ec517d3295a4438ce373 100644 (file)
@@ -18,6 +18,6 @@
 #define __NOTIFICATION_VIEWER_H__
 
 int notification_get_default_viewer(const char *path, char **default_viewer);
-int notification_launch_default_viewer(const char *default_viewer, int priv_id);
+int notification_launch_default_viewer(const char *default_viewer, int priv_id, uid_t uid);
 
 #endif /* __NOTIFICATION_VIEWER_H__ */
index b28fd8a465e54e9ef5f4974ef663c2d11439c425..52d7f9b94ad3b1b2eb915809e523e209b5d5040b 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <app_control_internal.h>
 #include <iniparser.h>
+#include <aul_svc.h>
 
 #include <notification.h>
 #include <notification_debug.h>
@@ -50,43 +51,46 @@ EXPORT_API int notification_get_default_viewer(const char *path, char **default_
        return 0;
 }
 
-EXPORT_API int notification_launch_default_viewer(const char *default_viewer, int priv_id)
+EXPORT_API int notification_launch_default_viewer(const char *default_viewer, int priv_id, uid_t uid)
 {
        int ret;
        char buf[32] = {0,};
-       app_control_h app_control = NULL;
+       bundle *b = NULL;
 
-       ret = app_control_create(&app_control);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               NOTIFICATION_ERR("Failed to create app_control[%x]", ret);
-               goto out;
+       b = bundle_create();
+       if (b == NULL) {
+               NOTIFICATION_ERR("Failed to create bundle");
+               return NOTIFICATION_ERROR_OUT_OF_MEMORY;
        }
 
-       ret = app_control_set_app_id(app_control, default_viewer);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               NOTIFICATION_ERR("Failed to set app id to app_control[%x]", ret);
+       ret = aul_svc_set_appid(b, default_viewer);
+       if (ret != AUL_SVC_RET_OK) {
+               NOTIFICATION_ERR("Failed to set appid to bundle[%x]", ret);
                goto out;
        }
 
        snprintf(buf, sizeof(buf), "%d", priv_id);
 
-       ret = app_control_add_extra_data(app_control, "NOTIFICATION_PRIVATE_ID", buf);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               NOTIFICATION_ERR("Failed to add extra data to app_control[%x]", ret);
+       ret = aul_svc_add_data(b, "NOTIFICATION_PRIVATE_ID", buf);
+       if (ret != AUL_SVC_RET_OK) {
+               NOTIFICATION_ERR("Failed to add extra_data[%x]", ret);
                goto out;
        }
 
-       ret = app_control_send_launch_request(app_control, NULL, NULL);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               NOTIFICATION_ERR("Failed to request app launch[%x]", ret);
-               goto out;
+       ret = aul_svc_run_service_async_for_uid(b, 0, NULL, NULL, uid);
+       if (ret < 0) {
+               NOTIFICATION_ERR("Failed to request app launch[%d]", ret);
+       } else {
+               NOTIFICATION_INFO("successed to request app launch[%d],[%d]",
+                               ret, uid);
+               ret = APP_CONTROL_ERROR_NONE;
        }
 
 out:
-       if (app_control)
-               app_control_destroy(app_control);
+       if (b)
+               bundle_free(b);
 
-       if (ret == APP_CONTROL_ERROR_NONE)
+       if (ret == 0)
                ret = NOTIFICATION_ERROR_NONE;
        else
                ret = NOTIFICATION_ERROR_IO_ERROR;