ADD_SUBDIRECTORY(watch-control)
ADD_SUBDIRECTORY(frame-broker)
ADD_SUBDIRECTORY(frame-provider)
+ADD_SUBDIRECTORY(ambient-viewer)
ADD_SUBDIRECTORY(tool)
ADD_SUBDIRECTORY(unittest)
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ambient-viewer CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR "${MAJORVER}")
+SET(VERSION "${FULLVER}")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(ambient-viewer REQUIRED
+ dlog
+ bundle
+ elementary
+ evas
+ screen_connector_remote_surface_evas
+ capi-system-info
+)
+
+FOREACH(flag ${ambient-viewer_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline")
+MESSAGE("${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${ambient-viewer_LDFLAGS})
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer.h DESTINATION include/${PROJECT_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer_surface.h DESTINATION include/${PROJECT_NAME})
--- /dev/null
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: ui_app_ambient_viewer
+Description: Support development of the ambient viewer
+Version: @VERSION@
+Libs: -L${libdir} -lambient_viewer
+Cflags: -I${includedir}
+cppflags: -I${includedir}
+
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_H__
+#define __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_H__
+
+#include <stdbool.h>
+#include <bundle.h>
+
+#include "ambient_viewer_surface.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file ambient-viewer.h
+ * @brief
+ */
+
+/**
+ * @addtogroup
+ * @{
+ */
+
+typedef void *ambient_viewer_h;
+
+typedef enum {
+ AMBIENT_VIEWER_EVENT_AOD_READY,
+ AMBIENT_VIEWER_EVENT_WATCH_CHANGED,
+} ambient_event_type_e;
+
+typedef enum {
+ AMBIENT_VIEWER_DIRECTION_WATCH,
+ AMBIENT_VIEWER_DIRECTION_TOP_APP,
+ AMBIENT_VIEWER_DIRECTION_BOTH,
+} ambient_viewer_direction_e;
+
+typedef void (*ambient_viewer_lifecycle_added_cb)(
+ ambient_viewer_surface_h surface, void *user_data);
+
+typedef void (*ambient_viewer_lifecycle_removed_cb)(
+ ambient_viewer_surface_h surface, void *user_data);
+
+typedef void (*ambient_viewer_lifecycle_updated_cb)(
+ ambient_viewer_surface_h surface, void *user_data);
+
+typedef struct _ambient_viewer_lifecycle{
+ ambient_viewer_lifecycle_added_cb added;
+ ambient_viewer_lifecycle_removed_cb deleted;
+ ambient_viewer_lifecycle_updated_cb updated;
+} ambient_viewer_lifecycle_s;
+
+int ambient_viewer_create(Evas_Object *win, ambient_viewer_h *handle);
+
+int ambient_viewer_destroy(ambient_viewer_h handle);
+
+int ambient_viewer_notify_ambient_event(ambient_viewer_h handle, bool enter,
+ ambient_viewer_direction_e dir, bundle *extra);
+
+int ambient_viewer_monitor(ambient_viewer_h handle,
+ ambient_viewer_lifecycle_s lifecycle, void *user_data);
+
+int ambient_viewer_unmonitor(ambient_viewer_h handle);
+
+typedef void (*ambient_viewer_event_cb)(ambient_event_type_e event,
+ const char *sender, bundle *extra, void *user_data);
+
+int ambient_viewer_set_event_listener(ambient_viewer_h handle,
+ ambient_viewer_event_cb callback, void *user_data);
+
+int ambient_viewer_unset_event_listener(ambient_viewer_h handle);
+
+int ambient_viewer_get_watch_surface(ambient_viewer_h handle,
+ ambient_viewer_surface_h *surface);
+
+int ambient_viewer_get_top_app_surface(ambient_viewer_h handle,
+ ambient_viewer_surface_h *surface);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_COMMON_H__
+#define __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_COMMON_H__
+
+#include <tizen.h>
+
+#ifdef EXPORT_API
+#undef EXPORT_API
+#endif
+
+#define EXPORT_API __attribute__((visibility("default")))
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_COMMON_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_SURFACE_H__
+#define __AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_SURFACE_H__
+
+#include <Evas.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file ambient-viewer.h
+ * @brief
+ */
+
+/**
+ * @addtogroup
+ * @{
+ */
+
+typedef void *ambient_viewer_surface_h;
+
+int ambient_viewer_surface_get_cur_image(ambient_viewer_surface_h handle,
+ Evas_Object *image);
+
+int ambient_viewer_surface_is_watch(ambient_viewer_surface_h handle,
+ bool *is_watch);
+
+int ambient_viewer_surface_get_app_id(ambient_viewer_surface_h handle,
+ char **app_id);
+
+int ambient_viewer_surface_get_inst_id(ambient_viewer_surface_h handle,
+ char **inst_id);
+
+int ambient_viewer_surface_get_opr(ambient_viewer_surface_h handle,
+ float *opr);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__AMBIENT_VIEWER_INCLUDE_AMBIENT_VIEWER_SURFACE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <bundle.h>
+
+#include "ambient-viewer.h"
+
+namespace ambient_viewer {
+
+AmbientViewer::AmbientViewer() {
+}
+
+AmbientViewer::~AmbientViewer() = default;
+
+void AmbientViewer::Monitor() {
+}
+
+void AmbientViewer::Unmonitor() {
+}
+
+void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender,
+ bundle* extra) {
+}
+
+int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir,
+ bundle* extra) {
+ /*
+ bundle* b = bundle_create();
+ bundle_raw* raw;
+ int len;
+
+ //watch
+
+ //top app
+
+ //both
+
+ bundle_add_byte(b, "enter", enter);
+ bundle_encode(extra, &raw, &len);
+ bundle_add_str(b, "extra", raw);
+ aul_app_com_send("endpoint", b);
+ */
+
+ return 0;
+}
+
+const ISurface& AmbientViewer::GetWatchSurface() const {
+ return *watch_surface_;
+}
+
+const ISurface& AmbientViewer::GetTopAppSurface() const {
+ return *app_surface_;
+}
+
+} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
+#define __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
+
+#include <bundle.h>
+
+#include <string>
+#include <memory>
+
+#include "isurface.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace ambient_viewer {
+
+class EXPORT_API AmbientViewer {
+ public:
+ enum EventType {
+ EVENT_AOD_PREPARE,
+ EVENT_AOD_READY,
+ EVENT_WATCH_CHANGED,
+ };
+
+ enum Direction {
+ DIRECTION_VIEWER_AND_WATCH,
+ DIRECTION_VIEWER_AND_TOP_APP,
+ DIRECTION_ALL,
+ };
+
+ public:
+ class IEvent {
+ public:
+ virtual void OnAdded(const ISurface& surface) = 0;
+ virtual void OnUpdated(const ISurface& surface) = 0;
+ virtual void OnRemoved(const ISurface& surface) = 0;
+ };
+
+ AmbientViewer();
+ virtual ~AmbientViewer();
+ void Monitor();
+ void Unmonitor();
+ void OnReceived(EventType ev, std::string sender, bundle *extra);
+ int NotifyAmbientEvent(bool enter, Direction dir, bundle *extra);
+ const ISurface& GetWatchSurface() const;
+ const ISurface& GetTopAppSurface() const;
+
+ private:
+ std::shared_ptr<ISurface> watch_surface_;
+ std::shared_ptr<ISurface> app_surface_;
+};
+
+} // namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_ISURFACE_H__
+#define __AMBIENT_VIEWER_ISURFACE_H__
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#include <evas_object.h>
+
+#include <string>
+
+namespace ambient_viewer {
+
+class EXPORT_API ISurface {
+ public:
+ virtual ~ISurface() = default;
+ virtual screen_connector::EvasObject& GetCurrentImage() const = 0;
+ virtual bool IsWatch() const = 0;
+ virtual std::string GetAppId() const = 0;
+ virtual std::string GetInstId() const = 0;
+ virtual float GetOpr() const = 0;
+};
+
+} //namespace ambient_viewer
+#endif // __AMBIENT_VIEWER_ISURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "ambient_viewer.h"
+#include "ambient_viewer_surface.h"
+#include "ambient_viewer_common.h"
+
+#include "ambient-viewer.h"
+
+namespace ambient_viewer {
+
+class AmbientViewerStub : public AmbientViewer {
+ public:
+ AmbientViewerStub()
+ : AmbientViewer() {
+ }
+};
+
+} // namespace ambient_viewer
+
+extern "C" EXPORT_API int ambient_viewer_create(Evas_Object *win,
+ ambient_viewer_h *handle)
+{
+ ambient_viewer_h ambient_viewer = NULL;
+
+ *handle = ambient_viewer;
+
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_destroy(ambient_viewer_h handle)
+{
+ free (handle);
+
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_notify_ambient_event(
+ ambient_viewer_h handle, bool enter,
+ ambient_viewer_direction_e dir, bundle *extra)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle,
+ ambient_viewer_lifecycle_s lifecycle, void *user_data)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_unmonitor(ambient_viewer_h handle)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_set_event_listener(
+ ambient_viewer_h handle,
+ ambient_viewer_event_cb callback, void *user_data)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_unset_event_listener(
+ ambient_viewer_h handle)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_get_watch_surface(
+ ambient_viewer_h handle,
+ ambient_viewer_surface_h *surface)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_get_top_app_surface(
+ ambient_viewer_h handle,
+ ambient_viewer_surface_h *surface)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_surface_get_cur_image(
+ ambient_viewer_surface_h handle, Evas_Object *image)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_surface_is_watch(
+ ambient_viewer_surface_h handle, bool *is_watch)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_surface_get_app_id(
+ ambient_viewer_surface_h handle, char **app_id)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_surface_get_inst_id(
+ ambient_viewer_surface_h handle, char **inst_id)
+{
+ return 0;
+}
+
+extern "C" EXPORT_API int ambient_viewer_surface_get_opr(
+ ambient_viewer_surface_h handle, float *opr)
+{
+ return 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <system_info.h>
+
+#include "top-app-surface.h"
+
+#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+
+namespace ambient_viewer {
+
+TopAppSurface::TopAppSurface(
+ std::shared_ptr<screen_connector::EvasObject> surface,
+ AmbientViewer::IEvent* listener)
+ : RemoteSurfaceWatcher(screen_connector::RemoteSurface::Type::UI, surface),
+ listener_(listener) {
+}
+
+TopAppSurface::~TopAppSurface() = default;
+
+screen_connector::EvasObject& TopAppSurface::GetCurrentImage() const {
+ return *image_;
+}
+
+bool TopAppSurface::IsWatch() const {
+ return false;
+}
+
+std::string TopAppSurface::GetAppId() const {
+ return app_id_;
+}
+
+std::string TopAppSurface::GetInstId() const {
+ return inst_id_;
+}
+
+static float _GetOpr(void* source_data, int width, int height) {
+ int *source;
+ int x;
+ int y;
+ int idx;
+ int max_rad;
+ int rad;
+ int pos;
+ unsigned int r = 0;
+ unsigned int g = 0;
+ unsigned int b = 0;
+ unsigned int pixel_sum;
+ float opr;
+ float max_opr;
+ bool shape_circle = false;
+
+ system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
+
+ source = static_cast<int*>(source_data);
+ pos = width / 2;
+ max_rad = (height * height) >> 2;
+
+ for (y = 0; y < height; ++y) {
+ for (x = 0; x < width; ++x) {
+ if (shape_circle) {
+ rad = (pos - x) * (pos - x) + (pos - y) * (pos - y);
+ if (rad <= max_rad) {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ } else {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ }
+ }
+
+ if (shape_circle)
+ max_opr = (width / 2) * (height / 2) * 3.14 * 3 * 255;
+ else
+ max_opr = width * height * 3 * 255;
+
+ pixel_sum = r + g + b;
+ opr = ((float)pixel_sum) / max_opr;
+
+ return opr;
+}
+
+float TopAppSurface::GetOpr() const {
+ float opr = 0.0f;
+ int width;
+ int height;
+ int ret;
+
+ Evas_Native_Surface* ns;
+ tbm_surface_h surface;
+ tbm_surface_info_s info = {0, };
+ void* source_data;
+
+ if (image_ == nullptr)
+ return 0;
+
+ evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+
+ ns = evas_object_image_native_surface_get(image_->GetRaw());
+ if (ns == nullptr) {
+ return 0;
+ }
+
+
+ surface = (tbm_surface_h)ns->data.tbm.buffer;
+ if (surface == nullptr) {
+ return 0;
+ }
+
+ ret = tbm_surface_map(surface, TBM_SURF_OPTION_READ, &info);
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ return 0;
+ }
+
+ source_data = info.planes[0].ptr;
+ if (source_data == nullptr) {
+ tbm_surface_unmap(surface);
+ return 0;
+ }
+
+ opr = _GetOpr(source_data, width, height);
+
+ tbm_surface_unmap(surface);
+
+ return opr;
+}
+
+void TopAppSurface::OnWatcherAdded(const std::string& appId,
+ const std::string& instId, const int pid) {
+ app_id_ = appId;
+ inst_id_ = instId;
+
+ listener_->OnAdded(*surface_);
+}
+
+void TopAppSurface::OnWatcherChanged(const std::string& appId,
+ const std::string& instId, const int pid,
+ const screen_connector::EvasObject& image) {
+ //image_ = image;
+ listener_->OnUpdated(*surface_);
+}
+
+void TopAppSurface::OnWatcherRemoved(const std::string& appId,
+ const std::string& instId, const int pid) {
+ listener_->OnRemoved(*surface_);
+ image_ = nullptr;
+}
+
+} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
+#define __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
+
+#include <remote_surface_watcher.h>
+
+#include <string>
+#include <memory>
+
+#include "isurface.h"
+#include "ambient-viewer.h"
+
+#define WATCH_SMART_SIGNAL_ADDED "watch,added"
+#define WATCH_SMART_SIGNAL_REMOVED "watch,removed"
+#define WATCH_SMART_SIGNAL_UPDATED "watch,updated"
+
+namespace ambient_viewer {
+
+class TopAppSurface : public screen_connector::RemoteSurfaceWatcher, public ISurface {
+ public:
+ screen_connector::EvasObject& GetCurrentImage() const override;
+ bool IsWatch() const override;
+ std::string GetAppId() const override;
+ std::string GetInstId() const override;
+ float GetOpr() const override;
+
+ TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface, AmbientViewer::IEvent* listener);
+ virtual ~TopAppSurface();
+
+ private:
+ void OnWatcherAdded(const std::string& appId, const std::string& instId,
+ const int pid) override;
+ void OnWatcherChanged(const std::string& appId, const std::string& instId,
+ const int pid, const screen_connector::EvasObject& image) override;
+ void OnWatcherRemoved(const std::string& appId, const std::string& instId,
+ const int pid) override;
+
+ private:
+ std::shared_ptr<screen_connector::EvasObject> image_;
+ std::string app_id_;
+ std::string inst_id_;
+
+ std::shared_ptr<ISurface> surface_;
+ AmbientViewer::IEvent* listener_;
+};
+
+} // namespace ambient_viewer
+#endif // __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <system_info.h>
+
+#include "watch-surface.h"
+
+#define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
+
+namespace ambient_viewer {
+
+WatchSurface::WatchSurface(
+ std::shared_ptr<screen_connector::EvasObject> surface,
+ AmbientViewer::IEvent* listener)
+ : screen_connector::RemoteSurfaceEvas("",
+ screen_connector::RemoteSurface::Type::WATCH, surface),
+ listener_(listener) {
+}
+
+WatchSurface::~WatchSurface() = default;
+
+screen_connector::EvasObject& WatchSurface::GetCurrentImage() const {
+ return *image_;
+}
+
+bool WatchSurface::IsWatch() const {
+ return true;
+}
+
+std::string WatchSurface::GetAppId() const {
+ return app_id_;
+}
+
+std::string WatchSurface::GetInstId() const {
+ return inst_id_;
+}
+
+static float _GetOpr(void* source_data, int width, int height) {
+ int *source;
+ int x;
+ int y;
+ int idx;
+ int max_rad;
+ int rad;
+ int pos;
+ unsigned int r = 0;
+ unsigned int g = 0;
+ unsigned int b = 0;
+ unsigned int pixel_sum;
+ float opr;
+ float max_opr;
+ bool shape_circle = false;
+
+ system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
+
+ source = static_cast<int*>(source_data);
+ pos = width / 2;
+ max_rad = (height * height) >> 2;
+
+ for (y = 0; y < height; ++y) {
+ for (x = 0; x < width; ++x) {
+ if (shape_circle) {
+ rad = (pos - x) * (pos - x) + (pos - y) * (pos - y);
+ if (rad <= max_rad) {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ } else {
+ idx = y * width + x;
+ r += ((source[idx] & 0x00ff0000) >> 16);
+ g += ((source[idx] & 0x0000ff00) >> 8);
+ b += (source[idx] & 0x000000ff);
+ }
+ }
+ }
+
+ if (shape_circle)
+ max_opr = (width / 2) * (height / 2) * 3.14 * 3 * 255;
+ else
+ max_opr = width * height * 3 * 255;
+
+ pixel_sum = r + g + b;
+ opr = ((float)pixel_sum) / max_opr;
+
+ return opr;
+}
+
+float WatchSurface::GetOpr() const {
+ float opr = 0.0f;
+ int width;
+ int height;
+ int ret;
+
+ Evas_Native_Surface* ns;
+ tbm_surface_h surface;
+ tbm_surface_info_s info = {0, };
+ void* source_data;
+
+ if (image_ == nullptr)
+ return 0;
+
+ evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+
+ ns = evas_object_image_native_surface_get(image_->GetRaw());
+ if (ns == nullptr) {
+ return 0;
+ }
+
+
+ surface = (tbm_surface_h)ns->data.tbm.buffer;
+ if (surface == nullptr) {
+ return 0;
+ }
+
+ ret = tbm_surface_map(surface, TBM_SURF_OPTION_READ, &info);
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ return 0;
+ }
+
+ source_data = info.planes[0].ptr;
+ if (source_data == nullptr) {
+ tbm_surface_unmap(surface);
+ return 0;
+ }
+
+ opr = _GetOpr(source_data, width, height);
+
+ tbm_surface_unmap(surface);
+
+ return opr;
+}
+
+void WatchSurface::OnEvasAdded(const std::string& appId,
+ const std::string& instId, int pid,
+ const screen_connector::EvasObject& image) {
+ app_id_ = appId;
+ inst_id_ = instId;
+ //image_ = image;
+
+ listener_->OnAdded(*surface_);
+}
+
+void WatchSurface::OnEvasRemoved(const std::string& appId,
+ const std::string& instId, int pid,
+ const screen_connector::EvasObject& image) {
+ listener_->OnRemoved(*surface_);
+ image_ = nullptr;
+}
+
+void WatchSurface::OnEvasChanged(const std::string& appId,
+ const std::string& instId, int pid,
+ const screen_connector::EvasObject& image) {
+ listener_->OnUpdated(*surface_);
+}
+
+} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AMBIENT_VIEWER_WATCH_SURFACE_H__
+#define __AMBIENT_VIEWER_WATCH_SURFACE_H__
+
+#include <remote_surface_evas.h>
+
+#include <string>
+#include <memory>
+
+#include "isurface.h"
+#include "ambient-viewer.h"
+
+namespace ambient_viewer {
+
+class WatchSurface : public screen_connector::RemoteSurfaceEvas, public ISurface {
+ public:
+ screen_connector::EvasObject& GetCurrentImage() const override;
+ bool IsWatch() const override;
+ std::string GetAppId() const override;
+ std::string GetInstId() const override;
+ float GetOpr() const override;
+
+ WatchSurface(std::shared_ptr<screen_connector::EvasObject> surface, AmbientViewer::IEvent* listener);
+ virtual ~WatchSurface();
+
+ private:
+ void OnEvasAdded(const std::string& appId, const std::string& instId,
+ int pid, const screen_connector::EvasObject& image) override;
+ void OnEvasRemoved(const std::string& appId, const std::string& instId,
+ int pid, const screen_connector::EvasObject& image) override;
+ void OnEvasChanged(const std::string& appId, const std::string& instId,
+ int pid, const screen_connector::EvasObject& image) override;
+
+ private:
+ std::shared_ptr<screen_connector::EvasObject> image_;
+ std::string app_id_;
+ std::string inst_id_;
+
+ std::shared_ptr<ISurface> surface_;
+ AmbientViewer::IEvent* listener_;
+};
+
+} // namespace ambient_viewer
+#endif // __AMBIENT_VIEWER_WATCH_SURFACE_H__
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
Source1005: frame-broker.manifest
Source1006: frame-provider.manifest
Source1007: watch-holder.manifest
+Source1008: ambient-viewer.manifest
BuildRequires: cmake, gettext-tools, coreutils, edje-bin
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(screen_connector_launcher_service)
BuildRequires: pkgconfig(screen_connector_shared_widget_launch)
+BuildRequires: pkgconfig(screen_connector_remote_surface_evas)
%if 0%{?gcov:1}
BuildRequires: lcov
BuildRequires: zip
cp %{SOURCE1005} .
cp %{SOURCE1006} .
cp %{SOURCE1007} .
+cp %{SOURCE1008} .
%build
%if 0%{?gcov:1}
%postun -n frame-provider -p /sbin/ldconfig
################################################
+# libambient-viewer
+################################################
+%package -n ambient-viewer
+Summary: APIs to control ambient viewer
+Version: 0.0.1
+License: apache-2.0
+Group: Applications/Core Applications
+
+%description -n ambient-viewer
+A set of APIs to control viewer applications
+
+%package -n ambient-viewer-devel
+Summary: APIs to control watch applications
+Group: Development/Libraries
+Requires: ambient-viewer
+
+%description -n ambient-viewer-devel
+Header & package configuration of ambient-viewer
+
+%post -n ambient-viewer -p /sbin/ldconfig
+%postun -n ambient-viewer -p /sbin/ldconfig
+
+################################################
# files
################################################
%files -n %{name}_evas
%{_libdir}/pkgconfig/frame-provider.pc
%{_libdir}/libframe-provider.so
+%files -n ambient-viewer
+%manifest ambient-viewer.manifest
+%{_libdir}/libambient-viewer.so.*
+
+%files -n ambient-viewer-devel
+%{_includedir}/ambient-viewer/*.h
+%{_libdir}/pkgconfig/ambient-viewer.pc
+%{_libdir}/libambient-viewer.so
# End of a file