[VD] add Gaming hub feature 90/259690/5
authoryman.son <yman.son@samsung.com>
Fri, 11 Jun 2021 06:10:01 +0000 (15:10 +0900)
committeryman.son <yman.son@samsung.com>
Wed, 16 Jun 2021 05:59:53 +0000 (14:59 +0900)
In the gaming hub panel,
there is a scenario where webapp plays sound after background launch.
Also, it should be possible to switch to UI mode.
At this time, must support multitasking unconditionally.

Add three fetures to support this.
1. Transition of FG and BG through Appcontrol
2. disable multitasking feature according to special App Control.
3. window's hide is required for Appcontrol BG transition. (change WebEngine code)

Change-Id: If6760ab87ece3966599cab5f393d043467b39187
Signed-off-by: yman.son <yman.son@samsung.com>
wrt_app/common/web_application_delegate.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index fcc4872..b31a4d9 100644 (file)
@@ -23,13 +23,16 @@ export class WebApplicationDelegate {
   constructor(webApplication: WebApplication) {
     this.webApplication = webApplication;
   }
-  initialize(options: RuntimeOption) { }
+
   backgroundExecutable() { return false; }
   beforeQuit() { }
+  canIgnoreSuspend() { return false; }
   clearCache() { }
   clearSuface(webContents: any) { }
   handleAppControlEvent(appControl: any) { return true; }
   handleProxyInfo(authInfo: any, callback: any) { return false; }
+  initialize(options: RuntimeOption) { }
+  isPreloading() { return false; }
   needInpectorGuide() { return false; }
   needReload(src: string) {
     let originalUrl = this.webApplication.mainWindow.webContents.getURL();
@@ -39,7 +42,6 @@ export class WebApplicationDelegate {
     return false;
   }
   needShowTimer() { return true; }
-  isPreloading() { return false; }
   onDidFinishLoad() { }
   profileName() { return 'common' }
   show() { }
index d0a88a2..bbda5e2 100644 (file)
@@ -26,6 +26,7 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate {
   isAlwaysReload: boolean = false;
   preloadStatus: string = 'none';
   runningStatus: string = 'none';
+  launchMode: string = 'none';
   tv: any = (wrt.tv as NativeWRTjs.TVExtension);
 
   constructor(webApplication: WebApplication) {
@@ -33,6 +34,7 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate {
   }
 
   initialize(options: RuntimeOption) {
+    this.launchMode = options.launchMode;
     if (options.launchMode == 'backgroundAtStartup') {
       console.log('backgroundAtStartup');
       this.preloadStatus = 'preload';
@@ -97,6 +99,10 @@ Then you can get profile log from the initial loading.`;
   }
 
   private suspendByStatus() {
+    if (this.launchMode == 'runningAsBackground') {
+      console.log('WebApplication : runningAsBackground suspend is skipped!');
+      return;
+    }
     if (this.preloadStatus === 'preload' ||
       this.runningStatus === 'behind') {
       console.log('WebApplication : suspendByStatus');
@@ -123,8 +129,8 @@ Then you can get profile log from the initial loading.`;
   }
 
   isPreloading() {
-    if (this.preloadStatus == 'preload') {
-      console.log('preloading show is skipped!');
+    if (this.preloadStatus == 'preload' || this.launchMode == 'runningAsBackground') {
+      console.log(`preloadStatus is ${this.preloadStatus} or ${this.launchMode}, show is skipped`);
       return true;
     }
     return false;
@@ -134,6 +140,15 @@ Then you can get profile log from the initial loading.`;
     this.preloadStatus = 'none';
   }
 
+  canIgnoreSuspend() {
+    if (this.launchMode == 'runningAsForeground' ||
+        this.launchMode == 'runningAsBackground') {
+      console.log('WebApplication : view_suspend & multitasking feature is skipped!');
+      return true;
+    }
+    return false;
+  }
+
   beforeQuit() {
     this.inspectorSrc = '';
     this.tv.cancelDialogs(this.webApplication.mainWindow.webContents);
@@ -191,8 +206,20 @@ Then you can get profile log from the initial loading.`;
   }
 
   handleAppControlEvent(appControl: any) {
-    let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
-    this.handlePreloadState(launchMode);
+    this.launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
+    this.handlePreloadState(this.launchMode);
+
+    if (this.launchMode === 'runningAsBackground') {
+      this.webApplication.suspended = false;
+      this.webApplication.windowList.forEach((window) => window.setEnabled(true));
+      this.webApplication.windowList[this.webApplication.windowList.length - 1].hide();
+      this.webApplication.sendAppControlEvent();
+      return false;
+    } else if (this.launchMode === 'runningAsForeground') {
+      this.webApplication.resume();
+      this.webApplication.sendAppControlEvent();
+      return false;
+    }
 
     let skipReload = appControl.getData('SkipReload');
     if (skipReload == 'Yes') {
index 6187903..84b6bca 100644 (file)
@@ -286,6 +286,8 @@ export class WebApplication {
     this.suspended = true;
     this.windowList[this.windowList.length - 1].hide();
     this.flushData();
+    if (this.profileDelegate.canIgnoreSuspend())
+      return;
     if (!this.backgroundRunnable()) {
       this.windowList.forEach((window) => window.setEnabled(false));
       if (!this.multitaskingSupport) {