From c2753a44fff106045381515c3ae9150cdaf35bd8 Mon Sep 17 00:00:00 2001 From: Youngsoo Choi Date: Thu, 23 Jul 2020 03:45:34 -0700 Subject: [PATCH] fixup! [Service] Routing API - tizen.application This resovles folloinwg error on public target: TypeError: Cannot read property 'getServiceId' of undefined The public profile has the webapis in sandbox, not in global. Change-Id: I99a2eb4ff373bf8103c0ef9e6392f96e7f6ffb09 Signed-off-by: Youngsoo Choi --- wrt_app/common/service_manager.ts | 2 +- wrt_app/service/device_api_router.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wrt_app/common/service_manager.ts b/wrt_app/common/service_manager.ts index d414bbd..a4222ab 100644 --- a/wrt_app/common/service_manager.ts +++ b/wrt_app/common/service_manager.ts @@ -111,7 +111,7 @@ export function startService(id: string, filename?: string) { } code = `const app = require('${filename}')`; if (service_type === 'DAEMON') { - internal_handler[id].deivce_api_router = new DeviceAPIRouter(); + internal_handler[id].deivce_api_router = new DeviceAPIRouter(sandbox[id]); } vm.runInNewContext(code, sandbox[id], options); } diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index f040e4c..a64c549 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -2,6 +2,7 @@ import { wrt } from '../browser/wrt'; export class DeviceAPIRouter { currentApplication: any; + sandbox: any; funcCurrentApplication: any; funcRequestedAppcontrol: any; funcGetAppInfo: any; @@ -11,18 +12,19 @@ export class DeviceAPIRouter { funcGetPackageInfo: any; funcPathResolve: any; - constructor() { + constructor(sandbox: any) { + this.sandbox = sandbox; this.RefineApplicationApis(); this.RefinePackageApis(); this.RefineFilesystemApis() } GetServiceId() { - return global.webapis.getServiceId(); + return this.sandbox.webapis.getServiceId(); } GetPackageId() { - return global.webapis.getPackageId(); + return this.sandbox.webapis.getPackageId(); } RefineApplicationApis() { @@ -99,4 +101,4 @@ export class DeviceAPIRouter { this.funcPathResolve(location, onSuccess, onError, mode ?? 'rw'); } } -} \ No newline at end of file +} -- 2.7.4