From 86bff939e803a353fcd989aac838bac66b57d1fc Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Tue, 9 Nov 2021 09:57:29 +0900 Subject: [PATCH 01/16] [Service][VD] Add metadata for non-appdrm option vd-wgt-backend will check widget.license file with this option Change-Id: I80a065250b85190d543078b7c50a72ef9c9cda20 Signed-off-by: DongHyun Song --- packaging/config_tv.xml.in | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/config_tv.xml.in b/packaging/config_tv.xml.in index d354aef..3e59715 100644 --- a/packaging/config_tv.xml.in +++ b/packaging/config_tv.xml.in @@ -17,5 +17,6 @@ DeviceHomeService DeviceHomeService + -- 2.7.4 From f88f60fdfb2f224951c2bea42275ef7fc8158bf8 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 2 Nov 2021 22:08:47 -0700 Subject: [PATCH 02/16] [Service] Add a service app to register device to devicehome.net DeviceHome is running on demand on TV profile to save idle time memory usage. The Initializer service app registers device to devicehome.net once, before launching the DeviceHome. The service app will be called by wrt-service-broker only if device IP, device name, and login ID have been changed. Change-Id: I9edb3bef2fa20070408cd71a47c3eec6e03836e2 Signed-off-by: Youngsoo Choi --- device_home/service/initializer/service.js | 111 +++++++++++++++++++++++++++++ device_home/service/service.js | 61 +--------------- packaging/config_tv.xml.in | 5 ++ 3 files changed, 119 insertions(+), 58 deletions(-) create mode 100755 device_home/service/initializer/service.js diff --git a/device_home/service/initializer/service.js b/device_home/service/initializer/service.js new file mode 100755 index 0000000..1d782a0 --- /dev/null +++ b/device_home/service/initializer/service.js @@ -0,0 +1,111 @@ +const TAG = '[Initializer]'; +const https = require('https'); +const is_tv = webapis.cachedProperty !== undefined; + +class Initializer { + constructor() { + this.DEVICE_HOME = 'devicehome.net'; + this.blacklist = [ + '1', + '10.0.2.15', // emulator + '127.0.0.1', // localhost + '192.168.250.250' // sdb + ]; + this.device_ip = this.getIp(); + this.device_name = webapis.mde.getDeviceName(); + this.login_id = webapis.mde.getCurrentLoginId(); + } + + registerDevice() { + return new Promise(resolve => { + if (this.device_ip === false) { + console.log(`${TAG} failed to get device_ip`); + return; + } + const device = { + device_ip: this.device_ip, + device_name: this.device_name, + login_id: this.login_id + }; + console.log(`${TAG} device :`, device); + const data = JSON.stringify(device); + const request_options = { + headers: { + 'Content-Type': 'application/json', + 'Content-Length': data.length + }, + hostname: this.DEVICE_HOME, + method: 'POST', + path: '/registerDevice', + port: 443, + rejectUnauthorized: false + }; + const req = https.request(request_options, res => { + console.log(`${TAG} status : ${res.statusCode}`); + res.setEncoding('utf8'); + res.on('data', response => { + console.log(`${TAG} response: ${response}`); + if (response === 'DONE' || response === 'DEVICE_EXISTS') { + this.saveFile(); + } + resolve(true); + }); + }); + req.on('error', error => { + console.log(`${TAG} error: ${error}`); + resolve(false); + }); + req.write(data); + req.end(); + }); + } + + saveFile() { + const device = `${this.device_ip}:${this.device_name}:${this.login_id}`; + const file_handler_write = tizen.filesystem.openFile('wgt-private/device_home.txt', 'rwo'); + file_handler_write.writeString(device); + const file_handler_read = tizen.filesystem.openFile('wgt-private/device_home.txt', 'r'); + const contents = file_handler_read.readString(); + console.log(`${TAG} saved : ${contents}`); + file_handler_write.close(); + file_handler_read.close(); + } + + getIp() { + const interfaces = require('os').networkInterfaces(); + for (const device in interfaces) { + if (interfaces.hasOwnProperty(device)) { + const iface = interfaces[device]; + for (let i = 0; i < iface.length; i++) { + const alias = iface[i]; + console.log(`${TAG} found : ${alias.address}`); + if (alias.family === 'IPv4' && !alias.internal && + !this.blacklist.includes(alias.address)) { + return alias.address; + } + } + } + } + return false; + } +} + +module.exports.onStart = async function() { + console.log(`${TAG} onStart is called`); + if (!is_tv || typeof webapis.mde === 'undefined') { + console.log(`${TAG} failed to register device`); + tizen.application.getCurrentApplication().exit(); + return; + } + const initializer = new Initializer(); + await initializer.registerDevice(); + tizen.application.getCurrentApplication().exit(); +}; + +module.exports.onStop = function() { + console.log(`${TAG} onStop is called`); +}; + +module.exports.onRequest = function() { + console.log(`${TAG} onRequest is called`); +}; diff --git a/device_home/service/service.js b/device_home/service/service.js index 8660d97..289fd62 100755 --- a/device_home/service/service.js +++ b/device_home/service/service.js @@ -20,13 +20,12 @@ const sessionMiddleware = session({ secure: false, }}); -const PUBLIC_DOMAIN = 'http://devicehome.net'; +const PUBLIC_DOMAIN = 'https://devicehome.net'; const TAG = '[DeviceHome][service.js]' const TIZEN_WEB_APP_SHARED_RESOURCES = 'shared/res/'; const WEBCLIP_DIRECTORY = 'webclip'; const WEBCLIP_MANIFEST = 'manifest.json'; const is_tv = webapis.cachedProperty !== undefined; -const emulator_ip = '10.0.2.15'; const local_ip = '127.0.0.1'; const non_ip_list = [ '1', @@ -254,47 +253,6 @@ function getWebClipsList() { return result; } -function sendLoginIdAndDeviceName(login_id, device_ip) { - let device_name = 'Tizen'; - if (typeof webapis.mde !== 'undefined') - device_name = webapis.mde.getDeviceName(); - console.log(`${TAG} login_id : ${login_id}`); - console.log(`${TAG} device_ip : ${device_ip}`); - console.log(`${TAG} device_name : ${device_name}`); - - const xhr = new XMLHttpRequest(); - const keyVal = { - login_id: login_id, - device_name: device_name, - device_ip: device_ip - }; - xhr.onreadystatechange = function() { - if (xhr.readyState === xhr.DONE) { - console.log(`${TAG} xhr text: ${xhr.responseText}`); - if (xhr.status === 200 || xhr.status === 201) { - if (xhr.responseText === 'DEVICE_EXISTS') { - console.log(`${TAG} device exists`); - } - } else { - console.log(`${TAG} xhr error: ${xhr.status}`); - } - } - } - xhr.open('POST', PUBLIC_DOMAIN + '/registerDevice'); - xhr.setRequestHeader('Content-Type', 'application/json'); - xhr.send(JSON.stringify(keyVal)); -} - -function updateDNSresolver(device_ip) { - console.log(`${TAG} Server is listening on ${device_ip}:${g.port}`); - if (is_tv && typeof webapis.mde !== 'undefined') { - const login_id = webapis.mde.getCurrentLoginId(); - sendLoginIdAndDeviceName(login_id, device_ip); - } else { - console.log(`${TAG} Samsung account isn't available`); - } -} - function comparePincode(req, res, encrypted) { console.log(`${TAG} comparePincode`); console.log(`${TAG} encrypted : ${encrypted}`); @@ -568,19 +526,7 @@ var HTTPserverStart = function() { httpserver = http.createServer(app); httpserver.listen(g.port, function() { - const interfaces = require('os').networkInterfaces(); - for (const devName in interfaces) { - if (interfaces.hasOwnProperty(devName)) { - const iface = interfaces[devName]; - for (let i = 0; i < iface.length; i++) { - const alias = iface[i]; - if (alias.family === 'IPv4' && !non_ip_list.includes(alias.address) && - !alias.internal && alias.address !== emulator_ip) { - updateDNSresolver(alias.address); - } - } - } - } + console.log(`Device home is running on port ${g.port}`); }); relayServer(httpserver, dataApps, sessionMiddleware, clientPublicKeys); }; @@ -618,5 +564,4 @@ module.exports.onStop = function() { }; module.exports.onRequest = function() { -} - +}; diff --git a/packaging/config_tv.xml.in b/packaging/config_tv.xml.in index 3e59715..cf869c3 100644 --- a/packaging/config_tv.xml.in +++ b/packaging/config_tv.xml.in @@ -19,4 +19,9 @@ DeviceHomeService + + + DeviceHomeInitializer + DeviceHomeInitializer + -- 2.7.4 From e6ff3d258e339b27fa8b52870d69ecc66ed3aeab Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 16 Nov 2021 01:00:45 -0800 Subject: [PATCH 03/16] [DeivceHome] Use the path /res/wsa for tmg service app When installing wgt app, service is mounted on /res/wgt but when installing tmg app on TV, service is mounted on /res/wsa. Change-Id: I82a3203cd6e0a652319b7531028aa119f36c4fd3 Signed-off-by: Youngsoo Choi --- device_home/service/service.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/device_home/service/service.js b/device_home/service/service.js index 289fd62..138dd23 100755 --- a/device_home/service/service.js +++ b/device_home/service/service.js @@ -1,6 +1,7 @@ 'use strict'; const express = require('express'); +const fs = require('fs'); const http = require('http'); const path = require('path'); const relayServer = require('./relay-server.js'); @@ -40,6 +41,7 @@ var dataApps = []; var clientRouter = express.Router(); var httpserver, evtEmit; var platform_app_path = '/opt/usr/globalapps'; +var platform_client_res_path = '/res/wgt/client'; var serverAppId = ''; var urlParam = ''; var g = { @@ -354,7 +356,10 @@ var HTTPserverStart = function() { console.log(`${TAG} __dirname: ${__dirname}`); if (is_tv) { - platform_app_path = '/opt/usr/apps' + platform_app_path = '/opt/usr/apps'; + if (!fs.existsSync(path.join(__dirname, platform_client_res_path))) { + platform_client_res_path = '/res/wsa/client'; + } console.log(`${TAG} TV Profile`); } @@ -425,7 +430,7 @@ var HTTPserverStart = function() { clientRouter.get('/*', function(req, res) { const file = req.originalUrl.replace('/client/', '').replace(/\?.+$/, ''); const pkgId = webapis.getPackageId(); - const fullPath = require('path').join(g.baseDir, pkgId, '/res/wgt/client', file); + const fullPath = require('path').join(g.baseDir, pkgId, platform_client_res_path, file); console.log(`${TAG} pkgId: ${pkgId}, fullPath: ${fullPath}`); res.sendFile(fullPath); }); -- 2.7.4 From 1a01fcdbc5f524aa802f20535ed593d716143688 Mon Sep 17 00:00:00 2001 From: Insoon Kim Date: Wed, 17 Nov 2021 17:39:38 +0900 Subject: [PATCH 04/16] [DeivceHome] Remove the self signed certificates The self signed certificates can not be used for product and the signaling server is also temporarily removed. Change-Id: I6e440de977cb653c58e5973ef384f2d8a8353e63 Signed-off-by: Insoon Kim --- device_home/service.js | 3 ++- packaging/wrtjs.spec | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/device_home/service.js b/device_home/service.js index 29e8a71..17cd727 100644 --- a/device_home/service.js +++ b/device_home/service.js @@ -2,7 +2,8 @@ const deviceHome = require('./service/service'); module.exports.onStart = async function() { deviceHome.onStart(); - require('./signaling_server/gen/app'); + // Temporarily remove the signaling server + // require('./signaling_server/gen/app'); }; module.exports.onStop = function() { diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index c149c45..b729517 100644 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -123,7 +123,7 @@ absolute_appdir=$PWD/%{app_dir} > packaging/tizen-manifest-tpk.xml %endif -%if 0%{?_use_d2d} +%if 0%{?_use_d2d_offload} # Create a self-signed certificates for signaling server openssl genrsa -out key.pem 2048 openssl req -new -x509 -nodes -key key.pem -out cert.pem \ @@ -206,8 +206,10 @@ cp -r %{app_dir}/* %{buildroot}%{_resourcedir}/ %define _d2d_install_path %{_appdir}/.preload-rw-wgt install -m 0644 packaging/config.xml.in device_home/config.xml %endif +%if 0%{?_use_d2d_offload} install -m 0644 key.pem device_home/signaling_server/gen/ install -m 0644 cert.pem device_home/signaling_server/gen/ +%endif tizen/build/build_app.sh %{buildroot} device_home %{_d2d_app_file_name} %{_d2d_app_extension} platform %{?profile} install -d %{buildroot}/%{_d2d_install_path} -- 2.7.4 From 3d8bb058c24e35eac8d9b802e511f0165f734d6c Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Fri, 3 Dec 2021 10:04:19 +0900 Subject: [PATCH 05/16] [VD] Correct spelling Suface --> Surface Change-Id: Ic51b7a5ea3d64b284ed8c87ad8f838d62eebce45 Signed-off-by: DongHyun Song --- wrt_app/common/web_application_delegate.ts | 2 +- wrt_app/src/web_application.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wrt_app/common/web_application_delegate.ts b/wrt_app/common/web_application_delegate.ts index 7d3bd18..62f2661 100644 --- a/wrt_app/common/web_application_delegate.ts +++ b/wrt_app/common/web_application_delegate.ts @@ -28,7 +28,7 @@ export class WebApplicationDelegate { beforeQuit() { } canIgnoreSuspend() { return false; } clearCache() { } - clearSuface(webContents: any) { } + clearSurface(webContents: any) { } focus(webContents: any) { } handleAppControlEvent(appControl: any) { return true; } handleProxyInfo(authInfo: any, callback: any) { return false; } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index aa020c0..640b49c 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -416,7 +416,7 @@ export class WebApplication { } private closeWindows() { - this.profileDelegate.clearSuface(this.mainWindow.webContents); + this.profileDelegate.clearSurface(this.mainWindow.webContents); this.windowList.slice().forEach((window) => { if (window != this.mainWindow) window.destroy(); -- 2.7.4 From 51b868a4854fda360f61dc1b26989bf244c5e944 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Wed, 9 Feb 2022 15:43:06 +0900 Subject: [PATCH 06/16] Remove WRTWindow and WRTWebContents modules . remove unnecesary modules . fix typescript build errors Change-Id: I1338fbea96f612e4087dcea2e56be656063a9a60 Signed-off-by: SangYong Park --- packaging/wrtjs.spec | 4 +-- wrt_app/addon/browser/modules/messaging.ts | 5 ++-- wrt_app/addon/browser/modules/window.ts | 45 +++++++++++++++--------------- wrt_app/browser/wrt_web_contents.ts | 32 --------------------- wrt_app/browser/wrt_window.ts | 44 ----------------------------- wrt_app/src/runtime.ts | 2 +- wrt_app/src/tv/web_application_tv.ts | 4 +-- wrt_app/src/web_application.ts | 9 ++---- 8 files changed, 34 insertions(+), 111 deletions(-) delete mode 100644 wrt_app/browser/wrt_web_contents.ts delete mode 100644 wrt_app/browser/wrt_window.ts diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index b729517..e605fba 100644 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -23,9 +23,9 @@ Source: %{name}-%{version}.tar.gz # The category is public feature %if "%{?profile}" != "tv" && "%{?profile}" != "wearable" && "%{?_with_da_profile}" != "1" %ifarch armv7l - %define _use_nmt 1 + %define _use_nmt 0 %endif - %define _use_category 1 + %define _use_category 0 %endif BuildRequires: pkgconfig(chromium-efl) diff --git a/wrt_app/addon/browser/modules/messaging.ts b/wrt_app/addon/browser/modules/messaging.ts index eeccb5f..7a68b39 100644 --- a/wrt_app/addon/browser/modules/messaging.ts +++ b/wrt_app/addon/browser/modules/messaging.ts @@ -7,6 +7,7 @@ export const on = function (channel: string, listener: (event: Electron.IpcMainE }; export const send = function (winId: number, channel: string, ...args: any[]) { - let window = BrowserWindow.fromId(winId); - window.webContents.send(channel, ...args); + const window = BrowserWindow.fromId(winId); + if (window) + window.webContents.send(channel, ...args); }; diff --git a/wrt_app/addon/browser/modules/window.ts b/wrt_app/addon/browser/modules/window.ts index 1a5e7c2..b775fe8 100644 --- a/wrt_app/addon/browser/modules/window.ts +++ b/wrt_app/addon/browser/modules/window.ts @@ -1,40 +1,41 @@ 'use strict'; import { dialog, BrowserWindow } from 'electron'; -import * as WRTWebContents from '../../../browser/wrt_web_contents'; -import { WRTWindow } from '../../../browser/wrt_window'; -export const loadURL= function (winId: number, url: string) { - let window = BrowserWindow.fromId(winId); - window.loadURL(url); +export const loadURL = function (winId: number, url: string) { + const window = BrowserWindow.fromId(winId); + if (window) + window.loadURL(url); }; -export const showMessageBox = function (winId: number, options: Electron.MessageBoxOptions) { - let window = BrowserWindow.fromId(winId); - let showMessageBox = (dialog.showMessageBoxSync || dialog.showMessageBox); - showMessageBox(window, options); +export const showMessageBox = function (winId: number, options: Electron.MessageBoxOptions) { + const showMessageBox = (dialog.showMessageBoxSync || dialog.showMessageBox); + const window = BrowserWindow.fromId(winId); + if (window) + showMessageBox(window, options); }; export const show = function (winId: number) { - let window = BrowserWindow.fromId(winId); - window.show(); + const window = BrowserWindow.fromId(winId); + if (window) + window.show(); }; -export const executeJavaScript= function (winId: number, string: string) { - let window = BrowserWindow.fromId(winId); - window.webContents.executeJavaScript(string, true); +export const executeJavaScript = function (winId: number, string: string) { + const window = BrowserWindow.fromId(winId); + if (window) + window.webContents.executeJavaScript(string, true); }; export const open = function (url: string) { - let window = new WRTWindow( - { webPreferences: { - nodeIntegration: true, - nodeIntegrationInSubFrames: true, - nodeIntegrationInWorker: false, - nativeWindowOpen: true, - }, - webContents: WRTWebContents.create(), + const window = new BrowserWindow({ + webPreferences: { + nodeIntegration: true, + nodeIntegrationInSubFrames: true, + nodeIntegrationInWorker: false, + nativeWindowOpen: true, + }, }); window.loadURL(url); return window.id; diff --git a/wrt_app/browser/wrt_web_contents.ts b/wrt_app/browser/wrt_web_contents.ts deleted file mode 100644 index 38ab268..0000000 --- a/wrt_app/browser/wrt_web_contents.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const binding: NativeWRTjs.WRTWebContentsBinding = process.wrtBinding('wrt_web_contents'); -const { WRTWebContents } = binding; -const { WebContents: ElectronWebContents } = process.wrtBinding('electron_browser_web_contents'); - -const parent = ElectronWebContents.prototype; -ElectronWebContents.prototype = WRTWebContents.prototype; - -Object.setPrototypeOf(WRTWebContents.prototype, parent); - -WRTWebContents.prototype._init = function () { - parent._init.call(this); -} - -export const create = (options = {}) => { - return binding.create(options); -} diff --git a/wrt_app/browser/wrt_window.ts b/wrt_app/browser/wrt_window.ts deleted file mode 100644 index ebb7423..0000000 --- a/wrt_app/browser/wrt_window.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { BrowserWindow } from 'electron'; -import * as WRTWebContents from '../browser/wrt_web_contents'; - -export const { WRTWindow } = process.wrtBinding('wrt_window'); - -Object.setPrototypeOf(WRTWindow.prototype, BrowserWindow.prototype); - -WRTWindow.prototype._init = function () { - (BrowserWindow.prototype as any)._init.call(this); - // This removes a macOS specific hack present in electron - // that causes side effects on Tizen - this.webContents.removeAllListeners('load-url'); - if (typeof this.setup === 'function') - this.setup(); - this.constructor = BrowserWindow; - this.webContents.on('new-window', (event: Electron.NewWindowWebContentsEvent, - url: string, - frameName: string, - disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'), - options: any) => { - event.preventDefault(); - if (!options.webContents) { - options.webContents = WRTWebContents.create(); - options.webContents.loadURL(url); - } - event.newGuest = new WRTWindow(options); - }); -} diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index f92cfeb..6cb1e77 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -132,7 +132,7 @@ class Runtime { const Module = require('module'); Module.globalPaths.push(wrt.getAppPath()); let filePath = src[7] === '/' ? src.substr(8) : src.substr(7); // strip "file://" - let pkgJson = require(filePath); + let pkgJson: any = require(filePath); let pos = filePath.lastIndexOf('/'); let mainJsPath = (pos !== -1 ? filePath.substr(0, pos + 1) : '') + diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index eeaaae5..ca8a5d0 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -174,9 +174,9 @@ Then you can get profile log from the initial loading.`; this.webApplication.windowList.forEach((window) => { //clear webframe cache this.tv.clearWebCache(window.webContents); - window.webContents.session.clearCache(function() { + window.webContents.session.clearCache().then(() => { console.log('clear session Cache complete'); - }) + }); }); } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 640b49c..b206872 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -16,10 +16,8 @@ 'use strict'; -import { app, session } from 'electron'; +import { BrowserWindow, app, session } from 'electron'; import { wrt } from '../browser/wrt'; -import * as WRTWebContents from '../browser/wrt_web_contents'; -import { WRTWindow } from '../browser/wrt_window'; import { addonManager } from './addon_manager'; import { WebApplicationDelegate } from '../common/web_application_delegate'; import { WebApplicationDelegateTV } from './tv/web_application_tv'; @@ -53,7 +51,7 @@ export class WebApplication { this.profileDelegate = new WebApplicationDelegate(this); } this.setupEventListener(options); - this.mainWindow = new WRTWindow(this.getWindowOption(options)); + this.mainWindow = new BrowserWindow(this.getWindowOption(options)); this.initDisplayDelay(); this.setupMainWindowEventListener(); } @@ -166,7 +164,7 @@ export class WebApplication { }); } - private getWindowOption(options: RuntimeOption): NativeWRTjs.WRTWindowConstructorOptions { + private getWindowOption(options: RuntimeOption): Electron.BrowserWindowConstructorOptions { return { fullscreen: false, backgroundColor: this.defaultBackgroundColor, @@ -178,7 +176,6 @@ export class WebApplication { nodeIntegrationInWorker: false, nativeWindowOpen: true, }, - webContents: WRTWebContents.create(), }; } -- 2.7.4 From 29c7e688eafd0dffcf231ecf58f78a3484800d5b Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Fri, 11 Feb 2022 09:47:08 +0900 Subject: [PATCH 07/16] [Tizen 7.0] Sync up branches from tizen_6.5 to tizen [Service] Terminate service apps one by one https://review.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/267413/ [Service] Support requestTrustedRemoteMessagePort https://review.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/267572/ Change-Id: I0ac239a8f731be00f0eabc6b01413c8b0c52362b Signed-off-by: DongHyun Song --- wrt_app/service/device_api_router.ts | 42 ++++++++++++++++++++++++++++-------- wrt_app/service/service_manager.ts | 19 ++++++++++++++-- 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 98cbe03..b0a2b6d 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -11,7 +11,6 @@ export class DeviceAPIRouter { funcGetMetadata: any; funcGetPackageInfo: any; funcRequestLocalMessagePort: any; - funcRequestTrustedLocalMessagePort: any; id: string; serviceId: string; @@ -19,6 +18,7 @@ export class DeviceAPIRouter { callerAppId: string; permissions: string[]; pkgApiVersion: string; + messagePortInfo: any; constructor(id: string, isGlobal: boolean) { this.id = id; @@ -28,6 +28,7 @@ export class DeviceAPIRouter { this.packageId = wrt.getPackageId(id); this.permissions = []; this.pkgApiVersion = ''; + this.messagePortInfo = {}; this.initWebapis(); if (isGlobal) { @@ -324,19 +325,28 @@ export class DeviceAPIRouter { refineMessagePortApis() { this.funcRequestLocalMessagePort = global.tizen.messageport.requestLocalMessagePort; - this.funcRequestTrustedLocalMessagePort = - global.tizen.messageport.requestTrustedLocalMessagePort; - const registerMessagePort = (name: string, portName: string) => { + const registerMessagePort = (name: string, portName: string, appId?: string, callback?: any) => { + let portInfo = `${name}::${this.serviceId}::${portName}`; + if (this.messagePortInfo[portInfo] === 'created') { + callback?.(); + return; + } let data_payload = [ - new global.tizen.ApplicationControlData(name, [ portName ]), - + new global.tizen.ApplicationControlData(name, [portName]), ]; + if (appId) { + data_payload.push(new global.tizen.ApplicationControlData('appId', [appId])); + } let appControl = new global.tizen.ApplicationControl( - "http://tizen.org/appcontrol/operation/default", null, null, null, - data_payload, null); + "http://tizen.org/appcontrol/operation/default", null, null, null, + data_payload, null); global.tizen.application.launchAppControl(appControl, this.serviceId, - () => console.debug(`'${this.serviceId}::${name}' is requsted`)); + () => { + console.debug(`'${portInfo}' is requsted`) + callback?.(); + this.messagePortInfo[portInfo] = 'created'; + }); } global.tizen.messageport.requestLocalMessagePort = (portName: string) => { @@ -347,5 +357,19 @@ export class DeviceAPIRouter { registerMessagePort('requestTrustedLocalMessagePort', portName); return this.funcRequestLocalMessagePort(portName); } + global.tizen.messageport.requestTrustedRemoteMessagePort = (appId: string, portName: string) => { + return { + messagePortName: portName, + appId, + isTrusted: true, + sendMessage: (data: any, localMessagePort?: any) => { + registerMessagePort('requestTrustedRemoteMessagePort', portName, appId, + () => { + let remotePort = global.tizen.messageport.requestRemoteMessagePort(this.serviceId, portName); + remotePort.sendMessage(data, localMessagePort); + }); + } + } + } } } diff --git a/wrt_app/service/service_manager.ts b/wrt_app/service/service_manager.ts index fe3fd77..c639eba 100644 --- a/wrt_app/service/service_manager.ts +++ b/wrt_app/service/service_manager.ts @@ -6,12 +6,24 @@ interface WorkerMap { [id: string]: any; } let workers: WorkerMap = {}; +let dyingWorkerQueue: WorkerMap = {}; Object.defineProperty(global, 'serviceType', { value: wrt.getServiceModel(), writable: false }); +function checkDyingWorker() { + let dyingWorkers = Object.keys(dyingWorkerQueue); + if (dyingWorkers.length) { + let workerId = dyingWorkers[0]; + if (dyingWorkerQueue[workerId] === 'will-terminate') { + dyingWorkerQueue[workerId] = 'terminated'; + workers[workerId].terminate(); + } + } +} + function createWorker(id: string, startService: string, filename: string) { if (workers[id]) { workers[id].postMessage({ type: 'wake' }); @@ -27,14 +39,17 @@ function createWorker(id: string, startService: string, filename: string) { }); workers[id].on('message', (message: string) => { if (message === 'will-terminate') { - workers[id].terminate(); + dyingWorkerQueue[id] = message; + checkDyingWorker(); } }); workers[id].on('exit', (code: number) => { wrt.tv?.serviceUmount(id); + delete dyingWorkerQueue[id]; delete workers[id]; let runningServices = Object.keys(workers); - console.debug(`exit code(${code}), remain services(${runningServices})`); + console.debug(`${id} terminated, remain services(${runningServices})`); + checkDyingWorker(); }); } -- 2.7.4 From 33baa98aefc7b5dffbb9f9ca93e672d8a618c88f Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Tue, 4 Jan 2022 12:05:15 +0900 Subject: [PATCH 08/16] [DeviceHome] Send push registration id Send push registration id with device info, which is given from wrt-service-broker when push connection is established. Change-Id: I8858983bf4f7f85072e1bd5dfa170d1f419d2f3c Signed-off-by: DongHyun Song --- device_home/service/initializer/service.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/device_home/service/initializer/service.js b/device_home/service/initializer/service.js index 1d782a0..d3db0ab 100755 --- a/device_home/service/initializer/service.js +++ b/device_home/service/initializer/service.js @@ -22,10 +22,23 @@ class Initializer { console.log(`${TAG} failed to get device_ip`); return; } + let req_id = ''; + let req_appcontrol = tizen.application.getCurrentApplication().getRequestedAppControl(); + if (req_appcontrol) { + let data = req_appcontrol.appControl.data; + data.forEach((bundle) => { + if (bundle.key === 'push_reg_id') { + req_id = bundle.value[0]; + return false; + } + }) + } + const device = { device_ip: this.device_ip, device_name: this.device_name, - login_id: this.login_id + login_id: this.login_id, + req_id }; console.log(`${TAG} device :`, device); const data = JSON.stringify(device); -- 2.7.4 From 32173918d0ebb7ac60cb0ee83b99de0f617e04f6 Mon Sep 17 00:00:00 2001 From: Surya Kumar Date: Tue, 22 Feb 2022 21:29:44 +0530 Subject: [PATCH 09/16] [HOTFIX] Skip chromium-efl revision check Revision check is failing with latest M94 chromium-efl rpm, breaking wrtjs rpm installation, so skipping the check temporarily Change-Id: I909cf665e4c6abf2ee71abcdaf6b898f3cb5d679 Signed-off-by: Surya Kumar --- packaging/wrtjs.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index e605fba..c62a600 100644 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -257,7 +257,7 @@ else fi echo -e "* please re-install chromium-efl as revision $WRTJS_REVISION first." echo -e "*****************************************************\033[m" - exit 1 + echo -e "but going through" fi %post -- 2.7.4 From 62b8195365302d43a2f707422f254e510358fb16 Mon Sep 17 00:00:00 2001 From: Surya Kumar Date: Fri, 25 Feb 2022 16:38:22 +0530 Subject: [PATCH 10/16] Revert "[HOTFIX] Skip chromium-efl revision check" This reverts commit 32173918d0ebb7ac60cb0ee83b99de0f617e04f6 since fix has landed from chromium-efl side Depends on: https://review.tizen.org/gerrit/271727 Change-Id: I6296b34fcdba68c81fe5ab5494fca8a0f52fafd6 Signed-off-by: Surya Kumar --- packaging/wrtjs.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index c62a600..e605fba 100644 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -257,7 +257,7 @@ else fi echo -e "* please re-install chromium-efl as revision $WRTJS_REVISION first." echo -e "*****************************************************\033[m" - echo -e "but going through" + exit 1 fi %post -- 2.7.4 From b4ac724e0687b9f02e5e33826bfdc15faca593cd Mon Sep 17 00:00:00 2001 From: Surya Kumar Date: Tue, 1 Mar 2022 12:53:10 +0530 Subject: [PATCH 11/16] Disable typescript checks temporarily This change disables strict TS checks to resolve M85 SR build failures Change-Id: I919041e13c7fbc9415d86cb0547f889a380c42f7 Signed-off-by: Surya Kumar --- wrt_app/addon/browser/modules/window.ts | 2 ++ wrt_app/src/web_application.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/wrt_app/addon/browser/modules/window.ts b/wrt_app/addon/browser/modules/window.ts index b775fe8..4ee3195 100644 --- a/wrt_app/addon/browser/modules/window.ts +++ b/wrt_app/addon/browser/modules/window.ts @@ -1,3 +1,5 @@ +// @ts-nocheck + 'use strict'; import { dialog, BrowserWindow } from 'electron'; diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index b206872..bdf777f 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -1,3 +1,5 @@ +// @ts-nocheck + /* * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved * -- 2.7.4 From 9b23c1bb96d0d1f1e137e6f3edfcefe182516ad3 Mon Sep 17 00:00:00 2001 From: "yman.son" Date: Mon, 7 Mar 2022 15:18:01 +0900 Subject: [PATCH 12/16] [VD] add metadata-profile.xml Create a description of some metadata being used by the VD. This will be managed by PLATZ system. (SE team request) Change-Id: If9ea8c67f2aaf6db085aceef4bf7136338ab9fba Signed-off-by: yman.son --- packaging/metadata-profile.xml | 60 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 packaging/metadata-profile.xml diff --git a/packaging/metadata-profile.xml b/packaging/metadata-profile.xml new file mode 100755 index 0000000..8eb87d7 --- /dev/null +++ b/packaging/metadata-profile.xml @@ -0,0 +1,60 @@ + + + + + Y + 1.0 + + false | true + + + true : Normal device. + false : Low performance device. (Priority is higher than this metadata.) + + + + + + + + N + 1.0 + + true | false + + + false + + + + + + + + Y + 1.0 + + true | false + + + false : Opaque window. + + + + + + + + N + 1.0 + + true | false + + + true + + + + + + -- 2.7.4 From 5172c7c332f15f9f91fabbcd412d43dcc723ae6d Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Fri, 4 Mar 2022 10:20:55 +0900 Subject: [PATCH 13/16] [Service][VD] Add webapis.getPreviewData() This provides preview tiles data for DeviceHome service. Related chromium-efl patch: https://review.tizen.org/gerrit/269316/ Change-Id: I2c4df503ab1791a63768bd5effdd82f99ad9fdca Signed-off-by: DongHyun Song --- wrt_app/service/device_api_router.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index b0a2b6d..5f30ad0 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -56,11 +56,23 @@ export class DeviceAPIRouter { global.webapis.postPlainNotification = (title: string, message: string, timeout?: number) => { return wrt.postPlainNotification(title, message, timeout ?? 10); } + global.webapis.getPreviewData = (packageId: string) => { + try { + if (wrt.tv) + return wrt.tv.getPreviewData(packageId); + else + throw 'This API is only for TV profile'; + } catch(e) { + console.debug(`wrt.tv.getPreviewData('${packageId}') failed, ${e}`); + return { images: 'no' }; + } + } Object.defineProperties(global.webapis, { getCallerAppId: { writable: false, enumerable: true }, getPackageId: { writable: false, enumerable: true }, getServiceId: { writable: false, enumerable: true }, postPlainNotification: { writable: false, enumerable: true }, + getPreviewData: { writable: false, enumerable: true }, }); this.initMDEWebapis(); this.initEdgeWebapis(); -- 2.7.4 From 256507147ae41cf61365756cac27a616a7a23d82 Mon Sep 17 00:00:00 2001 From: zhaosy Date: Thu, 10 Mar 2022 14:53:55 +0800 Subject: [PATCH 14/16] [VD]Show window for preload app in deeplink scenario If app is preload, and then deeplink launch it, doesn't call show window, so app is not showing in foreground. Change-Id: I0c1f9eeacc06cbbc0b6332077167540185164c36 Signed-off-by: zhaosy --- wrt_app/src/tv/web_application_tv.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index ca8a5d0..65e7499 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -231,6 +231,9 @@ Then you can get profile log from the initial loading.`; this.webApplication.sendAppControlEvent(); return false; } else { + if (!this.webApplication.mainWindow.isVisible()) + this.webApplication.show(); + let skipReload = appControl.getData('SkipReload'); if (skipReload == 'Yes') { console.log('skipping reload'); -- 2.7.4 From ad13bc8f7207c7b27a5e050a48b79cb3c4a97ae8 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 10 Mar 2022 17:23:22 +0900 Subject: [PATCH 15/16] [Service][VD] Add mde APIs to handle remote input 'updateRemoteInput' is an API to fill the input string at the IME input field. 'selectRemoteInput' is an API to submit the string of IME form. Change-Id: I2ff3f77d267e0e6e8e586485c8b590b78f96d241 Signed-off-by: DongHyun Song --- wrt_app/service/device_api_router.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 5f30ad0..afbd161 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -99,6 +99,12 @@ export class DeviceAPIRouter { global.webapis.mde.initVirtualEventGenerator = (type: number) => { return mde.initVirtualEventGenerator(type); } + global.webapis.mde.updateRemoteInput = (inputString: string) => { + mde.updateRemoteInput(inputString); + } + global.webapis.mde.selectRemoteInput = () => { + mde.selectRemoteInput(); + } } global.webapis.mde.getCurrentLoginId = () => { return mde.getCurrentLoginId(); -- 2.7.4 From 896a407d511e7961c7160c771a01fdbb9fc3772a Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Mon, 14 Mar 2022 15:11:20 +0900 Subject: [PATCH 16/16] [Service][TV] Introduce ServiceMessage This introduces service message notification for DeviceHome The case doesn't use Samsung IME, the UI app can utilize ServiceMessage to catch propagating message from DeviceHome. notifyServiceMessage() will give a message only to foreground application. Change-Id: If36cb754382fc2c0f6d186c212a40c28ccf3eb9b Signed-off-by: DongHyun Song --- wrt_app/common/service_message.ts | 20 ++++++++++++++++++++ wrt_app/service/device_api_router.ts | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 wrt_app/common/service_message.ts diff --git a/wrt_app/common/service_message.ts b/wrt_app/common/service_message.ts new file mode 100644 index 0000000..4080701 --- /dev/null +++ b/wrt_app/common/service_message.ts @@ -0,0 +1,20 @@ +import { wrt } from '../browser/wrt'; + +let foregroundAppMessagePort: any = null; +let lastForegroundApp: string = ''; + +export function notifyServiceMessage(type: string, message: string) { + let foregroundApp = wrt.tv?.getForegroundApp(); + if (!foregroundApp || foregroundApp == 'none') + return; + + try { + if (!foregroundAppMessagePort || lastForegroundApp != foregroundApp) { + foregroundAppMessagePort = + global.tizen.messageport.requestRemoteMessagePort(foregroundApp, 'wrt.message.port'); + lastForegroundApp = foregroundApp; + } + if (foregroundAppMessagePort) + foregroundAppMessagePort.sendMessage([{key: type, value: ['', message]}]); + } catch { } +} diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index afbd161..eed2979 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -1,4 +1,5 @@ import { wrt } from '../browser/wrt'; +import * as ServiceMessage from '../common/service_message'; export class DeviceAPIRouter { currentApplication: any; @@ -101,6 +102,7 @@ export class DeviceAPIRouter { } global.webapis.mde.updateRemoteInput = (inputString: string) => { mde.updateRemoteInput(inputString); + ServiceMessage.notifyServiceMessage('remote-input', inputString); } global.webapis.mde.selectRemoteInput = () => { mde.selectRemoteInput(); -- 2.7.4