[Service] Relay message-port via launcher 95/262495/4 submit/tizen/20210818.160021
authorDongHyun Song <dh81.song@samsung.com>
Thu, 12 Aug 2021 05:29:40 +0000 (14:29 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 13 Aug 2021 03:53:45 +0000 (12:53 +0900)
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 <dh81.song@samsung.com>
wrt_app/service/access_control_manager.ts
wrt_app/service/device_api_router.ts

index e95f6dc..5fad4b2 100644 (file)
@@ -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.');
     }
   }
index 2c9c051..5fe116b 100644 (file)
@@ -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);
+    }
+  }
 }