[DeviceHome][VD] Add 'action' parameter for deeplink 12/274112/2 submit/tizen/20220426.160022
authorDongHyun Song <dh81.song@samsung.com>
Thu, 21 Apr 2022 11:06:18 +0000 (20:06 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Tue, 26 Apr 2022 00:44:47 +0000 (09:44 +0900)
If there is 'action' parameter, then, it will be a 'PAYLOAD' data
for deeplink.

Change-Id: Ic7f3414364945f0a46b2e74274924cfcdc8a9b31
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
device_home/client/js/actions.js [changed mode: 0755->0644]
device_home/service/app_proxy.js [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index fdcb1c5..1ff3f9a
@@ -11,18 +11,13 @@ class Actions {
      * @returns {Function}
      */
 
-    launchAppOnTV(pkgId, appId, callback) {
-        const xhr = new XMLHttpRequest();
-
-        var self = this;
-        var retFunc = function() {
-            var data = {
-                pkgId: pkgId,
-                appId: appId
-            };
-            self.sendDataToApp(pkgId, appId, data, callback);
+    launchAppOnTV(pkgId, appId, action, callback) {
+        var data = {
+            pkgId,
+            appId,
+            action
         };
-        return retFunc;
+        return this.sendDataToApp('app', data, callback);
     };
 
     /**
@@ -32,12 +27,8 @@ class Actions {
      * @param {Object} data
      * @param {Function} callback
      */
-    sendDataToApp(pkgId, appId, data, callback) {
+    sendDataToApp(api, data, callback) {
         const xhr = new XMLHttpRequest();
-        // add tv app id
-        data.appId = appId;
-        data.pkgId = pkgId;
-
         xhr.onreadystatechange = function() {
             if (xhr.readyState === xhr.DONE) {
                 if (xhr.status === 200 || xhr.status === 201) {
@@ -50,7 +41,7 @@ class Actions {
                 }
             }
         }
-        xhr.open('POST', serverURL + ':' + serverPort + '/app');
+        xhr.open('POST', `${serverURL}:${serverPort}/${api}`);
         xhr.setRequestHeader('Content-Type', 'application/json');
         xhr.send(JSON.stringify(data));
     };
old mode 100755 (executable)
new mode 100644 (file)
index 1cd814c..d71fca1
@@ -6,7 +6,7 @@ var appRouters = [];
 var path = null;
 var currentD2DAppId = null;
 
-function runApp(appId, port, callback) {
+function runApp(appId, port, action, callback) {
     function onRunningAppsContext(contexts) {
         var isRunning = false;
         for (var i = 0; i < contexts.length; i++) {
@@ -16,22 +16,35 @@ function runApp(appId, port, callback) {
             }
         }
 
-        if (isRunning && currentD2DAppId === appId) {
+        if (isRunning && currentD2DAppId === appId && !action) {
             callback();
         } else {
             const urlParam = require('./service').getUrlParam();
             const urlObj = url.parse(urlParam, true).query;
             urlObj.target = is_tv ? 'tv' : 'fhub';
-            const appControl = new tizen.ApplicationControl(
-                "http://tizen.org/appcontrol/operation/default", null, null, null,
-                [new tizen.ApplicationControlData(
-                    "http://tizen.org/appcontrol/data/launch_port", [port]
-                ),
-                new tizen.ApplicationControlData(
-                    "http://tizen.org/appcontrol/data/url_parameter", [JSON.stringify(urlObj)]
-                )]
-            );
-
+            var appControl;
+            if (action) {
+                console.log('action : ' + JSON.stringify(action));
+                appControl = new tizen.ApplicationControl(
+                    "http://tizen.org/appcontrol/operation/eden_resume", null, null, null,
+                    [new tizen.ApplicationControlData(
+                        "PAYLOAD", [JSON.stringify({ values: action }) ]
+                    ),
+                    new tizen.ApplicationControlData(
+                        "SkipReload", ['No']
+                    )]
+                );
+            } else {
+                appControl = new tizen.ApplicationControl(
+                    "http://tizen.org/appcontrol/operation/default", null, null, null,
+                    [new tizen.ApplicationControlData(
+                        "http://tizen.org/appcontrol/data/launch_port", [port]
+                    ),
+                    new tizen.ApplicationControlData(
+                        "http://tizen.org/appcontrol/data/url_parameter", [JSON.stringify(urlObj)]
+                    )]
+                );
+            }
             currentD2DAppId = appId;
             tizen.application.launchAppControl(appControl, appId, callback);
         }
@@ -56,6 +69,7 @@ module.exports = function (app, port) {
         path = req.body.pkgId ? req.body.pkgId : path;
         var appId = req.body.appId;
         var pkgId = req.body.pkgId;
+        var action = req.body.action;
         var name = appId.split(".")[1];
         var appRouter = appRouters.filter(function (router) {
             return router.path === path;
@@ -71,7 +85,7 @@ module.exports = function (app, port) {
             }
             console.log('[GlobalWebServer] appProxy.post ', path, action);
             // run app
-            runApp(appId, port, function () {
+            runApp(appId, port, action, function () {
                 res.send({ port: port });
             });
         }