From 943c25bda3bd3c48c94efd61d85182018292f54d Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 2 Dec 2020 17:14:35 +0900 Subject: [PATCH 01/16] Refactor app-control event to improve readability 1) Split into small functions by their roles. 2) Move functions to proper class - most of them are located in WebApplication Change-Id: Ibd03eb6b6ef29c197266b7b9d51393134c06c375 Signed-off-by: DongHyun Song --- wrt_app/src/runtime.ts | 127 ++++++++++++++--------------------------- wrt_app/src/web_application.ts | 86 +++++++++++++++++++++++++--- 2 files changed, 120 insertions(+), 93 deletions(-) diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index 8857abd..8687822 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -80,92 +80,16 @@ class Runtime { wrt.on('app-control', (event: any, appControl: any) => { console.log('app-control'); - let loadInfo = appControl.getLoadInfo(); - let src = loadInfo.getSrc(); - if (wrt.isElectronApp()) { - console.log('Electron App launch'); - 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 pos = filePath.lastIndexOf('/'); - - let mainJsPath = (pos !== -1 ? filePath.substr(0, pos + 1) : '') + - (pkgJson.main || 'index.js'); - console.log('loading path:', mainJsPath); - Module._load(mainJsPath, Module, true); - app.emit('ready'); + this.handleAppControlForElectronApp(appControl); + return; + } + console.log('Tizen Web App launch'); + if (!this.webApplication) { + this.createWebApplicationAndLoadUrl(appControl); } else { - console.log('Tizen Web App launch'); - let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode'); - if (!this.webApplication) { - console.log('Creating WebApplication'); - let options: RuntimeOption = { - isAddonAvailable: addonManager.isAddonAvailable(), - launchMode: launchMode - } - this.webApplication = new WebApplication(options); - if (wrt.tv) { - this.inspectorEnabledByVconf = wrt.tv.needUseInspector(); - if (this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') { - this.webApplication.inspectorSrc = src; - src = "about:blank"; - } - } - this.webApplication.mainWindow.loadURL(src); - this.webApplication.prelaunch(src); - if (wrt.da) { - this.webApplication.mainWindow.emit('ready-to-show'); - } - } else { - console.log('Handling app-control event'); - if (this.webApplication.preloadStatus == 'readyToShow') { - this.webApplication.show(); - } else { - if (launchMode != 'backgroundAtStartup') - this.webApplication.preloadStatus = 'none'; - } - - let skipReload = appControl.getData('SkipReload'); - if (skipReload == 'Yes') { - console.log('skipping reload'); - // TODO : Need to care this situation and decide to pass the addon event emitter to resume() - this.webApplication.resume(); - return; - } - - let reload = loadInfo.getReload() || this.webApplication.isAlwaysReload; - if (!reload) { - let originalUrl = this.webApplication.mainWindow.webContents.getURL(); - if (wrt.tv) { - console.log(`appcontrol src = ${src}, original url = ${originalUrl}`); - if (src && originalUrl) { - let appcontrolUrl = (new URL(src)).href; - let oldUrl = (new URL(originalUrl)).href; - console.log(`appcontrolUrl = ${appcontrolUrl}, oldUrl = ${oldUrl}`); - // FIXME(dh81.song) - // Below case it must be distinguishable for known cases - // from 'file:///index.htmlx' to 'file:///index.html' - if (appcontrolUrl !== oldUrl.substr(0, appcontrolUrl.length)) - reload = true; - } else { - reload = true; - } - } else if (src !== originalUrl) { - reload = true; - } - } - // handle http://tizen.org/appcontrol/operation/main operation specially. - // only menu-screen app can send launch request with main operation. - // in this case, web app should have to resume web app not reset. - if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main') - reload = false; - if (reload) - this.webApplication.handleAppControlReload(src); - else - this.webApplication.sendAppControlEvent(); - } + console.log('Handling app-control event'); + this.webApplication.handleAppControlEvent(appControl); } this.launchInspector(appControl); }); @@ -225,6 +149,41 @@ class Runtime { wrt.getInstalledPkg(); } + private handleAppControlForElectronApp(appControl: any) { + console.log('Electron App launch'); + let src = appControl.getLoadInfo().getSrc(); + 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 pos = filePath.lastIndexOf('/'); + + let mainJsPath = (pos !== -1 ? filePath.substr(0, pos + 1) : '') + + (pkgJson.main || 'index.js'); + console.log('loading path:', mainJsPath); + Module._load(mainJsPath, Module, true); + app.emit('ready'); + } + + private createWebApplicationAndLoadUrl(appControl: any) { + console.log('Creating WebApplication'); + let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode'); + let src = appControl.getLoadInfo().getSrc(); + let options: RuntimeOption = { + isAddonAvailable: addonManager.isAddonAvailable(), + launchMode: launchMode + } + this.webApplication = new WebApplication(options); + if (wrt.tv) { + this.inspectorEnabledByVconf = wrt.tv.needUseInspector(); + if (this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') { + this.webApplication.inspectorSrc = src; + src = "about:blank"; + } + } + this.webApplication.loadUrl(src); + } + private launchInspector(appControl: NativeWRTjs.AppControl) { this.launchInspector = (param) => {}; // call once console.log('launchInspector'); diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index ce20833..147ff8e 100755 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -27,7 +27,6 @@ export class WebApplication { backgroundExecution: boolean; defaultBackgroundColor: string; defaultTransparent: boolean; - isAlwaysReload: boolean; mainWindow: Electron.BrowserWindow; multitaskingSupport: boolean; notificationPermissionMap?: Map; @@ -60,7 +59,6 @@ export class WebApplication { this.backgroundExecution = false; } this.accessiblePath = wrt.tv?.getAccessiblePath(); - this.isAlwaysReload = (wrt.tv ? wrt.tv.isAlwaysReload() : false); this.multitaskingSupport = (wrt.tv ? wrt.tv.getMultitaskingSupport() : true); this.defaultBackgroundColor = (wrt.tv ? '#0000' : ((wrt.getPlatformType() === "product_wearable") ? '#000' : '#FFF')); @@ -312,13 +310,6 @@ export class WebApplication { return this.backgroundSupport || this.backgroundExecution; } - handleAppControlReload(url: string) { - console.log('WebApplication : handleAppControlReload'); - this.closeWindows(); - this.initDisplayDelay(false); - this.mainWindow.loadURL(url); - } - private suspendByStatus() { if (this.preloadStatus === 'readyToShow' || this.preloadStatus === 'preload' || @@ -354,6 +345,40 @@ 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); + + let skipReload = appControl.getData('SkipReload'); + if (skipReload == 'Yes') { + console.log('skipping reload'); + // TODO : Need to care this situation and decide to pass the addon event emitter to resume() + this.resume(); + return; + } + + let loadInfo = appControl.getLoadInfo(); + let src = loadInfo.getSrc(); + let reload = loadInfo.getReload() || this.needReload(src); + // handle http://tizen.org/appcontrol/operation/main operation specially. + // only menu-screen app can send launch request with main operation. + // in this case, web app should have to resume web app not reset. + if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main') + reload = false; + if (reload) + this.handleAppControlReload(src); + else + this.sendAppControlEvent(); + } + + loadUrl(src: string) { + this.mainWindow.loadURL(src); + this.prelaunch(src); + if (wrt.da) { + this.mainWindow.emit('ready-to-show'); + } + } + suspend() { if (this.suspended || this.inQuit) return; @@ -413,6 +438,49 @@ Then you can get profile log from the initial loading.`; this.inQuit = true; } + private needReload(src: string) { + let isAlwaysReload = (wrt.tv ? wrt.tv.isAlwaysReload() : false); + if (isAlwaysReload) { + return true; + } + let reload = false; + let originalUrl = this.mainWindow.webContents.getURL(); + if (wrt.tv) { + console.log(`appcontrol src = ${src}, original url = ${originalUrl}`); + if (src && originalUrl) { + let appcontrolUrl = (new URL(src)).href; + let oldUrl = (new URL(originalUrl)).href; + console.log(`appcontrolUrl = ${appcontrolUrl}, oldUrl = ${oldUrl}`); + // FIXME(dh81.song) + // Below case it must be distinguishable for known cases + // from 'file:///index.htmlx' to 'file:///index.html' + if (appcontrolUrl !== oldUrl.substr(0, appcontrolUrl.length)) + reload = true; + } else { + reload = true; + } + } else if (src !== originalUrl) { + reload = true; + } + return reload; + } + + private handleAppControlReload(url: string) { + console.log('WebApplication : handleAppControlReload'); + this.closeWindows(); + this.initDisplayDelay(false); + this.mainWindow.loadURL(url); + } + + private handlePreloadState(launchMode: string) { + if (this.preloadStatus == 'readyToShow') { + this.show(); + } else { + if (launchMode != 'backgroundAtStartup') + this.preloadStatus = 'none'; + } + } + private flushData() { console.log('WebApplication : FlushData'); this.windowList.forEach((window) => window.webContents.session.flushStorageData()); -- 2.7.4 From 2c0a8c5c989b12c33e1949597d0050e2e0291f21 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Fri, 4 Dec 2020 13:55:37 +0900 Subject: [PATCH 02/16] Using native window open window.open uses electron js logic when renderer was integrated with node. (node is integrated in renderer when addon is enabled. and default webapp do not use node in renderer side.). It has some compatibility issue. so, use native window open always. related: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/248981/ Change-Id: I8d786b2d9d1ba97796217f0b2cb2371e89b80479 Signed-off-by: SangYong Park --- wrt_app/browser/wrt_window.ts | 3 +-- wrt_app/src/web_application.ts | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wrt_app/browser/wrt_window.ts b/wrt_app/browser/wrt_window.ts index 2ac5a14..ebb7423 100644 --- a/wrt_app/browser/wrt_window.ts +++ b/wrt_app/browser/wrt_window.ts @@ -29,14 +29,13 @@ WRTWindow.prototype._init = function () { if (typeof this.setup === 'function') this.setup(); this.constructor = BrowserWindow; - let self = this; 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 === self) { + if (!options.webContents) { options.webContents = WRTWebContents.create(); options.webContents.loadURL(url); } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 147ff8e..fbaff44 100755 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -244,7 +244,8 @@ export class WebApplication { show: false, webPreferences: { nodeIntegration: options.isAddonAvailable, - nodeIntegrationInWorker: false + nodeIntegrationInWorker: false, + nativeWindowOpen: true, }, webContents: WRTWebContents.create(), }; -- 2.7.4 From cd3319229afa5f538281631e503915922d794f78 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 16 Dec 2020 17:37:57 +0900 Subject: [PATCH 03/16] Move inspector functions to WebApplication debugPort / inspectorSrc are members for WebApplication class. Then, move related functions to WebApplication is more proper and it can reduce to check webApplication instance. Change-Id: I7fc4415e25249e574270a38900fdcb2bd1e934e7 Signed-off-by: DongHyun Song --- wrt_app/src/runtime.ts | 31 +------------------------------ wrt_app/src/web_application.ts | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index 8687822..a729356 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -24,7 +24,6 @@ import { WebApplication } from './web_application'; class Runtime { webApplication?: WebApplication = undefined; isLaunched = false; - inspectorEnabledByVconf = false; constructor() { app.on('before-quit', (event: any) => { @@ -91,7 +90,6 @@ class Runtime { console.log('Handling app-control event'); this.webApplication.handleAppControlEvent(appControl); } - this.launchInspector(appControl); }); wrt.on('suspend', () => { @@ -168,39 +166,12 @@ class Runtime { private createWebApplicationAndLoadUrl(appControl: any) { console.log('Creating WebApplication'); let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode'); - let src = appControl.getLoadInfo().getSrc(); let options: RuntimeOption = { isAddonAvailable: addonManager.isAddonAvailable(), launchMode: launchMode } this.webApplication = new WebApplication(options); - if (wrt.tv) { - this.inspectorEnabledByVconf = wrt.tv.needUseInspector(); - if (this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') { - this.webApplication.inspectorSrc = src; - src = "about:blank"; - } - } - this.webApplication.loadUrl(src); - } - - private launchInspector(appControl: NativeWRTjs.AppControl) { - this.launchInspector = (param) => {}; // call once - console.log('launchInspector'); - - // AUL public key/Vconf - To support inspector - if (this.checkInspectorCondition(appControl)) { - let debugPort = wrt.startInspectorServer(); - let data = { "port" : [ debugPort.toString() ] }; - if (this.webApplication) - this.webApplication.debugPort = debugPort; - appControl.reply(data); - } - } - - private checkInspectorCondition(appControl: NativeWRTjs.AppControl) { - let bundleDebug = (appControl.getData('__AUL_DEBUG__') === "1"); - return (bundleDebug || this.inspectorEnabledByVconf); + this.webApplication.loadUrl(appControl); } private handleKeyEvents(key: string) { diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index 147ff8e..25a2441 100755 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -36,6 +36,7 @@ export class WebApplication { backgroundSupport = wrt.getBackgroundSupport(); debugPort = 0; firstRendered = false; + contentSrc = ''; inspectorSrc = ''; loadFinished = false; pendingCallbacks: Map = new Map(); @@ -371,9 +372,27 @@ Then you can get profile log from the initial loading.`; this.sendAppControlEvent(); } - loadUrl(src: string) { - this.mainWindow.loadURL(src); - this.prelaunch(src); + private launchInspectorIfNeeded(appControl: NativeWRTjs.AppControl) { + console.log('launchInspectorIfNeeded'); + let inspectorEnabledByVconf = wrt.tv ? wrt.tv.needUseInspector() : false; + if (inspectorEnabledByVconf && !this.backgroundExecution) { + this.inspectorSrc = this.contentSrc; + this.contentSrc = 'about:blank'; + } + let hasAulDebug = (appControl.getData('__AUL_DEBUG__') === '1'); + if (hasAulDebug || inspectorEnabledByVconf) { + let debugPort = wrt.startInspectorServer(); + let data = { "port": [debugPort.toString()] }; + this.debugPort = debugPort; + appControl.reply(data); + } + } + + loadUrl(appControl: NativeWRTjs.AppControl) { + this.contentSrc = appControl.getLoadInfo().getSrc(); + this.launchInspectorIfNeeded(appControl); + this.mainWindow.loadURL(this.contentSrc); + this.prelaunch(this.contentSrc); if (wrt.da) { this.mainWindow.emit('ready-to-show'); } -- 2.7.4 From 121c9f9320b787159d5aff9ba84d169ffd224155 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Tue, 29 Dec 2020 17:45:21 +0900 Subject: [PATCH 05/16] [Service] Apply worker to 'standalone' model 'standalone' model will not be used anywhere. TV will apply global wrt-service on Tizen 6.5 Change-Id: I1ebe5fbea6a9db4f56c1d9fb0c58cfa7e76fdb63 Signed-off-by: DongHyun Song --- wrt_app/common/service_manager.ts | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/wrt_app/common/service_manager.ts b/wrt_app/common/service_manager.ts index 14f0a87..face443 100644 --- a/wrt_app/common/service_manager.ts +++ b/wrt_app/common/service_manager.ts @@ -12,10 +12,6 @@ Object.defineProperty(global, 'serviceType', { writable: false }); -function isStandalone() { - return global['serviceType'] === 'STANDALONE'; -} - function createWorker(id: string, startService: string, filename: string) { if (workers[id]) return; @@ -49,26 +45,13 @@ function terminateWorker(id: string, delay: number) { export function startService(id: string, filename: string) { console.log(`startService - ${id}`); - if (isStandalone()) { - runner = require('../common/service_runner'); - runner.start(id, filename); - } else { - let startService = `${__dirname}/service_runner.js`; - createWorker(id, startService, filename); - } + let startService = `${__dirname}/service_runner.js`; + createWorker(id, startService, filename); } export function stopService(id: string) { console.log(`stopService - ${id}`); - if (isStandalone()) { - if (!runner) { - console.log('runner instance is null in standalone mode'); - return; - } - runner.stop(id); - } else { - terminateWorker(id, 500); - } + terminateWorker(id, 500); } export function handleBuiltinService(serviceId: string, serviceName: string) { -- 2.7.4 From 054d81987df8f183576a9445f5db71f8cc56cb8b Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 6 Jan 2021 12:32:25 +0900 Subject: [PATCH 06/16] [Tizen6.5 Migration][Service] Support simple notification popup User apps can use this notification posting API by calling webapis.postPlainNotification() - title: string, mandatory - message: string, mandatory - timeout: number, optional (10s default) Actually, this feature is alternative simple solution to show notification popup of tizen.UserNotification webapi. Global notification webapis is not included in TV platform. Related patch: https://review.tizen.org/gerrit/250942/ Change-Id: Ibf51f707be4b1edf3fc50dd94041df38cbdae168 Signed-off-by: DongHyun Song --- wrt_app/service/device_api_router.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 7cb70cb..7f6548f 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -37,21 +37,30 @@ export class DeviceAPIRouter { } initWebapis() { - global.webapis = global.webapis ?? {}; + let app_info = global.tizen.application.getAppInfo(this.serviceId); + if (app_info) { + this.packageId = app_info.packageId; + } + global.webapis = global.webapis ?? {}; global.webapis.getCallerAppId = () => { return this.callerAppId; } global.webapis.getServiceId = () => { return this.serviceId; } - let app_info = global.tizen.application.getAppInfo(this.serviceId); - if (app_info) { - this.packageId = app_info.packageId; - } global.webapis.getPackageId = () => { return this.packageId; } + global.webapis.postPlainNotification = (title: string, message: string, timeout?: number) => { + return wrt.postPlainNotification(title, message, timeout ?? 10); + } + Object.defineProperties(global.webapis, { + getCallerAppId: { writable: false, enumerable: true }, + getPackageId: { writable: false, enumerable: true }, + getServiceId: { writable: false, enumerable: true }, + postPlainNotification: { writable: false, enumerable: true }, + }); this.initProductWebapis(); } -- 2.7.4 From 01d638f95796fba2fbc1e7a8dee138e00eb2543f Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 8 Jan 2021 17:52:11 +0800 Subject: [PATCH 07/16] [VD] Get app forcereload flag in webapplication constructor For wrt autotest tc which check "force.loadDefaultURI" metadata, get app forcereload flag(force.loadDefaultURI) in constructor, otherwise it's hard to make a scenario by test script to check this metadata. Change-Id: I38ae46846687ab52a874d8dff22d62f581b9491f Signed-off-by: liwei --- wrt_app/src/web_application.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100755 => 100644 wrt_app/src/web_application.ts diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts old mode 100755 new mode 100644 index 25a2441..dee5636 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -27,6 +27,7 @@ export class WebApplication { backgroundExecution: boolean; defaultBackgroundColor: string; defaultTransparent: boolean; + isAlwaysReload: boolean; mainWindow: Electron.BrowserWindow; multitaskingSupport: boolean; notificationPermissionMap?: Map; @@ -60,6 +61,7 @@ export class WebApplication { this.backgroundExecution = false; } this.accessiblePath = wrt.tv?.getAccessiblePath(); + this.isAlwaysReload = (wrt.tv ? wrt.tv.isAlwaysReload() : false); this.multitaskingSupport = (wrt.tv ? wrt.tv.getMultitaskingSupport() : true); this.defaultBackgroundColor = (wrt.tv ? '#0000' : ((wrt.getPlatformType() === "product_wearable") ? '#000' : '#FFF')); @@ -458,8 +460,7 @@ Then you can get profile log from the initial loading.`; } private needReload(src: string) { - let isAlwaysReload = (wrt.tv ? wrt.tv.isAlwaysReload() : false); - if (isAlwaysReload) { + if (this.isAlwaysReload) { return true; } let reload = false; -- 2.7.4 From 486ed93ebf9d237de154cd431219727f46221e42 Mon Sep 17 00:00:00 2001 From: liwei Date: Fri, 15 Jan 2021 10:19:22 +0800 Subject: [PATCH 08/16] [Tizen6.5 Migration][Service] Print appcontrol data when service app is launched Now in many scenario UI app launch service app, service app will check tizen.application.getCurrentApplication().getRequestedAppControl() operation and data, so print this data is good for debugging. (ex. 3201506003227, STARZY) Related patch: https://review.tizen.org/gerrit/248053/ Change-Id: I9f7b6c6319ddc0e16089ef826855ce064aeb754f Signed-off-by: liwei --- wrt_app/common/service_runner.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wrt_app/common/service_runner.ts b/wrt_app/common/service_runner.ts index 8913929..4a0d1f1 100644 --- a/wrt_app/common/service_runner.ts +++ b/wrt_app/common/service_runner.ts @@ -16,6 +16,15 @@ function isServiceApplication() { function isGlobalService() { return global['serviceType'] === 'GLOBAL'; } +function printAppControlData(id: string) { + var reqAppControl = global.tizen.application.getCurrentApplication().getRequestedAppControl(); + var appControlData = reqAppControl.appControl.data; + console.log(`id: ${id}, appControlData operation: ${reqAppControl.appControl.operation}`); + for (var dataIndex in appControlData) { + for (var valueIndex in appControlData[dataIndex].value) + console.log(`data[${dataIndex}][${valueIndex}]: ${appControlData[dataIndex].value[valueIndex]}`); + } +} function registerExtensionResolver(id: string) { if (wrt.tv) { @@ -63,6 +72,7 @@ export function start(id: string, filename: string) { // FIXME: this is for awaking up uv loop. // uv loop is sleeping for a few second with tizen webapis's aync callback fakeTimer = setInterval(() => {}, 100); + printAppControlData(id); try { app = require(filename); if (app.onStart !== undefined) { -- 2.7.4 From ae44edd7eb4d09634531b218e16f3830ceee4ab5 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 17 Dec 2020 14:07:33 +0900 Subject: [PATCH 09/16] [Tizen6.5 Migration][Service] Add getPkgApiVersion for global model xwalk.utils.getPkgApiVersion will return required_version of config.xml. (a.k.a. api version) This getPkgApiVersion() is used to check api privileges which is allowed in Tizen platform version. Without this patch, getPkgApiVersion() will returns wrt-service package's api version in its manifest. Reference: https://review.tizen.org/gerrit/247389/ Change-Id: Id084f2eda53e3310a2d7c5842d6bd1be4ca34fe0 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 7cb70cb..50f6c99 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -16,6 +16,7 @@ export class DeviceAPIRouter { packageId: string; callerAppId: string; permissions: string[]; + pkgApiVersion: string; constructor(id: string, isGlobal: boolean) { this.id = id; @@ -24,10 +25,12 @@ export class DeviceAPIRouter { this.callerAppId = ids[1] ?? ''; this.packageId = this.serviceId.split('.')[0]; this.permissions = []; + this.pkgApiVersion = ''; this.initWebapis(); if (isGlobal) { this.permissions = wrt.getPrivileges(this.id); + this.pkgApiVersion = wrt.getPkgApiVersion(this.id); this.refineApplicationApis(); this.refinePackageApis(); this.refineFilesystemApis() @@ -276,5 +279,8 @@ export class DeviceAPIRouter { throw 'Permission denied'; } } + global.xwalk.utils.getPkgApiVersion = () => { + return this.pkgApiVersion; + } } } -- 2.7.4 From dfee77be66960867ceb25f0bceba8565e802702a Mon Sep 17 00:00:00 2001 From: liwei Date: Thu, 21 Jan 2021 11:25:11 +0800 Subject: [PATCH 10/16] fixup![Tizen6.5 Migration][Service] Print appcontrol data when service app is launched When service app is launched by "new Service()", appcontrol is not set, so need pre-check appcontrol. Change-Id: I6c9d312e2addee1e7e0c5308ce637f93ecede196 Signed-off-by: liwei --- wrt_app/common/service_runner.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wrt_app/common/service_runner.ts b/wrt_app/common/service_runner.ts index 4a0d1f1..3522d75 100644 --- a/wrt_app/common/service_runner.ts +++ b/wrt_app/common/service_runner.ts @@ -17,12 +17,14 @@ function isGlobalService() { return global['serviceType'] === 'GLOBAL'; } function printAppControlData(id: string) { - var reqAppControl = global.tizen.application.getCurrentApplication().getRequestedAppControl(); - var appControlData = reqAppControl.appControl.data; - console.log(`id: ${id}, appControlData operation: ${reqAppControl.appControl.operation}`); - for (var dataIndex in appControlData) { - for (var valueIndex in appControlData[dataIndex].value) - console.log(`data[${dataIndex}][${valueIndex}]: ${appControlData[dataIndex].value[valueIndex]}`); + let reqAppControl = global.tizen.application.getCurrentApplication().getRequestedAppControl(); + if (reqAppControl) { + console.log(`id: ${id}, appControlData operation: ${reqAppControl.appControl.operation}`); + let appControlData = reqAppControl.appControl.data; + for (let dataIndex in appControlData) { + for (let valueIndex in appControlData[dataIndex].value) + console.log(`data[${dataIndex}][${valueIndex}]: ${appControlData[dataIndex].value[valueIndex]}`); + } } } -- 2.7.4 From 957df0f518550850d777b644581b5c4d9956305a Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 6 Jan 2021 14:35:30 +0900 Subject: [PATCH 11/16] Refactors initDisplayDelay function for readability Segregates two parts according to 'firstLaunch'. If first launch, - handle splash screen (place out of 'initDisplayDelay()') - add delay show event If not first launch - enable window Change-Id: Ic8104bc683bf3785581c4c3e6582d3fe738bed89 Signed-off-by: DongHyun Song --- wrt_app/src/web_application.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index a48dfa2..e6cc16c 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -70,7 +70,7 @@ export class WebApplication { this.setupEventListener(options); this.mainWindow = new WRTWindow(this.getWindowOption(options)); - this.initDisplayDelay(true); + this.initDisplayDelay(); this.setupMainWindowEventListener(); } @@ -290,26 +290,28 @@ export class WebApplication { }); } - private initDisplayDelay(firstLaunch: boolean) { - // TODO: On 6.0, this causes a black screen on relaunch - if (firstLaunch) - this.firstRendered = false; + private enableWindow() { this.suspended = false; + // TODO: On 6.0, this causes a black screen on relaunch if (this.showTimer) clearTimeout(this.showTimer); - let splashShown = this.preloadStatus !== 'preload' && firstLaunch && wrt.showSplashScreen(); - if (!splashShown && !wrt.tv) { - this.showTimer = setTimeout(() => { - if (!this.suspended) { - console.log('FrameRendered not obtained from engine. To show window, timer fired'); - this.mainWindow.emit('ready-to-show'); - } - }, 2000); - } - if (!firstLaunch && !this.backgroundRunnable()) + if (!this.backgroundRunnable()) this.mainWindow.setEnabled(true); } + private initDisplayDelay() { + let splashShown = this.preloadStatus !== 'preload' && wrt.showSplashScreen(); + if (splashShown || wrt.tv) + return; + + this.showTimer = setTimeout(() => { + if (!this.suspended) { + console.log('FrameRendered not obtained from engine. To show window, timer fired'); + this.mainWindow.emit('ready-to-show'); + } + }, 2000); + } + private backgroundRunnable(): boolean { return this.backgroundSupport || this.backgroundExecution; } @@ -489,7 +491,7 @@ Then you can get profile log from the initial loading.`; private handleAppControlReload(url: string) { console.log('WebApplication : handleAppControlReload'); this.closeWindows(); - this.initDisplayDelay(false); + this.enableWindow(); this.mainWindow.loadURL(url); } -- 2.7.4 From c6e40415c63ae8d007e979255e0aeb0205aa2514 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Fri, 22 Jan 2021 12:33:36 +0900 Subject: [PATCH 12/16] Don't use rpm command in spec file The use of rpm command will block OBS build process. This replace it with cat command to read chromium-efl version. Change-Id: I30e738eeb69a4d205fab5b9f73ac2f66b77d165e Signed-off-by: Youngsoo Choi --- packaging/wrtjs.spec | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packaging/wrtjs.spec b/packaging/wrtjs.spec index 842226c..f962ec8 100755 --- a/packaging/wrtjs.spec +++ b/packaging/wrtjs.spec @@ -130,6 +130,8 @@ install -d %{buildroot}%{_datadir}/aul install -d %{buildroot}%{_resourcedir} install -d %{buildroot}%{WRTJS_APP_DIR} +mkdir -p %{buildroot}%{_datadir}/wrtjs +echo %{version} > %{buildroot}%{_datadir}/wrtjs/version %if 0%{?_use_tpk} %if 0%{?__package_signing} install -m 0644 tizen/downloadable/vd_sign/author-signature.xml %{buildroot}%{WRTJS_APP_DIR} @@ -186,19 +188,13 @@ cp -r %{app_dir}/* %{buildroot}%{_resourcedir}/ %endif %pre -if (( $(rpm -q chromium-efl | wc -l) > 1 )); then - echo -e "\033[31m*****************************************************" - echo -e "Please remove chromium-efl rpm(s) except for one:\n" - rpm -q chromium-efl - echo -e "*****************************************************\033[m" - exit 1 -fi - -export CHROMIUM_REVISION=$(rpm -q chromium-efl | awk -F. '{print $2}') -export WRTJS_REVISION=$(echo %{version} | awk -F. '{print $2}') -if [[ "${CHROMIUM_REVISION}" == "" ]]; then +export CHROMIUM_REVISION= +if [ -f "%{_datadir}/chromium-efl/version" ]; then + CHROMIUM_REVISION=$(cat %{_datadir}/chromium-efl/version | awk -F. '{print $2}') +else CHROMIUM_REVISION="not installed" fi +export WRTJS_REVISION=$(echo %{version} | awk -F. '{print $2}') echo -e "\033[32m*****************************************************" echo -e "* chromium-efl revision : ${CHROMIUM_REVISION}" @@ -243,6 +239,7 @@ rm -fr %{buildroot} %if "%{_vd_cfg_product_type}" != "LFD" %{_datadir}/aul/wrt.loader %endif +%{_datadir}/wrtjs/version %{_libdir}/%{crosswalk_extensions_service}/plugins.json %{_resourcedir}/* %if 0%{?__package_signing} -- 2.7.4 From 51a7882ab7ea3f5fedc35e0f1ec4267f854509a5 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 12 Nov 2020 17:17:18 +0900 Subject: [PATCH 13/16] [Service][Builtin] Introduce Appmanifest installer This built-in service introduces to support W3C AppManifest installation, which is written JSON manifest file. The overall goal of this feature is that 1) Convert JSON manifest to config.xml - download proper icon 2) Archive .wgt and request to install .wgt - tizen.archive is newly necessary to load To support installation of archived wgt file from this feature, there are 2 consideration to be solved. a) there is no signature file b) at least, public level certification is necessary Change-Id: Iaf09bdfb3e6c5d6e8471ef91ea13fda863641db0 Signed-off-by: DongHyun Song --- packaging/plugins.json | 5 + wrt_app/common/service_manager.ts | 1 + wrt_app/service/builtins/appmanifest_loader.ts | 203 +++++++++++++++++++++++++ wrt_app/service/builtins/wasm_builder.ts | 16 +- 4 files changed, 217 insertions(+), 8 deletions(-) create mode 100644 wrt_app/service/builtins/appmanifest_loader.ts diff --git a/packaging/plugins.json b/packaging/plugins.json index 7838bf7..ed9a833 100644 --- a/packaging/plugins.json +++ b/packaging/plugins.json @@ -79,5 +79,10 @@ "name":"tizen.notification", "lib":"/usr/lib/tizen-extensions-crosswalk/libtizen_notification.so", "entry_points": ["tizen.StatusNotification","tizen.UserNotification", "tizen.NotificationDetailInfo"] + }, + { + "name":"tizen.archive", + "lib":"/usr/lib/tizen-extensions-crosswalk/libtizen_archive.so", + "entry_points": [] } ] diff --git a/wrt_app/common/service_manager.ts b/wrt_app/common/service_manager.ts index face443..544aec7 100644 --- a/wrt_app/common/service_manager.ts +++ b/wrt_app/common/service_manager.ts @@ -60,6 +60,7 @@ export function handleBuiltinService(serviceId: string, serviceName: string) { } let need_stop = (serviceName.substr(0, 5) === 'stop_'); if (need_stop) { + console.log(`${serviceName} will be terminated.`); workers[serviceId].terminate(); } else { console.log(`Builtin service is ${serviceName}`); diff --git a/wrt_app/service/builtins/appmanifest_loader.ts b/wrt_app/service/builtins/appmanifest_loader.ts new file mode 100644 index 0000000..2c8597b --- /dev/null +++ b/wrt_app/service/builtins/appmanifest_loader.ts @@ -0,0 +1,203 @@ +import '../../common/init'; +import { isMainThread, workerData } from 'worker_threads'; +import { wrt } from '../../browser/wrt'; +import * as fs from 'fs'; +import * as https from 'https'; +import * as XWalkExtension from '../../common/wrt_xwalk_extension'; + +function getManifestFile(manifestUrl: string) { + console.log('manifestUrl : '+manifestUrl); + return new Promise((resolve, reject) => { + const req = https.request(manifestUrl, (res) => { + res.setEncoding('utf8'); + let responseBody = ''; + res.on('data', (data) => { + responseBody += data; + }); + res.on('end', () => { + resolve(JSON.parse(responseBody)); + }); + }).on('error', (err) => { + console.log(`error : ${err}`); + reject(err); + }); + req.end(); + }); +} + +async function downloadIcon(iconSrc: string, iconFile: string) { + console.log('iconSrc : ' + iconSrc); + return new Promise((resolve, reject) => { + const req = https.request(iconSrc, (res) => { + const Stream = require('stream').Transform; + let data = new Stream(); + res.on('data', (chunk) => { + data.push(chunk); + }); + res.on('end', () => { + fs.writeFileSync(iconFile, data.read()); + resolve('done'); + }); + }).on('error', (err) => { + console.log(`error : ${err}`); + reject(err); + }); + req.end(); + }); +} + +function copyManifest(filePath: string, manifestData: string) { + fs.writeFileSync(filePath, manifestData); +} + +function concatWithBaseUrl(url: string, baseUrl: string) { + if (url.indexOf('http:') == -1 && url.indexOf('https:') == -1) { + return baseUrl.substr(0, baseUrl.lastIndexOf('/') + 1) + url; + } + return url; +} + +let baseWorkingDir = '/home/owner/content/Downloads/AppManifest'; +let downloadVirtualDir = 'downloads/AppManifest'; +let iconFile: string = ''; +let iconName: string = ''; +let manifestFile: string = ''; +let convertedConfigXml: string = ''; +let refCount: number = 0; + +function getAppName(appName: string) { + appName = appName.replace(/ /g, ''); + console.log('appName : ' + appName); + return appName; +} + +function makeWorkingFolder(appName: string) { + let workingDir = `${baseWorkingDir}/${appName}`; + fs.rmdirSync(workingDir, { recursive: true }); + fs.mkdir(workingDir, { recursive: true }, (err) => { + if (err) + console.log(`mkdir error : ${err}`) + }); +} + +async function handleIcon(appName: string, manifestUrl: string, manifest: any) { + let lengthOfIcons = manifest['icons'].length; + let lastIcon = manifest['icons'][lengthOfIcons - 1]; + let iconSrc = concatWithBaseUrl(lastIcon['src'], manifestUrl); + iconName = iconSrc.substr(iconSrc.lastIndexOf('/') + 1); + iconFile = `${baseWorkingDir}/${appName}/${iconName}`; + await downloadIcon(iconSrc, iconFile); + iconFile = `${downloadVirtualDir}/${appName}/${iconName}`; + refCount++; +} + +function handleStartUrl(appName: string, manifestUrl: string, manifest: any) { + let startUrl = concatWithBaseUrl(manifest['start_url'], manifestUrl); + manifest['start_url'] = startUrl; + manifestFile = `${baseWorkingDir}/${appName}/appmanifest.json`; + copyManifest(manifestFile, JSON.stringify(manifest)); + manifestFile = `${downloadVirtualDir}/${appName}/appmanifest.json`; + refCount++; + return startUrl; +} + +function makeRandomId() { + return Math.random().toString(36).substring(2, 12); +} + +function convertConfigXml(appName: string, startUrl: string) { + convertedConfigXml = `${baseWorkingDir}/${appName}/config.xml`; + let id = makeRandomId(); + let configXml = ``; + configXml += ``; + configXml += ``; + configXml += `` + configXml += ``; + configXml += `${appName}`; + configXml += ``; + configXml += ``; + copyManifest(convertedConfigXml, configXml); + convertedConfigXml = `${downloadVirtualDir}/${appName}/config.xml`; + refCount++; +} + +function cleanUpAndQuit(appName: string) { + let workingDir = `${baseWorkingDir}/${appName}`; + fs.rmdirSync(workingDir, { recursive: true }); + process.exit(); +} + +function installWgt(appName: string) { + let onInstallation = { + onprogress: (packageId: string, percentage: string) => { + console.log("On installation(" + packageId + ") : progress(" + percentage + ")"); + }, + oncomplete: (packageId: string) => { + console.log("Installation(" + packageId + ") Complete"); + wrt.postPlainNotification(appName, 'Install Success', 5); + cleanUpAndQuit(appName); + } + }; + let wgtPath = `${baseWorkingDir}/${appName}/${appName}.wgt`; + console.log(`wgtPath: ${wgtPath}`); + global.tizen.package.install(wgtPath, onInstallation, (err: any) => { + console.log("Error occurred on installation : " + err.name); + cleanUpAndQuit(appName); + }); +} + +function makeWgt(appName: string) { + let wgtPath = `${downloadVirtualDir}/${appName}/${appName}.wgt`; + let onArchive = (archive: any) => { + function progressCallback(opId: string, val: number, name: any) { + console.log('opId: ' + opId + ' with progress val: ' + (val * 100).toFixed(0) + '%'); + } + function successCallback() { + console.log(`File added : ${refCount}`); + refCount--; + if (!refCount) { + installWgt(appName); + } + } + console.log(`convertedConfigXml : ${convertedConfigXml}`); + console.log(`manifestFile : ${manifestFile}`); + console.log(`iconFile : ${iconFile}`); + let defaultArchiveFileEntryOption = { destination:'', stripSourceDirectory: true}; + archive.add(convertedConfigXml, successCallback, null, progressCallback, defaultArchiveFileEntryOption); + archive.add(manifestFile, successCallback, null, progressCallback, defaultArchiveFileEntryOption); + if (iconFile) + archive.add(iconFile, successCallback, null, progressCallback, defaultArchiveFileEntryOption); + } + global.tizen.archive.open(wgtPath, 'w', onArchive, () => { }, { overwrite: true }); +} + +async function parseAndHandleManifest(manifestUrl: string) { + let manifest: any = await getManifestFile(manifestUrl); + let appName = getAppName(manifest['name']); + try { + makeWorkingFolder(appName); + if (manifest['icons']) { + await handleIcon(appName, manifestUrl, manifest); + } + if (manifest['start_url']) { + let startUrl = handleStartUrl(appName, manifestUrl, manifest); + convertConfigXml(appName, startUrl); + } + makeWgt(appName); + } catch (e) { + console.log(`Exception: ${e}`); + cleanUpAndQuit(appName); + } +} + +export function run(manifestUrl: string) { + console.log(`Appmanifest parser starts for ${manifestUrl}`); + setInterval(() => { }, 500); + wrt.tv?.delayShutdown(); + XWalkExtension.initialize(); + parseAndHandleManifest(manifestUrl); +} + +if (!isMainThread) { + run(decodeURIComponent(workerData.id)); +} diff --git a/wrt_app/service/builtins/wasm_builder.ts b/wrt_app/service/builtins/wasm_builder.ts index 54177d0..e23ac17 100644 --- a/wrt_app/service/builtins/wasm_builder.ts +++ b/wrt_app/service/builtins/wasm_builder.ts @@ -1,13 +1,13 @@ import '../../common/init'; -import { isMainThread, parentPort, workerData } from 'worker_threads'; +import { isMainThread, workerData } from 'worker_threads'; import { wrt } from '../../browser/wrt'; import * as fs from 'fs'; function compileWasmForCaching(files: string[]) { try { - files.forEach(async file_path => { - console.log(`Requesting WASM compilation for building a cache, file_path:(${file_path})`); - let source = fs.readFileSync(file_path); + files.forEach(async filePath => { + console.log(`Requesting WASM compilation for building a cache, file_path:(${filePath})`); + let source = fs.readFileSync(filePath); let file = new Uint8Array(source); await WebAssembly.compile(file); }); @@ -16,12 +16,12 @@ function compileWasmForCaching(files: string[]) { } } -export function run(app_id: string) { - console.log(`wasm_builder.js starts, app_id:(${app_id})`); +export function run(appId: string) { + console.log(`wasm_builder.js starts, app_id:(${appId})`); let tv = wrt.tv as NativeWRTjs.TVExtension; tv.setWasmFlags(); - tv.setDiskCache(app_id); - let files = tv.getWasmFiles(app_id); + tv.setDiskCache(appId); + let files = tv.getWasmFiles(appId); console.log(files); tv.delayShutdown(); compileWasmForCaching(files); -- 2.7.4 From 81b700da16e52295da22da13b22568384313044e Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Thu, 28 Jan 2021 11:51:40 +0900 Subject: [PATCH 14/16] [M85][MDE] Support MDE interfaces This supports MDE interfaces. Reference: https://review.tizen.org/gerrit/248308 Together with: https://review.tizen.org/gerrit/252383 Change-Id: Ifa6f5d96606979918d4b134abcd48405e5e4654b Signed-off-by: Youngsoo Choi --- wrt_app/service/device_api_router.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 735eb57..9e2495b 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -64,9 +64,38 @@ export class DeviceAPIRouter { getServiceId: { writable: false, enumerable: true }, postPlainNotification: { writable: false, enumerable: true }, }); + this.initMDEWebapis(); this.initProductWebapis(); } + initMDEWebapis() { + if (wrt['mde'] && !global.webapis.mde) { + let mde = wrt.mde as NativeWRTjs.MDEExtension; + global.webapis.mde = {}; + if (wrt.tv) { + global.webapis.mde.deInitVirtualEventGenerator = (type: number) => { + return mde.deInitVirtualEventGenerator(type); + } + global.webapis.mde.generateVirtualKeyEvent = (keycode: number, state: number) => { + return mde.generateVirtualKeyEvent(keycode, state); + } + global.webapis.mde.generateVirtualMouseButtonEvent = (button: number, status: number) => { + return mde.generateVirtualMouseButtonEvent(button, status); + } + global.webapis.mde.generateVirtualMouseMoveEvent = (x: number, y: number, move_count: number) => { + return mde.generateVirtualMouseMoveEvent(x, y, move_count); + } + global.webapis.mde.initVirtualEventGenerator = (type: number) => { + return mde.initVirtualEventGenerator(type); + } + } + global.webapis.mde.launchBrowserFromUrl = (url: string) => { + return mde.launchBrowserFromUrl(url); + } + Object.defineProperty(global.webapis, 'mde', { writable: false, enumerable: true }); + } + } + initProductWebapis() { // for TV profile if (wrt.tv && !global.webapis.productinfo) { -- 2.7.4 From 73bfef03506dee58ff00e5b2a116ba0662f4cc26 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Mon, 1 Feb 2021 11:21:48 +0900 Subject: [PATCH 15/16] Set DEFAULT_TIZEN_VERSION to 6.5 This sets DEFAULT_TIZEN_VERSION to 6.5 as per current tizen branch version. Change-Id: I9d5d20edef1a89f5865909bb5eff691c49f7b264 Signed-off-by: Youngsoo Choi --- tizen/build/common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tizen/build/common.sh b/tizen/build/common.sh index 98325fe..e2bcb49 100755 --- a/tizen/build/common.sh +++ b/tizen/build/common.sh @@ -4,7 +4,7 @@ export SCRIPTDIR=$(readlink -e $(dirname $0)) export TOPDIR=$(readlink -f "${SCRIPTDIR}/../..") export CHROME_SRC="${TOPDIR}" -export LATEST_TIZEN_VERSION=6.0 +export LATEST_TIZEN_VERSION=6.5 export DEFAULT_TIZEN_VERSION=$LATEST_TIZEN_VERSION if [ "$(echo "$@" | grep -e "--tizen")" != "" ]; then @@ -82,9 +82,13 @@ function setupAndExecuteTargetBuild() { if [ "$PROFILE" == "" ]; then if [[ $platform == "tv" ]]; then - PROFILE=tztv_${DEFAULT_TIZEN_VERSION}_arm-nikem + #TODO: Once 6.5 tv repo is ready, uncomment following line + #PROFILE=tztv_${DEFAULT_TIZEN_VERSION}_arm-nikem + PROFILE=tztv_6.0_arm-nikem elif [[ $platform == "da" ]]; then - PROFILE=tzda_${DEFAULT_TIZEN_VERSION}_arm-kantm + #TODO: Once 6.5 fhub repo is ready, uncomment following line + #PROFILE=tzda_${DEFAULT_TIZEN_VERSION}_arm-kantm + PROFILE=tzda_6.0_arm-kantm elif [[ $platform == "wearable" ]]; then PROFILE=tzwr_5.5_arm-spin else -- 2.7.4 From 8fdbbe55276275c63760ebc6bd48a830c1410e29 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Tue, 19 Jan 2021 11:53:31 +0900 Subject: [PATCH 16/16] [M85][Service] Drop thread privilege of service app This drops the privilege of service app and sets it to User::Pkg::{PKG_ID}. With this changes, the service app is under control of kernel smack rule. Reference: https://review.tizen.org/gerrit/249081 Together with: https://review.tizen.org/gerrit/251775 Change-Id: I0cd14f159b61b17dc395fd938144a0646529a2d9 Signed-off-by: Youngsoo Choi --- wrt_app/service/access_control_manager.ts | 4 +++- wrt_app/service/device_api_router.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wrt_app/service/access_control_manager.ts b/wrt_app/service/access_control_manager.ts index 87afb7a..b3d804c 100644 --- a/wrt_app/service/access_control_manager.ts +++ b/wrt_app/service/access_control_manager.ts @@ -1,3 +1,4 @@ +import { wrt } from '../browser/wrt'; function checkSystemInfoApiPrivilege(func: any, permissions: string[]) { let override_func = func; @@ -10,7 +11,8 @@ function checkSystemInfoApiPrivilege(func: any, permissions: string[]) { } } -export function initialize(permissions: string[]) { +export function initialize(packageId: string, appId: string, permissions: string[]) { + wrt.security?.dropThreadPrivilege(packageId, appId); let tizen = global.tizen; if (!permissions.includes("http://tizen.org/privilege/alarm")) { tizen.alarm.add = diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 9e2495b..c083c11 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -154,7 +154,7 @@ export class DeviceAPIRouter { initAccessControlManager() { console.log(`permissions : ${this.permissions}`); const AccessControlManager = require('./access_control_manager'); - AccessControlManager.initialize(this.permissions); + AccessControlManager.initialize(this.packageId, this.serviceId, this.permissions); } getServiceId() { -- 2.7.4