From: Hyunho Kang Date: Fri, 8 Sep 2017 06:09:00 +0000 (+0900) Subject: Check watch pkgid in sdk viewer when watch changed X-Git-Tag: submit/tizen/20170925.023149~1^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4108cc6e2aa8f132625c21e58db4f249e5c9d9f;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Check watch pkgid in sdk viewer when watch changed Change-Id: I97e54e9c1b818018ab63c9642f54e475822dfc92 Signed-off-by: Hyunho Kang --- diff --git a/widget_viewer_sdk/src/main.c b/widget_viewer_sdk/src/main.c index 90528970..d6ad83f5 100644 --- a/widget_viewer_sdk/src/main.c +++ b/widget_viewer_sdk/src/main.c @@ -101,7 +101,7 @@ static struct info { #define LONG_PRESS 1.0f #define CONF_FNAME "/etc/widget_viewer_sdk.conf" -static char *__watch_appid; +static char *__watch_pkgid; static Evas_Object *__clock; static void back_key_cb(void *data, Evas_Object *obj, void *event_info) @@ -282,9 +282,10 @@ void __clock_vconf_cb(keynode_t *node, void *data) { char *cur_watch = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE); - LOGD("watch now %s, changed %s", __watch_appid, cur_watch); - if (cur_watch != NULL && __watch_appid != NULL - && strcmp(cur_watch, __watch_appid) == 0) { + LOGD("watch sdk [%s], home [%s]", + __watch_pkgid, cur_watch); + if (cur_watch != NULL && __watch_pkgid != NULL + && strcmp(cur_watch, __watch_pkgid) == 0) { ui_app_exit(); LOGW("same watch displayed on the other viewer EXIT"); } @@ -742,6 +743,29 @@ static void __set_bundle_for_watchapp(bundle *app_control_b, bundle *b) } } +static char *__get_pkgid_by_appid(char *appid) +{ + pkgmgrinfo_appinfo_h handle; + int ret; + char *pkgid = NULL; + char *ret_pkgid = NULL; + + ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle); + if (ret != PMINFO_R_OK) + return NULL; + + ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid); + if (ret != PMINFO_R_OK) { + pkgmgrinfo_appinfo_destroy_appinfo(handle); + return NULL; + } + + ret_pkgid = strdup(pkgid); + pkgmgrinfo_appinfo_destroy_appinfo(handle); + + return ret_pkgid; +} + static void _app_control(app_control_h service, void *data) { char *widget_id = NULL; @@ -773,14 +797,17 @@ static void _app_control(app_control_h service, void *data) cur_watch = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE); if (widget_id != NULL) { - if (cur_watch != NULL && - strcmp(cur_watch, widget_id) == 0) { + if (__watch_pkgid) { + free(__watch_pkgid); + __watch_pkgid = NULL; + } + __watch_pkgid = __get_pkgid_by_appid(widget_id); + + if (cur_watch != NULL && __watch_pkgid != NULL && + strcmp(cur_watch, __watch_pkgid) == 0) { vconf_set_str(VCONFKEY_WMS_CLOCKS_SET_IDLE, DEFAULT_WATCH); } - if (__watch_appid) - free(__watch_appid); - __watch_appid = strdup(widget_id); } evas_object_resize(s_info.win, s_info.w, s_info.h);