From 0c9faf0db7a4b3776c9a097e6952f8393087f01a Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 22 Feb 2017 10:33:32 +0900 Subject: [PATCH 01/16] Send FG/BG signal to resourced - resourced should know the FG/BG status to control oom score Change-Id: Ieab8aa28f9f80bbb087cef1f662c58ad8e4cb3de Signed-off-by: Junghoon Park --- src/widget_app.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/widget_app.c b/src/widget_app.c index b3c18c5..3911a6d 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -16,6 +16,7 @@ #include +#include #include #include @@ -50,6 +51,9 @@ #define STR_MAX_BUF 128 #define LOG_TAG "CAPI_WIDGET_APPLICATION" #define K_REASON "__WC_K_REASON__" +#define APP_TYPE_WIDGET "widgetapp" +#define STATUS_FOREGROUND "fg" +#define STATUS_BACKGROUND "bg" typedef enum _widget_obj_state_e { WC_READY = 0, @@ -86,6 +90,7 @@ static char *appid; static widget_class_h class_provider; static int exit_called; static char *package_id; +static bool fg_signal; static void _widget_core_set_appcore_event_cb(void); static void _widget_core_unset_appcore_event_cb(void); @@ -149,6 +154,28 @@ static widget_context_s *__find_context_by_id(const char *id) return ret->data; } +static gint __comp_by_state(gconstpointer a, gconstpointer b) +{ + widget_context_s *wc = (widget_context_s *)a; + + if (wc->state == (widget_obj_state_e)GPOINTER_TO_INT(b)) + return 0; + + return -1; +} + +static widget_context_s *__find_context_by_state(widget_obj_state_e state) +{ + GList *ret; + GList *contexts = _widget_app_get_contexts(); + + ret = g_list_find_custom(contexts, GINT_TO_POINTER((int)state), __comp_by_state); + if (ret == NULL) + return NULL; + + return ret->data; +} + static gint __comp_by_win(gconstpointer a, gconstpointer b) { int win = GPOINTER_TO_INT(b); @@ -283,6 +310,15 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd if (send_update) { ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_RESUME, NULL); + if (!fg_signal) { + _D("Send fg signal to resourceD"); + aul_send_app_status_change_signal(getpid(), + appid, + package_id, + STATUS_FOREGROUND, + APP_TYPE_WIDGET); + fg_signal = true; + } } else { ret = 0; } @@ -318,6 +354,16 @@ static int __instance_pause(widget_class_h handle, const char *id, int send_upda if (send_update) { ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_PAUSE, NULL); + wc = __find_context_by_state(WC_RUNNING); + if (!wc && fg_signal) { + _D("Send bg signal to resourceD"); + aul_send_app_status_change_signal(getpid(), + appid, + package_id, + STATUS_BACKGROUND, + APP_TYPE_WIDGET); + fg_signal = false; + } } else { ret = 0; } -- 2.7.4 From dad8b9e077617e32e5c62fb6b6716dc04249f679 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 16 Mar 2017 11:39:08 +0900 Subject: [PATCH 02/16] Add log messages Change-Id: I9cc598c0b9252b16946aa93771290538854ddd68 Signed-off-by: Hwankyu Jhun --- src/widget_app.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget_app.c b/src/widget_app.c index 3911a6d..6cedfa8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -455,8 +455,10 @@ static int __instance_create(widget_class_h handle, const char *id, const char * bundle *content_info = NULL; wc = (widget_context_s *)calloc(1, sizeof(widget_context_s)); - if (!wc) + if (!wc) { + _E("Out of memory"); return WIDGET_ERROR_OUT_OF_MEMORY; + } wc->state = WC_READY; wc->id = strdup(id); @@ -473,6 +475,7 @@ static int __instance_create(widget_class_h handle, const char *id, const char * ret = handle->ops.create(wc, content_info, w, h, handle->user_data); if (ret < 0) { + _W("Create callback resturns error(%d)", ret); /* TODO send abort */ } else { ret = __send_update_status(handle->classid, wc->id, -- 2.7.4 From 48f9d97a5d930e13ad80e318bdd2c7e6bfab0020 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Fri, 17 Mar 2017 22:59:28 +0900 Subject: [PATCH 03/16] Handle widget resize event Change-Id: I8a6a8cc7be128ebd8720bb2bd6a0794385a2b97a Signed-off-by: Hyunho Kang (cherry picked from commit e14b8629ef2df41c3a018aaed9f2d40a791c03ff) --- src/widget_app.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget_app.c b/src/widget_app.c index 6cedfa8..a5a5bdb 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -634,6 +634,7 @@ static void __control(bundle *b) __instance_create(handle, id, content, w, h); } else if (strcmp(operation, "resize") == 0) { __resize_window(id, w, h); + __instance_resize(handle, id, w, h); } else if (strcmp(operation, "update") == 0) { if (id) __instance_update(handle, id, force, content); -- 2.7.4 From 6fdbff007910db7fca2b6d0cddee15c10e477491 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 17 Mar 2017 16:53:20 +0900 Subject: [PATCH 04/16] Send create aborted event to the widget viewer Requires: - https://review.tizen.org/gerrit/119553 Change-Id: Iaac8a02534fd72381a270aa00e00de59756559f0 Signed-off-by: Hwankyu Jhun (cherry picked from commit fcbfa76f54caaff86e2ff9648d420f1338854af8) --- src/widget_app.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/widget_app.c b/src/widget_app.c index a5a5bdb..5995238 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -476,7 +476,17 @@ static int __instance_create(widget_class_h handle, const char *id, const char * ret = handle->ops.create(wc, content_info, w, h, handle->user_data); if (ret < 0) { _W("Create callback resturns error(%d)", ret); - /* TODO send abort */ + ret = __send_update_status(handle->classid, wc->id, + WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL); + _widget_app_remove_context(wc); + if (wc->id) + free(wc->id); + if (wc->content) + free(wc->content); + free(wc); + + if (_widget_app_get_contexts() == NULL && !exit_called) + widget_app_exit(); } else { ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_CREATE, NULL); -- 2.7.4 From 7bd93f1f542237e8313c30f0b2018be0cadcd654 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 13 Apr 2017 20:46:41 +0900 Subject: [PATCH 05/16] Change main loop APIs - Use elm_run instead of ecore_main_loop_begin Change-Id: I613edea999586a27d20eee506aabfcb66bb694fa Signed-off-by: Junghoon Park --- src/widget_app.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/widget_app.c b/src/widget_app.c index 5995238..384f0cd 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -1039,6 +1039,13 @@ static void __after_loop() } elm_shutdown(); + + /* Check loader case */ + if (getenv("AUL_LOADER_INIT")) { + unsetenv("AUL_LOADER_INIT"); + elm_shutdown(); + } + } static void __on_low_memory(keynode_t *key, void *data) @@ -1221,7 +1228,7 @@ EXPORT_API int widget_app_main(int argc, char **argv, return r; } - ecore_main_loop_begin(); + elm_run(); aul_status_update(STATUS_DYING); __after_loop(); @@ -1240,7 +1247,7 @@ EXPORT_API int widget_app_exit(void) exit_called = 1; - ecore_main_loop_quit(); + elm_exit(); return WIDGET_ERROR_NONE; } -- 2.7.4 From 92bdc56b4dbe0d4a75c692a6d1a68344c0db9580 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 31 May 2017 13:25:44 +0900 Subject: [PATCH 06/16] Handle abnormal exit Whlie calling widget_app_exit(), the widget app sends the normal termination signal to the amd. If the amd doesn't get the signal when the widget app is dead, the amd will send the widget fault signal to the widget viewer. Requires: - https://review.tizen.org/gerrit/#/c/131674/ [aul-1] - https://review.tizen.org/gerrit/#/c/131685/ [amd] - https://review.tizen.org/gerrit/#/c/131692/ [widget-service] - https://review.tizen.org/gerrit/#/c/131695/ [widget-viewer] Change-Id: I60076b893ef36c8a43e43669746393b7b98b877f Signed-off-by: Hwankyu Jhun --- src/widget_app.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widget_app.c b/src/widget_app.c index 384f0cd..8790457 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -1248,6 +1248,7 @@ EXPORT_API int widget_app_exit(void) exit_called = 1; elm_exit(); + aul_widget_notify_exit(); return WIDGET_ERROR_NONE; } -- 2.7.4 From e4c76a4930252928b0d183fc6aac09282e9d46d4 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 28 Jun 2017 20:41:33 +0900 Subject: [PATCH 07/16] Use common normal exit notify API - aul_notify_exit https://review.tizen.org/gerrit/#/c/136199/ (amd) https://review.tizen.org/gerrit/#/c/136200/ (aul-1) https://review.tizen.org/gerrit/#/c/136201/ (appcore-widget) https://review.tizen.org/gerrit/#/c/136209/ (widget-service) Change-Id: I92863ca2c88e8ac552012a5b5c4ae4f190833029 Signed-off-by: Hyunho Kang --- src/widget_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget_app.c b/src/widget_app.c index 8790457..3d3fc87 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -1248,7 +1248,7 @@ EXPORT_API int widget_app_exit(void) exit_called = 1; elm_exit(); - aul_widget_notify_exit(); + aul_notify_exit(); return WIDGET_ERROR_NONE; } -- 2.7.4 From 6a1dd11989d25f1b24c6ac04e47eaa577d9f5f88 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Mon, 17 Jul 2017 14:21:40 +0900 Subject: [PATCH 08/16] Remove ECORE_WL_EVENT_WINDOW_SHOW handler Now widget framework can use ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE and ECORE_WL_EVENT_WINDOW_SHOW do not mean window is visible. So, let's make widget resume/pause event depend on ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE Change-Id: Iecad60c477e6f947a898265f9d1e046e51cea8e0 Signed-off-by: Hyunho Kang --- src/widget_app.c | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/src/widget_app.c b/src/widget_app.c index 3d3fc87..db42d0b 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -729,38 +729,6 @@ static void __destroy_all(int reason, int send_update) } } - -static Eina_Bool __show_cb(void *data, int type, void *event) -{ - Ecore_Wl_Event_Window_Show *ev = event; - widget_context_s *cxt = __find_context_by_win(ev->win); - - LOGD("show %d %d", (unsigned int)ev->win, (unsigned int)ev->data[0]); - - if (cxt) - __instance_resume(cxt->provider, cxt->id, UPDATE_ALL); - else - LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */ - - return ECORE_CALLBACK_RENEW; -} - -static Eina_Bool __hide_cb(void *data, int type, void *event) -{ - Ecore_Wl_Event_Window_Hide *ev = event; - widget_context_s *cxt = __find_context_by_win(ev->win); - - - LOGD("hide %d", (unsigned int)ev->win); - - if (cxt) - __instance_pause(cxt->provider, cxt->id, UPDATE_ALL); - else - LOGE("unknown window error: %d", ev->win); /* LCOV_EXCL_LINE */ - - return ECORE_CALLBACK_RENEW; -} - static Eina_Bool __visibility_cb(void *data, int type, void *event) { Ecore_Wl_Event_Window_Visibility_Change *ev = event; @@ -773,7 +741,8 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) return ECORE_CALLBACK_RENEW; } - if (cxt->state == WC_PAUSED && ev->fully_obscured == 0) { + if ((cxt->state == WC_READY || cxt->state == WC_PAUSED) + && ev->fully_obscured == 0) { __instance_resume(cxt->provider, cxt->id, UPDATE_ALL); } else if (cxt->state == WC_RUNNING && ev->fully_obscured == 1) { __instance_pause(cxt->provider, cxt->id, UPDATE_ALL); @@ -813,8 +782,6 @@ static Eina_Bool __configure_cb(void *data, int type, void *event) static void __add_climsg() { - ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, NULL); - ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, NULL); ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE, __visibility_cb, NULL); ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __lower_cb, NULL); ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_CONFIGURE, __configure_cb, NULL); -- 2.7.4 From 092c5946d68397d0e6d7f76ebde387629222c771 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 19 Jul 2017 15:09:56 +0900 Subject: [PATCH 09/16] Implement periodic update - update-callabck should be invoked periodically when the value of 'update-period' is bigger then 0 - Paused widget's update-callback should be deferred until it is resumed - Require https://review.tizen.org/gerrit/#/c/139466/ Change-Id: Id30e4de0576f3cb8b35743fff0ac37989356df6d Signed-off-by: Junghoon Park --- src/widget-private.h | 3 +++ src/widget_app.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/widget-private.h b/src/widget-private.h index 847c099..1c7f519 100644 --- a/src/widget-private.h +++ b/src/widget-private.h @@ -43,6 +43,9 @@ struct _widget_context { Evas_Object *win; int win_id; char *content; + double period; + guint periodic_timer; + bool pending_update; widget_instance_lifecycle_callback_s ops; }; diff --git a/src/widget_app.c b/src/widget_app.c index db42d0b..5cc0e22 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -94,6 +94,7 @@ static bool fg_signal; static void _widget_core_set_appcore_event_cb(void); static void _widget_core_unset_appcore_event_cb(void); +static int __instance_update(widget_class_h handle, const char *id, int force, const char *content); static void __free_handler_cb(gpointer data) { @@ -282,6 +283,26 @@ static int __send_update_status(const char *class_id, const char *instance_id, return 0; } +static gboolean __timeout_cb(gpointer user_data) +{ + widget_context_s *wc = user_data; + + if (wc->state == WC_RUNNING) { + _D("Periodic update!"); + __instance_update(wc->provider, wc->id, 0, NULL); + } else if (wc->state == WC_PAUSED || + wc->state == WC_READY) { + wc->pending_update = true; + if (wc->periodic_timer) { + _D("Remove timer!"); + g_source_remove(wc->periodic_timer); + wc->periodic_timer = 0; + } + } + + return G_SOURCE_CONTINUE; +} + static int __instance_resume(widget_class_h handle, const char *id, int send_update) { widget_context_s *wc = __find_context_by_id(id); @@ -302,6 +323,18 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd return 0; /* LCOV_EXCL_LINE */ } + if (wc->pending_update) { + _D("pending update!"); + wc->pending_update = false; + __instance_update(wc->provider, wc->id, 0, NULL); + + if (wc->period > 0) { + _D("Restart timer!"); + wc->periodic_timer = g_timeout_add_seconds(wc->period, + __timeout_cb, wc); + } + } + if (handle->ops.resume) handle->ops.resume(wc, handle->user_data); @@ -448,7 +481,8 @@ static int __instance_update(widget_class_h handle, const char *id, int force, c } /* LCOV_EXCL_STOP */ -static int __instance_create(widget_class_h handle, const char *id, const char *content, int w, int h) +static int __instance_create(widget_class_h handle, const char *id, + const char *content, int w, int h, double period) { widget_context_s *wc = NULL; int ret = 0; @@ -500,6 +534,12 @@ static int __instance_create(widget_class_h handle, const char *id, const char * if (content_info) bundle_free(content_info); + if (period > 0) { + wc->period = period; + wc->periodic_timer = g_timeout_add_seconds(period, + __timeout_cb, wc); + } + return ret; } @@ -547,6 +587,9 @@ static int __instance_destroy(widget_class_h handle, const char *id, if (wc->content) free(wc->content); + if (wc->periodic_timer) + g_source_remove(wc->periodic_timer); + free(wc); if (_widget_app_get_contexts() == NULL && !exit_called) /* all instance destroyed */ @@ -603,7 +646,11 @@ static void __control(bundle *b) char *remain = NULL; int force; char *force_str = NULL; + double *period = NULL; + double update_period = 0; widget_class_h handle = NULL; + size_t size; + int ret; bundle_get_str(b, WIDGET_K_CLASS, &class_id); /* for previous version compatibility, use appid for default class id */ @@ -640,8 +687,12 @@ static void __control(bundle *b) if (h_str) h = (int)g_ascii_strtoll(h_str, &remain, 10); + ret = bundle_get_byte(b, WIDGET_K_PERIOD, (void **)&period, &size); + if (ret == BUNDLE_ERROR_NONE) + update_period = *period; + if (strcmp(operation, "create") == 0) { - __instance_create(handle, id, content, w, h); + __instance_create(handle, id, content, w, h, update_period); } else if (strcmp(operation, "resize") == 0) { __resize_window(id, w, h); __instance_resize(handle, id, w, h); -- 2.7.4 From def6e470cc48abce1f37937ddc77be77dffb4999 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 20 Jul 2017 14:23:36 +0900 Subject: [PATCH 10/16] Implement widget operation for 'period' - This patch is associated with widget_service_change_period() - This operation is responsible for changing current update-period Change-Id: I32abe9b865941040d223d467984dac8e72e9d748 Signed-off-by: Junghoon Park --- src/widget_app.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/widget_app.c b/src/widget_app.c index 5cc0e22..527cfa8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -598,6 +598,31 @@ static int __instance_destroy(widget_class_h handle, const char *id, return ret; } +static int __instance_change_period(const char *id, double period) +{ + widget_context_s *wc = __find_context_by_id(id); + + if (!wc) { + _E("could not find widget obj: %s", id); + return -1; + } + + if (wc->periodic_timer) { + _D("Remove timer!"); + g_source_remove(wc->periodic_timer); + wc->periodic_timer = 0; + } + + wc->period = period; + if (wc->period > 0) { + _D("Restart timer!"); + wc->periodic_timer = g_timeout_add_seconds(wc->period, + __timeout_cb, wc); + } + + return 0; +} + static widget_class_h __find_class_handler(const char *class_id, widget_class_h handle) { @@ -710,6 +735,8 @@ static void __control(bundle *b) __instance_pause(handle, id, UPDATE_ALL); } else if (strcmp(operation, "terminate") == 0) { __instance_destroy(handle, id, WIDGET_APP_DESTROY_TYPE_TEMPORARY, UPDATE_ALL); + } else if (strcmp(operation, "period") == 0) { + __instance_change_period(id, update_period); } return; -- 2.7.4 From 4e9d331f7b3c4b1157f7be54c0d919e371070fef Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 4 Aug 2017 19:53:49 +0900 Subject: [PATCH 11/16] Add an exception handling about permanent deletion Change-Id: Iea0e8dc778532174c618f07273f793cbee74d35b Signed-off-by: Hwankyu Jhun --- src/widget_app.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/widget_app.c b/src/widget_app.c index 527cfa8..858e7fc 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -91,6 +91,7 @@ static widget_class_h class_provider; static int exit_called; static char *package_id; static bool fg_signal; +static bool is_permanent; static void _widget_core_set_appcore_event_cb(void); static void _widget_core_unset_appcore_event_cb(void); @@ -567,9 +568,11 @@ static int __instance_destroy(widget_class_h handle, const char *id, handle->user_data); if (reason == WIDGET_APP_DESTROY_TYPE_PERMANENT) { + is_permanent = true; event = WIDGET_INSTANCE_EVENT_DESTROY; aul_widget_instance_del(handle->classid, id); } else { + is_permanent = false; ret = __send_update_status(handle->classid, id, WIDGET_INSTANCE_EVENT_EXTRA_UPDATED, content_info); } @@ -1293,7 +1296,8 @@ EXPORT_API int widget_app_exit(void) exit_called = 1; elm_exit(); - aul_notify_exit(); + if (!_widget_app_get_contexts() && is_permanent) + aul_notify_exit(); return WIDGET_ERROR_NONE; } -- 2.7.4 From 1b9774d7a11892bba972697d3cc7f447d97a5efa Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 11 Aug 2017 10:54:53 +0900 Subject: [PATCH 12/16] Add a fallback about updating instance Change-Id: Icc45d5f4fddbadd8deeb81bdd024a47543b2a09c Signed-off-by: Hwankyu Jhun --- src/widget-private.h | 1 + src/widget_app.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/widget-private.h b/src/widget-private.h index 1c7f519..0813ebc 100644 --- a/src/widget-private.h +++ b/src/widget-private.h @@ -47,6 +47,7 @@ struct _widget_context { guint periodic_timer; bool pending_update; widget_instance_lifecycle_callback_s ops; + char *pending_content; }; typedef struct _widget_context widget_context_s; diff --git a/src/widget_app.c b/src/widget_app.c index 858e7fc..50712c8 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -324,10 +324,11 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd return 0; /* LCOV_EXCL_LINE */ } + wc->state = WC_RUNNING; if (wc->pending_update) { _D("pending update!"); wc->pending_update = false; - __instance_update(wc->provider, wc->id, 0, NULL); + __instance_update(wc->provider, wc->id, 0, wc->pending_content); if (wc->period > 0) { _D("Restart timer!"); @@ -339,7 +340,6 @@ static int __instance_resume(widget_class_h handle, const char *id, int send_upd if (handle->ops.resume) handle->ops.resume(wc, handle->user_data); - wc->state = WC_RUNNING; _D("%s is resumed", id); if (send_update) { ret = __send_update_status(handle->classid, wc->id, @@ -425,6 +425,20 @@ static int __instance_resize(widget_class_h handle, const char *id, int w, int h return ret; } +static void __update_pending_content(widget_context_s *wc, const char *content) +{ + if (wc->pending_content) { + free(wc->pending_content); + wc->pending_content = NULL; + } + + if (content) { + wc->pending_content = strdup(content); + if (wc->pending_content == NULL) + _W("Out of memory"); + } +} + /* LCOV_EXCL_START */ static int __instance_update_all(widget_class_h handle, int force, const char *content) { @@ -439,11 +453,17 @@ static int __instance_update_all(widget_class_h handle, int force, const char *c if (handle->ops.update) { while (context) { wc = (widget_context_s *)context->data; + context = context->next; + if (wc->state != WC_RUNNING && !force) { + __update_pending_content(wc, content); + wc->pending_update = true; + continue; + } + handle->ops.update(wc, b, force, handle->user_data); ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_UPDATE, NULL); _D("updated:%s", wc->id); - context = context->next; } } @@ -465,6 +485,12 @@ static int __instance_update(widget_class_h handle, const char *id, int force, c return -1; } + if (wc->state != WC_RUNNING && !force) { + __update_pending_content(wc, content); + wc->pending_update = true; + return 0; + } + if (content) b = bundle_decode((const bundle_raw *)content, strlen(content)); @@ -593,6 +619,9 @@ static int __instance_destroy(widget_class_h handle, const char *id, if (wc->periodic_timer) g_source_remove(wc->periodic_timer); + if (wc->pending_content) + free(wc->pending_content); + free(wc); if (_widget_app_get_contexts() == NULL && !exit_called) /* all instance destroyed */ -- 2.7.4 From 90b1ca01336a649bc742e3c0fcc3ebfeff81854f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Aug 2017 14:05:12 +0900 Subject: [PATCH 13/16] Fix the fallback about setlocale Change-Id: I9f647318f8937fadd1260abb2f94237a3f6b6cb3 Signed-off-by: Hwankyu Jhun --- src/widget-i18n.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget-i18n.c b/src/widget-i18n.c index 39ae5c5..eafb8ed 100755 --- a/src/widget-i18n.c +++ b/src/widget-i18n.c @@ -43,16 +43,16 @@ void _update_lang(void) setenv("LANGUAGE", language, 1); setenv("LANG", lang, 1); setenv("LC_MESSAGES", lang, 1); + free(lang); r = setlocale(LC_ALL, ""); if (r == NULL) { /* LCOV_EXCL_START */ - r = setlocale(LC_ALL, lang); + r = setlocale(LC_ALL, "en_US"); if (r) _D("*****appcore setlocale=%s\n", r); /* LCOV_EXCL_STOP */ } - free(lang); } else { _E("failed to get current language for set lang env"); /* LCOV_EXCL_LINE */ } -- 2.7.4 From 0d0c874054abb035f5246b0f7a482dc1ccb24e7c Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 16 Aug 2017 13:44:32 +0900 Subject: [PATCH 14/16] Do not check period when instance create fail Change-Id: I6870e0ff6bd93f92f100ad8a0baf6f9d84285dce Signed-off-by: Hyunho Kang --- src/widget_app.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/widget_app.c b/src/widget_app.c index 50712c8..22d6920 100755 --- a/src/widget_app.c +++ b/src/widget_app.c @@ -513,6 +513,7 @@ static int __instance_create(widget_class_h handle, const char *id, { widget_context_s *wc = NULL; int ret = 0; + int send_ret = 0; bundle *content_info = NULL; wc = (widget_context_s *)calloc(1, sizeof(widget_context_s)); @@ -537,8 +538,11 @@ static int __instance_create(widget_class_h handle, const char *id, ret = handle->ops.create(wc, content_info, w, h, handle->user_data); if (ret < 0) { _W("Create callback resturns error(%d)", ret); - ret = __send_update_status(handle->classid, wc->id, + send_ret = __send_update_status(handle->classid, wc->id, WIDGET_INSTANCE_EVENT_CREATE_ABORTED, NULL); + if (send_ret < 0) + _E("Fail to send abort status (%d)", send_ret); + _widget_app_remove_context(wc); if (wc->id) free(wc->id); @@ -556,17 +560,17 @@ static int __instance_create(widget_class_h handle, const char *id, content = "NULL"; aul_widget_instance_add(handle->classid, id); + + if (period > 0) { + wc->period = period; + wc->periodic_timer = g_timeout_add_seconds(period, + __timeout_cb, wc); + } } if (content_info) bundle_free(content_info); - if (period > 0) { - wc->period = period; - wc->periodic_timer = g_timeout_add_seconds(period, - __timeout_cb, wc); - } - return ret; } -- 2.7.4 From 00d781b3b371ab4408ae67654f97a33e4533fde6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Aug 2017 16:56:19 +0900 Subject: [PATCH 15/16] Fix the fallback about setting the current locale Change-Id: I8f295236878fc6370242db08ae769eb8c6f9162b Signed-off-by: Hwankyu Jhun --- src/widget-i18n.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widget-i18n.c b/src/widget-i18n.c index eafb8ed..cadf592 100755 --- a/src/widget-i18n.c +++ b/src/widget-i18n.c @@ -48,7 +48,7 @@ void _update_lang(void) r = setlocale(LC_ALL, ""); if (r == NULL) { /* LCOV_EXCL_START */ - r = setlocale(LC_ALL, "en_US"); + r = setlocale(LC_ALL, "en_US.UTF-8"); if (r) _D("*****appcore setlocale=%s\n", r); /* LCOV_EXCL_STOP */ -- 2.7.4 From f30f6036bca79b52a299db8628ebe5512e64ad3c Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 16 Aug 2017 17:12:15 +0900 Subject: [PATCH 16/16] Fix and add the log tag Change-Id: I2fdcd8720d0c3685608177b6acc57772e38ab4cc Signed-off-by: Hwankyu Jhun --- src/widget-i18n.c | 3 +++ src/widget_error.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/widget-i18n.c b/src/widget-i18n.c index cadf592..0d20024 100755 --- a/src/widget-i18n.c +++ b/src/widget-i18n.c @@ -31,6 +31,9 @@ #include "widget-log.h" #include "widget-private.h" +#undef LOG_TAG +#define LOG_TAG "CAPI_WIDGET_APPLICATION" + #define PATH_LOCALE "locale" void _update_lang(void) diff --git a/src/widget_error.c b/src/widget_error.c index bbe1549..37c9120 100755 --- a/src/widget_error.c +++ b/src/widget_error.c @@ -27,7 +27,7 @@ #undef LOG_TAG #endif -#define LOG_TAG "CAPI_WIDGET_APPLICATIO" +#define LOG_TAG "CAPI_WIDGET_APPLICATION" static const char *widget_app_error_to_string(widget_error_e error) { -- 2.7.4