From 4836baa67e9aeebaf9eb185f8d7b42d69eb0a821 Mon Sep 17 00:00:00 2001 From: hyunho Date: Thu, 26 Mar 2020 16:57:42 +0900 Subject: [PATCH] Add block update API to ambient-viewer Change-Id: I39a6be27058b3b3facf4ec44d35d2ca344c60024 Signed-off-by: hyunho --- ambient-viewer/include/ambient_viewer.h | 11 +++++++++++ ambient-viewer/src/ambient-viewer.cc | 12 ++++++++++++ ambient-viewer/src/ambient-viewer.hh | 1 + ambient-viewer/src/isurface.hh | 1 + ambient-viewer/src/stub.cc | 16 +++++++++++++++- ambient-viewer/src/top-app-surface.cc | 4 ++++ ambient-viewer/src/top-app-surface.hh | 1 + ambient-viewer/src/watch-surface.cc | 4 ++++ ambient-viewer/src/watch-surface.hh | 1 + 9 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ambient-viewer/include/ambient_viewer.h b/ambient-viewer/include/ambient_viewer.h index 45556ce..c515b4f 100644 --- a/ambient-viewer/include/ambient_viewer.h +++ b/ambient-viewer/include/ambient_viewer.h @@ -121,6 +121,17 @@ int ambient_viewer_create(Evas_Object *win, ambient_viewer_h *handle); int ambient_viewer_destroy(ambient_viewer_h handle); /** + * @brief Blocks the ambient viewer's update events. + * @remarks This function only for internal applications. + * @param[in] handle The ambient viewer handle + * @param[in] enable Whether block buffer event or not + * @return #AMBIENT_VIEWER_ERROR_NONE On success, other value on failure + * @retval #AMBIENT_VIEWER_ERROR_NONE Success + * @retval #AMBIENT_VIEWER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int ambient_viewer_block_update(ambient_viewer_h handle, bool enable); + +/** * @brief Notifies the ambient event. * @remarks This function only for internal applications. * @param[in] handle The ambient viewer handle diff --git a/ambient-viewer/src/ambient-viewer.cc b/ambient-viewer/src/ambient-viewer.cc index 2bf57d7..a086dc9 100644 --- a/ambient-viewer/src/ambient-viewer.cc +++ b/ambient-viewer/src/ambient-viewer.cc @@ -97,6 +97,18 @@ void AmbientViewer::Unmonitor() { watch_surface_.reset(); } +void AmbientViewer::BlockUpdate(bool enable) { + if (top_app_surface_ != nullptr && top_app_surface_.get() != nullptr) { + top_app_surface_->BlockUpdate(enable); + LOGW("Top App Block Update (%d)", enable); + } + + if (watch_surface_ != nullptr && watch_surface_.get() != nullptr) { + watch_surface_->BlockUpdate(enable); + LOGW("Watch Block Update (%d)", enable); + } +} + void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender, Bundle extra) { } diff --git a/ambient-viewer/src/ambient-viewer.hh b/ambient-viewer/src/ambient-viewer.hh index 6d7f5f8..a5970ca 100644 --- a/ambient-viewer/src/ambient-viewer.hh +++ b/ambient-viewer/src/ambient-viewer.hh @@ -57,6 +57,7 @@ class EXPORT_API AmbientViewer : public IAmbientViewer { int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra); const ISurface& GetWatchSurface() const; const ISurface& GetTopAppSurface() const; + void BlockUpdate(bool enable); private: std::string GetUUID(std::string rid) const; diff --git a/ambient-viewer/src/isurface.hh b/ambient-viewer/src/isurface.hh index 768e8a1..b6bad65 100644 --- a/ambient-viewer/src/isurface.hh +++ b/ambient-viewer/src/isurface.hh @@ -35,6 +35,7 @@ class EXPORT_API ISurface { virtual std::string GetAppId() const = 0; virtual std::string GetInstId() const = 0; virtual float GetOpr() const = 0; + virtual void BlockUpdate(bool enable) = 0; }; } //namespace ambient_viewer diff --git a/ambient-viewer/src/stub.cc b/ambient-viewer/src/stub.cc index 8f618d7..e419321 100644 --- a/ambient-viewer/src/stub.cc +++ b/ambient-viewer/src/stub.cc @@ -170,6 +170,20 @@ extern "C" EXPORT_API int ambient_viewer_notify_ambient_event( return AMBIENT_VIEWER_ERROR_NONE; } +extern "C" EXPORT_API int ambient_viewer_block_update(ambient_viewer_h handle, + bool enable) +{ + if (handle == nullptr) { + LOGE("Invalid parameter"); + return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER; + } + + AmbientViewerStub* stub = static_cast(handle); + stub->BlockUpdate(enable); + + return AMBIENT_VIEWER_ERROR_NONE; +} + extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle, ambient_viewer_lifecycle_s lifecycle, void *user_data) { @@ -348,4 +362,4 @@ extern "C" EXPORT_API int ambient_viewer_surface_get_opr( *opr = surface->GetOpr(); return AMBIENT_VIEWER_ERROR_NONE; -} +} \ No newline at end of file diff --git a/ambient-viewer/src/top-app-surface.cc b/ambient-viewer/src/top-app-surface.cc index 194eb36..8998372 100644 --- a/ambient-viewer/src/top-app-surface.cc +++ b/ambient-viewer/src/top-app-surface.cc @@ -96,6 +96,10 @@ float TopAppSurface::GetOpr() const { return opr; } +void TopAppSurface::BlockUpdate(bool enable) { + RemoteSurfaceWatcher::SetBlock(enable); +} + void TopAppSurface::OnWatcherAdded(const std::string& appId, const std::string& instId, const int pid) { LOGD("WatcherAdded (%s:%s:%d)", appId.c_str(), instId.c_str(), pid); diff --git a/ambient-viewer/src/top-app-surface.hh b/ambient-viewer/src/top-app-surface.hh index cd440df..886497f 100644 --- a/ambient-viewer/src/top-app-surface.hh +++ b/ambient-viewer/src/top-app-surface.hh @@ -36,6 +36,7 @@ class TopAppSurface : public screen_connector::RemoteSurfaceWatcher, std::string GetAppId() const override; std::string GetInstId() const override; float GetOpr() const override; + void BlockUpdate(bool enable) override; TopAppSurface(std::shared_ptr surface, IAmbientViewer* listener); diff --git a/ambient-viewer/src/watch-surface.cc b/ambient-viewer/src/watch-surface.cc index ff964a3..43c0ddd 100644 --- a/ambient-viewer/src/watch-surface.cc +++ b/ambient-viewer/src/watch-surface.cc @@ -97,6 +97,10 @@ float WatchSurface::GetOpr() const { return opr; } +void WatchSurface::BlockUpdate(bool enable) { + RemoteSurface::SetBlock(enable); +} + void WatchSurface::OnEvasAdded(const std::string& appId, const std::string& instId, int pid, const screen_connector::EvasObject& image) { diff --git a/ambient-viewer/src/watch-surface.hh b/ambient-viewer/src/watch-surface.hh index 2b3f1b4..6da8155 100644 --- a/ambient-viewer/src/watch-surface.hh +++ b/ambient-viewer/src/watch-surface.hh @@ -35,6 +35,7 @@ class WatchSurface : public screen_connector::RemoteSurfaceEvas, public ISurface std::string GetAppId() const override; std::string GetInstId() const override; float GetOpr() const override; + void BlockUpdate(bool enable) override; WatchSurface(int rid, std::string id, std::string appid, Evas_Object* viewer_win, IAmbientViewer* listener); virtual ~WatchSurface(); -- 2.7.4