Add package id to the lifecycle info 47/91347/2 accepted/tizen/common/20161010.145846 accepted/tizen/ivi/20161010.083244 accepted/tizen/mobile/20161010.083154 accepted/tizen/tv/20161010.083212 accepted/tizen/wearable/20161010.083226 submit/tizen/20161010.043049
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 7 Oct 2016 06:05:27 +0000 (15:05 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 10 Oct 2016 00:39:00 +0000 (09:39 +0900)
Change-Id: I812173fb03a725df74c710fe756d35bc9492f6f6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/widget_app.c

index 60d3d08..c3edd63 100755 (executable)
@@ -84,6 +84,7 @@ static void *app_user_data;
 static char *appid;
 static widget_class_h class_provider;
 static int exit_called;
+static char *package_id;
 
 static void _widget_core_set_appcore_event_cb(void);
 static void _widget_core_unset_appcore_event_cb(void);
@@ -170,6 +171,7 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id,
        int status)
 {
        bundle *b = bundle_create();
+       char pkgid[256] = {0, };
        int ret;
 
        if (b == NULL) {
@@ -177,9 +179,17 @@ static int __send_lifecycle_event(const char *class_id, const char *instance_id,
                return -1; /* LCOV_EXCL_LINE */
        }
 
+       if (package_id == NULL) {
+               ret = aul_app_get_pkgid_bypid(getpid(), pkgid, sizeof(pkgid));
+               if (ret == 0)
+                       package_id = strdup(pkgid);
+       }
+
        bundle_add_str(b, AUL_K_WIDGET_ID, class_id);
        bundle_add_str(b, AUL_K_WIDGET_INSTANCE_ID, instance_id);
        bundle_add_byte(b, AUL_K_WIDGET_STATUS, &status, sizeof(int));
+       if (package_id)
+               bundle_add_str(b, AUL_K_PKGID, package_id);
 
        _D("send lifecycle %s(%d)", instance_id, status);
        ret = aul_app_com_send("widget.status", b);
@@ -940,6 +950,12 @@ static void __after_loop()
        _widget_app_free_viewer_endpoint();
        _widget_core_unset_appcore_event_cb();
        __free_handler_list();
+
+       if (package_id) {
+               free(package_id);
+               package_id = NULL;
+       }
+
        elm_shutdown();
 }