[VD] Refactors for background launch 94/272194/9 submit/tizen/20220519.160023
authorDongHyun Song <dh81.song@samsung.com>
Fri, 11 Mar 2022 03:50:21 +0000 (12:50 +0900)
committerSangYong Park <sy302.park@samsung.com>
Thu, 19 May 2022 06:06:09 +0000 (06:06 +0000)
Refactors conditions regarding background launch related to
clearify logics.

Change-Id: If4e222a7212d0c5e22d55b5d393f43fb9db0079e
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/common/web_application_delegate.ts
wrt_app/src/tv/web_application_tv.ts
wrt_app/src/web_application.ts

index 62f2661..ac5635d 100644 (file)
@@ -24,7 +24,6 @@ export class WebApplicationDelegate {
     this.webApplication = webApplication;
   }
 
-  backgroundExecutableLaunchMode() { return false; }
   beforeQuit() { }
   canIgnoreSuspend() { return false; }
   clearCache() { }
@@ -33,7 +32,7 @@ export class WebApplicationDelegate {
   handleAppControlEvent(appControl: any) { return true; }
   handleProxyInfo(authInfo: any, callback: any) { return false; }
   initialize(options: RuntimeOption) { }
-  isPreloading() { return false; }
+  isBackgroundLaunch() { return false; }
   needInpectorGuide() { return false; }
   needReload(src: string) {
     let originalUrl = this.webApplication.mainWindow.webContents.getURL();
index d3668fc..0f8853b 100644 (file)
@@ -21,7 +21,6 @@ import { WebApplication } from '../web_application';
 import { WebApplicationDelegate } from '../../common/web_application_delegate';
 
 export class WebApplicationDelegateTV extends WebApplicationDelegate {
-  backgroundExecutionLaunchMode: boolean = false;
   backgroundExecutionMetaData: string = 'false';
   inspectorSrc: string = '';
   isAlwaysReload: boolean = false;
@@ -37,18 +36,12 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate {
 
   initialize(options: RuntimeOption) {
     this.launchMode = options.launchMode;
-    if (options.launchMode == 'backgroundAtStartup') {
-      console.log('backgroundAtStartup');
+    console.log(`launch mode is ${this.launchMode}`);
+    if (options.launchMode === 'backgroundAtStartup') {
       this.preloadStatus = 'preload';
     } else {
       this.preloadStatus = 'none';
     }
-    if (options.launchMode == 'backgroundExecution') {
-      console.log('launch mode is backgroundExecution');
-      this.backgroundExecutionLaunchMode = true;
-    } else {
-      this.backgroundExecutionLaunchMode = false;
-    }
     this.isAlwaysReload = this.tv.isAlwaysReload();
     this.webApplication.multitaskingSupport = this.tv.getMultitaskingSupport();
     this.webApplication.defaultBackgroundColor = '#0000';
@@ -101,6 +94,9 @@ for (var i=0; i < window.frames.length; i++)
   }
 
   private showInspectorGuide() {
+    if (this.isBackgroundLaunch())
+      return;
+
     console.log('WebApplication : showInspectorGuide');
     this.showInspectorGuide = () => { }; // call once
     const message = `${this.webApplication.debugPort.toString()}
@@ -114,11 +110,6 @@ Please click Record button in Timeline panel in PC before click OK button,
 Then you can get profile log from the initial loading.`;
     let webContents = this.webApplication.mainWindow.webContents;
     this.tv.showDialog(webContents, message);
-    if (this.preloadStatus !== 'none') {
-      setTimeout(() => {
-        this.tv.cancelDialogs(webContents);
-      }, 5000);
-    }
   }
 
   private needSuspend() {
@@ -138,26 +129,16 @@ Then you can get profile log from the initial loading.`;
     }
   }
 
-  backgroundExecutableLaunchMode() {
-    return this.backgroundExecutionLaunchMode;
-  }
-
-  isPreloading() {
-    if (this.preloadStatus === 'preload' ||
-        this.launchMode === 'runningAsBackground') {
-      console.log(`preloadStatus is ${this.preloadStatus} or ${this.launchMode}, show is skipped`);
-      return true;
-    }
-    return false;
+  isBackgroundLaunch() {
+    return (this.preloadStatus === 'preload' ||
+      this.launchMode === 'runningAsBackground' ||
+      this.launchMode === 'backgroundExecution');
   }
 
   canIgnoreSuspend() {
-    if (this.launchMode === 'runningAsForeground' ||
-        this.launchMode === 'runningAsBackground') {
-      console.log('WebApplication : view_suspend & multitasking feature is skipped!');
-      return true;
-    }
-    return false;
+    return (this.launchMode === 'runningAsForeground' ||
+      this.launchMode === 'runningAsBackground' ||
+      this.launchMode === 'backgroundExecution');
   }
 
   beforeQuit() {
@@ -181,8 +162,10 @@ Then you can get profile log from the initial loading.`;
   }
 
   needInpectorGuide() {
-    let inspectorEnabledByVconf = this.tv.needUseInspector();
-    if (inspectorEnabledByVconf && !this.backgroundExecutionLaunchMode) {
+    if (this.isBackgroundLaunch()) {
+      return false;
+    }
+    if (this.tv.needUseInspector()) {
       this.inspectorSrc = this.webApplication.contentSrc;
       this.webApplication.contentSrc = 'about:blank';
       return true;
@@ -243,11 +226,6 @@ Then you can get profile log from the initial loading.`;
         return false;
       }
     }
-
-    if ('true' === this.backgroundExecutionMetaData) {
-        console.log(`handle AppControl background exectution app to show`);
-        this.webApplication.mainWindow.show();
-    }
     return true;
   }
 
index bdf777f..1f55332 100644 (file)
@@ -244,12 +244,11 @@ export class WebApplication {
     // TODO: On 6.0, this causes a black screen on relaunch
     if (this.showTimer)
       clearTimeout(this.showTimer);
-    if (!this.backgroundRunnable())
-      this.mainWindow.setEnabled(true);
+    this.mainWindow.setEnabled(true);
   }
 
   private initDisplayDelay() {
-    if (this.profileDelegate.isPreloading())
+    if (this.profileDelegate.isBackgroundLaunch())
       return;
 
     this.splashShown = wrt.showSplashScreen();
@@ -264,10 +263,6 @@ export class WebApplication {
     }, 2000);
   }
 
-  private backgroundRunnable() {
-    return this.backgroundSupport || this.profileDelegate.backgroundExecutableLaunchMode();
-  }
-
   handleAppControlEvent(appControl: any) {
     if (!this.profileDelegate.handleAppControlEvent(appControl)) {
       return;
@@ -311,7 +306,7 @@ export class WebApplication {
   }
 
   private isPausable() {
-    return !this.profileDelegate.canIgnoreSuspend() && !this.backgroundRunnable();
+    return !this.backgroundSupport && !this.profileDelegate.canIgnoreSuspend();
   }
 
   suspend() {
@@ -325,7 +320,7 @@ export class WebApplication {
     }
     if (this.isPausable()) {
       this.windowList.forEach((window) => window.setEnabled(false));
-      if (!this.multitaskingSupport && !this.profileDelegate.isPreloading()) {
+      if (!this.multitaskingSupport && !this.profileDelegate.isBackgroundLaunch()) {
         setTimeout(() => {
           console.log('multitasking is not supported; quitting app')
           app.quit();
@@ -341,8 +336,7 @@ export class WebApplication {
     addonManager.emit('lcResume', this.mainWindow.id, this.reload);
     this.reload = false;
 
-    if (!this.backgroundRunnable())
-      this.windowList.forEach((window) => window.setEnabled(true));
+    this.windowList.forEach((window) => window.setEnabled(true));
     this.windowList[this.windowList.length - 1].show();
   }
 
@@ -399,13 +393,12 @@ export class WebApplication {
   }
 
   show() {
-    if (this.profileDelegate.isPreloading()) {
+    if (this.profileDelegate.isBackgroundLaunch()) {
+      console.log('show() will be skipped by background launch');
       return;
     }
     console.log('WebApplication : show');
-    if (this.profileDelegate.backgroundExecutableLaunchMode()) {
-      console.log('skip showing while backgroundExecutionLaunchMode mode');
-    } else if (!this.mainWindow.isVisible()) {
+    if (!this.mainWindow.isVisible()) {
       console.log(`show this.windowList.length : ${this.windowList.length}`);
       this.mainWindow.show();
       if (this.windowList.length > 1) {