From 66f28706481591e3676df6278e985fec89f248f6 Mon Sep 17 00:00:00 2001 From: Hyunho Kang Date: Wed, 24 Aug 2016 10:47:29 +0900 Subject: [PATCH] Add watch app handling feature to widget_viewer_sdk Change-Id: Id1d3835ab24bf10824bc43a6a4e058a029a52a2f Signed-off-by: Hyunho Kang --- packaging/libwidget_viewer.spec | 1 + widget_viewer_sdk/CMakeLists.txt | 6 +- widget_viewer_sdk/src/main.c | 118 +++++++++++++++++++++------------------ 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/packaging/libwidget_viewer.spec b/packaging/libwidget_viewer.spec index 834a90b..7a9fd5a 100644 --- a/packaging/libwidget_viewer.spec +++ b/packaging/libwidget_viewer.spec @@ -34,6 +34,7 @@ BuildRequires: pkgconfig(dali-adaptor) BuildRequires: pkgconfig(dali-toolkit) BuildRequires: pkgconfig(pepper-dali) BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(appsvc) %description API for creating a new instance of the widget and managing its life-cycle. diff --git a/widget_viewer_sdk/CMakeLists.txt b/widget_viewer_sdk/CMakeLists.txt index 529a329..fa9d9db 100644 --- a/widget_viewer_sdk/CMakeLists.txt +++ b/widget_viewer_sdk/CMakeLists.txt @@ -39,9 +39,10 @@ pkg_check_modules(sdk_pkgs REQUIRED edje vconf bundle - dlog + dlog widget_service efl-extension + appsvc ) ADD_DEFINITIONS("-DWIDGET_EVAS_RESOURCE_EDJ=\"${EDJDIR}/widget_viewer_sdk.edj\"") @@ -52,9 +53,10 @@ ADD_DEFINITIONS(${sdk_pkgs_CFLAGS}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../widget_viewer_evas/include) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../watch-control/include) ADD_EXECUTABLE(${PROJECT_NAME} src/main.c) -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${sdk_pkgs_LDFLAGS} "-lm -pie -fPIC" widget_viewer_evas) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${sdk_pkgs_LDFLAGS} "-lm -pie -fPIC" widget_viewer_evas watch-control) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PKGNAME}.xml DESTINATION /usr/share/packages) diff --git a/widget_viewer_sdk/src/main.c b/widget_viewer_sdk/src/main.c index bbd71a3..8a28cf0 100644 --- a/widget_viewer_sdk/src/main.c +++ b/widget_viewer_sdk/src/main.c @@ -31,6 +31,11 @@ #include #include +#include +#include +#include + + int errno; #include "main.h" @@ -209,6 +214,23 @@ static void layout_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info } } +static void __watch_added(void *data, Evas_Object *obj, void *event_info) +{ + LOGD("watch added"); + Evas_Object *clock = (Evas_Object *)event_info; + + evas_object_resize(s_info.win, s_info.w, s_info.h); + evas_object_resize(clock, s_info.w, s_info.h); + + evas_object_show(clock); + evas_object_show(s_info.win); +} + +static void __watch_removed(void *data, Evas_Object *obj, void *event_info) +{ + LOGD("watch removed"); +} + static bool app_create(void *data) { load_configuration(); @@ -278,6 +300,7 @@ static bool app_create(void *data) eext_object_event_callback_add(s_info.win, EEXT_CALLBACK_BACK, back_key_cb, NULL); evas_object_show(s_info.win); + return true; } @@ -639,74 +662,63 @@ static void _app_control(app_control_h service, void *data) { char *widget_id = NULL; int ret; + int lazy_loader = 0; + char *app_type = NULL; + pkgmgrinfo_appinfo_h app_info; + app_control_h watch_control = NULL; + bundle *b; ret = app_control_get_extra_data(service, WIDGET_APPID, &widget_id); if (ret == APP_CONTROL_ERROR_NONE) { -#if 0 - char *category; -#endif - int lazy_loader = 0; DbgPrint("Loading a widget: [%s]\n", widget_id); if (!widget_id) return; -#if 0 - category = widget_service_get_category(widget_id); - if (category) { - if (!strcmp(category, WATCH_CATEGORY)) { - /** - * Trying to unload the WATCH from W-HOME - */ - char *watch_id; - int need_to_unload = 0; - watch_id = vconf_get_str(VCONFKEY_WMS_CLOCKS_SET_IDLE); - if (watch_id) { - need_to_unload = !!strcmp(watch_id, s_info.default_watch); - free(watch_id); - } - - if (need_to_unload) { - DbgPrint("Watch: [%s] - unload first, SET(%s)\n", widget_id, s_info.default_watch); - ret = vconf_set_str(VCONFKEY_WMS_CLOCKS_SET_IDLE, s_info.default_watch); - if (ret != 0) - ErrPrint("If this is not wearable, there is no such CLOCKS_SET_IDLE key (%d)\n", ret); - - /** - * @note - * In this case, we should waiting some time to unload watch first. - */ - lazy_loader = 1; - } - } - free(category); + ret = pkgmgrinfo_appinfo_get_appinfo(widget_id, &app_info); + if (PMINFO_R_OK != ret) { + ErrPrint("fail to get %s appinfo %d", widget_id, ret); + return; } -#endif - ret = unload_widget(); - ret = prepare_widget(widget_id, service); + pkgmgrinfo_appinfo_get_component_type(app_info, &app_type); + if (app_type != NULL && strcmp(app_type, "watchapp") == 0) { + watch_manager_init(s_info.win); + evas_object_smart_callback_add(s_info.win, WATCH_SMART_SIGNAL_ADDED, __watch_added, NULL); + evas_object_smart_callback_add(s_info.win, WATCH_SMART_SIGNAL_REMOVED, __watch_removed, NULL); + + watch_manager_get_app_control(widget_id, &watch_control); + app_control_to_bundle(watch_control, &b); + appsvc_run_service(b, 0, NULL, NULL); + DbgPrint("appsvc_run_service returns [%d]", widget_id); + app_control_destroy(watch_control); + } else { + ret = unload_widget(); + ret = prepare_widget(widget_id, service); - if (s_info.lazy_widget_loader) { - char *tmp; - tmp = ecore_timer_del(s_info.lazy_widget_loader); - free(tmp); - } + if (s_info.lazy_widget_loader) { + char *tmp; + tmp = ecore_timer_del(s_info.lazy_widget_loader); + free(tmp); + } - if (lazy_loader) { - DbgPrint("Load a watch after some time later (%lf)\n", s_info.lazy_watch_time); - s_info.lazy_widget_loader = ecore_timer_add(s_info.lazy_watch_time, lazy_widget_loader_cb, widget_id); - if (!s_info.lazy_widget_loader) { - ErrPrint("Unable to fire the timer\n"); + if (lazy_loader) { + DbgPrint("Load a watch after some time later (%lf)\n", s_info.lazy_watch_time); + s_info.lazy_widget_loader = ecore_timer_add(s_info.lazy_watch_time, lazy_widget_loader_cb, widget_id); + if (!s_info.lazy_widget_loader) { + ErrPrint("Unable to fire the timer\n"); + lazy_widget_loader_cb(widget_id); + } + /** + * @note + * widget_id will be deleted from lazy_widget_loader_cb. or return value of ecore_timer_del(). + */ + } else { + DbgPrint("Immediately loads the watch[%s]\n", widget_id); lazy_widget_loader_cb(widget_id); } - /** - * @note - * widget_id will be deleted from lazy_widget_loader_cb. or return value of ecore_timer_del(). - */ - } else { - DbgPrint("Immediately loads the watch[%s]\n", widget_id); - lazy_widget_loader_cb(widget_id); } + } else { /** * @note -- 2.7.4