Check watch pkgid in sdk viewer when watch changed 54/148554/4
authorHyunho Kang <hhstark.kang@samsung.com>
Fri, 8 Sep 2017 06:09:00 +0000 (15:09 +0900)
committerSemun Lee <semun.lee@samsung.com>
Tue, 12 Sep 2017 05:45:10 +0000 (05:45 +0000)
Change-Id: I97e54e9c1b818018ab63c9642f54e475822dfc92
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
widget_viewer_sdk/src/main.c

index 90528970f0dac732d9efc45434ca949a20fd7400..d6ad83f58aae4c72e698afb6c9564d5cfc314b1e 100644 (file)
@@ -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);