[WRTjs][VD] Support notification layer window for WebApp 76/324776/3
authorzhaosy <shiyusy.zhao@samsung.com>
Wed, 21 May 2025 08:43:32 +0000 (16:43 +0800)
committerBot Blink <blinkbot@samsung.com>
Thu, 5 Jun 2025 01:41:38 +0000 (01:41 +0000)
Background:
  In LPM(Low Power Mode), Daily board need to show a notification layer webapp.

Guide:
  1.WebApp add notification metadata
    <tizen:metadata key="http://samsung.com/tv/metadata/allow.notification.layer" value="true"/>
  2.WebApp add window priority privilege
    <tizen:privilege name="http://tizen.org/privilege/window.priority.set" />
  3. Launch WebApp as notification window layer
    app_control_add_extra_data(handle, "window_layer", "notification");

Change-Id: I492f55fac2fd093126f6ce08b8dce7d3d298ca70
Signed-off-by: zhaosy <shiyusy.zhao@samsung.com>
wrt/src/browser/tv/native_web_runtime_delegate_tv.cc
wrt/src/browser/tv/native_web_runtime_delegate_tv.h
wrt/src/browser/tv/wrt_native_window_tv.cc
wrt/src/browser/tv/wrt_native_window_tv.h
wrt/src/browser/wrt_window_tree_host.h

index 05576ac8d2dd0695053ef047a7519eccb12de7bb..30b76f056da6e6d624a13d4f895f6728f72b9d9c 100644 (file)
@@ -77,6 +77,8 @@ namespace {
 
 const char* kAllowMixedContent =
     "http://samsung.com/tv/metadata/allow.mixedcontent";
+const char* kAllowNotificationLayer =
+    "http://samsung.com/tv/metadata/allow.notification.layer";
 const char* kAmbientScreen =
     "http://samsung.com/tv/metadata/ambient.screen.support";
 const char* kAppLocationFormat =
@@ -103,6 +105,7 @@ const char* kWrtLoaderCount = "rtc/memory/WebApp/wrtloadercount";
 const char* kWrtMessagePort = "wrt.message.port";
 const char* kMultitaskingSupport =
     "http://samsung.com/tv/metadata/multitasking.support";
+const char* kWindowLayer = "window_layer";
 
 #if defined(TIZEN_VIDEO_HOLE)
 const char* kVideoHoleSupport =
@@ -494,6 +497,10 @@ void NativeWebRuntimeDelegateTV::AfterAppControlEvent(
   if (half_window_option)
     ApplyHalfWindow(half_window_option);
 
+  auto* window_layer = appsvc_get_data(bundle, kWindowLayer);
+  if (window_layer)
+    ApplyNotificationWindow(window_layer);
+
   auto& app_data = ApplicationData::GetInstance();
   if (launch_mode == "backgroundExecution") {
     AmbientMode::CreateInstance(
@@ -510,13 +517,30 @@ void NativeWebRuntimeDelegateTV::AfterAppControlEvent(
 }
 
 void NativeWebRuntimeDelegateTV::ApplyHalfWindow(
-    std::string half_window_option) {
+    const std::string& half_window_option) {
   LOG(INFO) << "HalfWindowSupport value = " << half_window_option;
   auto native_window_tv = WRTNativeWindowTV::GetMainNativeWindow();
   if (native_window_tv)
     native_window_tv->HalfWindowSupport(half_window_option);
 }
 
+void NativeWebRuntimeDelegateTV::ApplyNotificationWindow(
+    const std::string& window_layer) {
+  LOG(INFO) << "window_layer value = " << window_layer;
+  if (window_layer != "notification")
+    return;
+
+  auto native_window_tv = WRTNativeWindowTV::GetMainNativeWindow();
+  if (!native_window_tv)
+    return;
+
+  auto allow_notification =
+      ApplicationData::GetInstance().GetMetadata(kAllowNotificationLayer);
+  LOG(INFO) << "allow.notification.layer value = " << allow_notification;
+  if (allow_notification == "true")
+    native_window_tv->SetNotificationWindow(true);
+}
+
 void NativeWebRuntimeDelegateTV::SubscribePowerState() {
   if (power_callback_registered_)
     return;
index 687e5d6259b55e109b1611266b2e206f13b1ec20..cc8e227cd0bc9284be9729e84b516a92fcf995bd 100644 (file)
@@ -78,7 +78,8 @@ class NativeWebRuntimeDelegateTV : public WRTProfileDelegate {
   void RequestQuit() override;
 
   void BoostNetworkServiceThread();
-  void ApplyHalfWindow(std::string half_window_option);
+  void ApplyHalfWindow(const std::string& half_window_option);
+  void ApplyNotificationWindow(const std::string& window_layer);
   void ClearTmpFolder();
   void EarlyLoadUrlIfHostedApp();
   void EarlyPlayVideoSplashScreen();
index 6cff811288588c574792b5c3313708fa36baa06e..0d5540bd627f9787c52fddee946eac09f3c4e9be 100644 (file)
@@ -1222,6 +1222,20 @@ void WRTNativeWindowTV::SetWindowStackMode(const std::string value) {
   LOG(INFO) << "ecore_wl2_window_stack_mode_set = " << mode;
 }
 
+void WRTNativeWindowTV::SetNotificationWindow(bool notification) {
+  LOG(INFO) << "set notification window, value is = " << notification;
+  tizen_policy* tz_policy = GetWindowTreeHost()->GetTizenPolicy();
+  Ecore_Wl2_Window* wl_win =
+      ecore_evas_wayland2_window_get(GetPlatformCanvas());
+  struct wl_surface* surface = ecore_wl2_window_surface_get(wl_win);
+  if (notification)
+    tizen_policy_set_notification_level(tz_policy, surface,
+                                        TIZEN_POLICY_LEVEL_TOP);
+  else
+    tizen_policy_set_notification_level(tz_policy, surface,
+                                        TIZEN_POLICY_LEVEL_NONE);
+}
+
 void WRTNativeWindowTV::SetDimScreen() {
   LOG(INFO) << "SetDimScreen, alphaset is " << alphaset_;
   if (!alphaset_) {
index f859b269a6b96930b1982587fd4412a7d4d7e187..be36388b9c9bde49d9135bfc70cefcd0846b72c6 100644 (file)
@@ -88,6 +88,7 @@ class WRTNativeWindowTV : public WRTNativeWindow {
   void SetScreenSaver(const std::string& state);
 
   bool SetWindowAuxHint(const std::string& hint_value);
+  void SetNotificationWindow(bool notification);
 
  private:
   // NativeWindow:
index cb135c59c1588fc1eb65f6aa9f4d3f9c108af513..34ce76afe2d16dea136588ed4fc87d5314b63fdf 100644 (file)
@@ -29,6 +29,7 @@ class WRTWindowTreeHost : public aura::WindowTreeHostPlatform,
   void Hide();
 
   Evas_Object* GetEvasObject() const;
+  tizen_policy* GetTizenPolicy() const { return tizen_policy_; }
 
   bool is_active() const { return is_active_; }