From: DongHyun Song Date: Fri, 3 Sep 2021 09:10:40 +0000 (+0900) Subject: [Service] Fix DeviceApiRouter with "new Service" X-Git-Tag: submit/tizen/20210907.160018^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7bbe2ba6de7958cbddfa9ec422d825a8b3584d2;p=platform%2Fframework%2Fweb%2Fwrtjs.git [Service] Fix DeviceApiRouter with "new Service" 1) Fix JavaScript error from DeviceApiRouter in case of global service app created by "new Service". There are wrong usage with 'id', which should have set 'internelId', not 'serviceId'. 2) If there is an exception on onStart() or onRequest(), there is no change to call finishStartingService(). Thus, it moves finishStartingService on finally section. Change-Id: Ie5117cc098dc24826472e974a50692baa2a105ae Signed-off-by: DongHyun Song --- diff --git a/wrt_app/service/device_api_router.ts b/wrt_app/service/device_api_router.ts index 1c4f610a..98cbe038 100644 --- a/wrt_app/service/device_api_router.ts +++ b/wrt_app/service/device_api_router.ts @@ -25,7 +25,7 @@ export class DeviceAPIRouter { let ids = id.split(':'); this.serviceId = ids[0]; this.callerAppId = ids[1] ?? ''; - this.packageId = this.serviceId.split('.')[0]; + this.packageId = wrt.getPackageId(id); this.permissions = []; this.pkgApiVersion = ''; @@ -42,11 +42,6 @@ export class DeviceAPIRouter { } initWebapis() { - 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; @@ -307,7 +302,7 @@ export class DeviceAPIRouter { try { let virtualPath = ['wgt-private', 'wgt-private-tmp', 'wgt-package']; virtualPath.forEach(name => { - let realPath = wrt.resolveVirtualRoot(this.getServiceId(), name); + let realPath = wrt.resolveVirtualRoot(this.id, name); global.tizen.filesystem.setVirtualPath(name, realPath, 'INTERVAL', 'MOUNTED'); }); } catch (e) { diff --git a/wrt_app/service/service_runner.ts b/wrt_app/service/service_runner.ts index b4b3fe1d..e3cb9bd9 100644 --- a/wrt_app/service/service_runner.ts +++ b/wrt_app/service/service_runner.ts @@ -69,7 +69,7 @@ let checkLauncherAlive = (id: string) => { export function start(id: string, filename: string) { let ids = id.split(':'); let serviceId = ids[0]; - let packageId = wrt.getPackageId(serviceId); + let packageId = wrt.getPackageId(id); wrt.setServiceAppId(id); wrt.security?.dropThreadPrivilege(packageId, serviceId); @@ -106,12 +106,13 @@ export function start(id: string, filename: string) { if (app.onRequest !== undefined) { app.onRequest(); } - if (isGlobalService()) { - wrt.finishStartingService(id); - } } catch (e) { console.debug(`exception on start: ${e}`); requestStopService(id); + } finally { + if (isGlobalService()) { + wrt.finishStartingService(id); + } } }