From: SukHyung, Kang Date: Fri, 21 Feb 2020 05:15:31 +0000 (+0900) Subject: Implement notify ambient event X-Git-Tag: submit/tizen/20200226.074332~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F225579%2F4;p=platform%2Fcore%2Fappfw%2Fwidget-viewer.git Implement notify ambient event Change-Id: Ia2fc51f312d93320e87c97dc5a53308fd6dc86bf Signed-off-by: SukHyung, Kang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 88397565..5c18f42e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ ADD_SUBDIRECTORY(tool) ADD_DEPENDENCIES(widget_viewer_sdk widget_viewer_evas) ADD_DEPENDENCIES(widget_viewer_sdk watch-holder) -ENABLE_TESTING() +#ENABLE_TESTING() SET(WIDGET_VIEWER_UNIT_TESTS widget-viewer_unittests) ADD_TEST(NAME ${WIDGET_VIEWER_UNIT_TESTS} COMMAND ${WIDGET_VIEWER_UNIT_TESTS} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/unittest) diff --git a/ambient-viewer/CMakeLists.txt b/ambient-viewer/CMakeLists.txt index 00a2613e..d3fe7741 100644 --- a/ambient-viewer/CMakeLists.txt +++ b/ambient-viewer/CMakeLists.txt @@ -13,6 +13,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) INCLUDE(FindPkgConfig) pkg_check_modules(ambient-viewer REQUIRED + aul dlog bundle elementary diff --git a/ambient-viewer/src/ambient-viewer.cc b/ambient-viewer/src/ambient-viewer.cc index 45d1715b..2c41e876 100644 --- a/ambient-viewer/src/ambient-viewer.cc +++ b/ambient-viewer/src/ambient-viewer.cc @@ -15,6 +15,8 @@ */ #include +#include +#include #include "ambient-viewer.h" #include "top-app-surface.h" @@ -49,6 +51,51 @@ void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender, int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir, bundle* extra) { + bundle* b; + bundle_raw* raw = nullptr; + int len; + int ret; + char ambient_mode[32] = {0, }; + + b = bundle_create(); + if (b == NULL) { + return -1; + } + + snprintf(ambient_mode, sizeof(ambient_mode), "%d", (int)enter); + bundle_add_str(b, "__AMBIENT_MODE__", ambient_mode); + + bundle_encode(extra, &raw, &len); + bundle_add_str(b, "__AMBIENT_EXTRA__", (const char*)raw); + + switch (dir) { + case DIRECTION_VIEWER_AND_WATCH: + ret = aul_app_com_send("watch.ambientchange", b); + if (ret < 0) + LOGE("notify watch ambient error:%d", ret); + break; + case DIRECTION_VIEWER_AND_TOP_APP: + ret = aul_app_com_send("ui.ambientchange", b); + if (ret < 0) + LOGE("notify app ambient error:%d", ret); + break; + case DIRECTION_ALL: + ret = aul_app_com_send("watch.ambientchange", b); + if (ret < 0) + LOGE("notify watch ambient error:%d", ret); + + ret = aul_app_com_send("ui.ambientchange", b); + if (ret < 0) + LOGE("notify app ambient error:%d", ret); + break; + } + + if (b) + bundle_free(b); + + if (raw) + free(raw); + return 0; }