From 10091806a8ac996bc35453fa41d152cd4e52facc Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 12 Aug 2021 14:29:40 +0900 Subject: [PATCH] [Service] Relay message-port via launcher When service app makes local message-port, the message-port is managed with 'app_id' + 'port_name'. But, because 'app_id' is 'org.tizen.chromium-efl.wrt.service' by AUL API, external app cannot send the message due to not-found port. This patch will create message-port listener with proper 'app_id' on launcher process to relay messages. Related chromium-efl patch: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/262496/ Change-Id: I3387b2d4d8c0ce5fb376bfcde375f34aed9538b6 Signed-off-by: DongHyun Song --- wrt_app/service/access_control_manager.ts | 3 +-- wrt_app/service/device_api_router.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/wrt_app/service/access_control_manager.ts b/wrt_app/service/access_control_manager.ts index e95f6dc..5fad4b2 100644 --- a/wrt_app/service/access_control_manager.ts +++ b/wrt_app/service/access_control_manager.ts @@ -41,8 +41,7 @@ export function initialize(packageId: string, appId: string, permissions: string } if (!permissions.includes("http://tizen.org/privilege/application.launch") && !permissions.includes("http://tizen.org/privilege/appmanager.launch")) { - tizen.application.launch = - tizen.application.launchAppControl = function() { + tizen.application.launch = function() { console.log('The application.launch and appmanager.launch permission is missing.'); } } diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 2c9c051..5fe116b 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -10,6 +10,8 @@ export class DeviceAPIRouter { funcGetSharedUri: any; funcGetMetadata: any; funcGetPackageInfo: any; + funcRequestLocalMessagePort: any; + funcRequestTrustedLocalMessagePort: any; id: string; serviceId: string; @@ -34,6 +36,7 @@ export class DeviceAPIRouter { this.refineApplicationApis(); this.refinePackageApis(); this.refineFilesystemApis() + this.refineMessagePortApis() this.initAccessControlManager(); this.refineXwalkUtilApis(); } @@ -329,4 +332,32 @@ export class DeviceAPIRouter { return this.pkgApiVersion; } } + + refineMessagePortApis() { + this.funcRequestLocalMessagePort = + global.tizen.messageport.requestLocalMessagePort; + this.funcRequestTrustedLocalMessagePort = + global.tizen.messageport.requestTrustedLocalMessagePort; + + const registerMessagePort = (name: string, portName: string) => { + let data_payload = [ + new global.tizen.ApplicationControlData(name, [ portName ]), + + ]; + let appControl = new global.tizen.ApplicationControl( + "http://tizen.org/appcontrol/operation/default", null, null, null, + data_payload, null); + global.tizen.application.launchAppControl(appControl, this.serviceId, + () => console.log(`'${this.serviceId}::${name}' is requsted`)); + } + + global.tizen.messageport.requestLocalMessagePort = (portName: string) => { + registerMessagePort('requestLocalMessagePort', portName); + return this.funcRequestLocalMessagePort(portName); + } + global.tizen.messageport.requestTrustedLocalMessagePort = (portName: string) => { + registerMessagePort('requestTrustedLocalMessagePort', portName); + return this.funcRequestLocalMessagePort(portName); + } + } } -- 2.7.4