From 4602d90a1c273e4ced1991e2b869d1b43f35a9ed Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Wed, 29 Jul 2020 19:35:16 -0700 Subject: [PATCH] [Service] Expose app id related APIs to public and add getCallerAppId This exposes getServiceId and getPackageId APIs to puglic profile. Also, this newly adds getCallerAppId for the use of service apps. For instance, it can be used when a service app wants to make a messageport connection with a caller web app. If there's no caller app, it returns ''. Change-Id: Icfe221cb23acfb3587b38bd75fdce28ea5d2a23e Signed-off-by: Youngsoo Choi --- wrt_app/common/service_manager.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wrt_app/common/service_manager.ts b/wrt_app/common/service_manager.ts index a4222ab..330e441 100644 --- a/wrt_app/common/service_manager.ts +++ b/wrt_app/common/service_manager.ts @@ -47,12 +47,17 @@ export function startService(id: string, filename?: string) { module: new Module, require: require, tizen: global.tizen, + webapis: wrt.tv ? global.webapis : global.webapis = {}, }; sandbox[id].module.exports.onStop = () => { callFunctionInContext('module.exports.onExit', id); }; - let service_id = id.split(':')[0]; - sandbox[id].webapis = wrt.tv ? global.webapis : {}; + let ids = id.split(':'); + let caller_app_id = ids[1] ?? ''; + sandbox[id].webapis.getCallerAppId = () => { + return caller_app_id; + } + let service_id = ids[0]; sandbox[id].webapis.getServiceId = () => { return service_id; } @@ -60,7 +65,7 @@ export function startService(id: string, filename?: string) { let app_info = global.tizen.application.getAppInfo(service_id); if (app_info) return app_info.packageId; - return ''; + return ids[0].split('.')[0]; } if (service_type !== 'UI') { -- 2.7.4