Implement notify ambient event 79/225579/4
authorSukHyung, Kang <shine.kang@samsung.com>
Fri, 21 Feb 2020 05:15:31 +0000 (14:15 +0900)
committerSukHyung, Kang <shine.kang@samsung.com>
Fri, 21 Feb 2020 05:42:35 +0000 (14:42 +0900)
Change-Id: Ia2fc51f312d93320e87c97dc5a53308fd6dc86bf
Signed-off-by: SukHyung, Kang <shine.kang@samsung.com>
CMakeLists.txt
ambient-viewer/CMakeLists.txt
ambient-viewer/src/ambient-viewer.cc

index 8839756..5c18f42 100644 (file)
@@ -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)
index 00a2613..d3fe774 100644 (file)
@@ -13,6 +13,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(ambient-viewer REQUIRED
+       aul
        dlog
        bundle
        elementary
index 45d1715..2c41e87 100644 (file)
@@ -15,6 +15,8 @@
  */
 
 #include <bundle.h>
+#include <dlog.h>
+#include <aul_app_com.h>
 
 #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;
 }