Add block update API to ambient-viewer 91/228891/2
authorhyunho <hhstark.kang@samsung.com>
Thu, 26 Mar 2020 07:57:42 +0000 (16:57 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 31 Mar 2020 02:56:08 +0000 (11:56 +0900)
Change-Id: I39a6be27058b3b3facf4ec44d35d2ca344c60024
Signed-off-by: hyunho <hhstark.kang@samsung.com>
ambient-viewer/include/ambient_viewer.h
ambient-viewer/src/ambient-viewer.cc
ambient-viewer/src/ambient-viewer.hh
ambient-viewer/src/isurface.hh
ambient-viewer/src/stub.cc
ambient-viewer/src/top-app-surface.cc
ambient-viewer/src/top-app-surface.hh
ambient-viewer/src/watch-surface.cc
ambient-viewer/src/watch-surface.hh

index 45556ce..c515b4f 100644 (file)
@@ -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
index 2bf57d7..a086dc9 100644 (file)
@@ -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) {
 }
index 6d7f5f8..a5970ca 100644 (file)
@@ -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;
index 768e8a1..b6bad65 100644 (file)
@@ -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
index 8f618d7..e419321 100644 (file)
@@ -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<AmbientViewerStub*>(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
index 194eb36..8998372 100644 (file)
@@ -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);
index cd440df..886497f 100644 (file)
@@ -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<screen_connector::EvasObject> surface,
     IAmbientViewer* listener);
index ff964a3..43c0ddd 100644 (file)
@@ -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) {
index 2b3f1b4..6da8155 100644 (file)
@@ -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();