From 88beccdf6e56f7c26b7ccd5be4679fbb7cbb0db0 Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Thu, 21 Apr 2022 20:06:18 +0900 Subject: [PATCH] [DeviceHome][VD] Add 'action' parameter for deeplink If there is 'action' parameter, then, it will be a 'PAYLOAD' data for deeplink. Change-Id: Ic7f3414364945f0a46b2e74274924cfcdc8a9b31 Signed-off-by: DongHyun Song --- device_home/client/js/actions.js | 25 ++++++++----------------- device_home/service/app_proxy.js | 40 +++++++++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 30 deletions(-) mode change 100755 => 100644 device_home/client/js/actions.js mode change 100755 => 100644 device_home/service/app_proxy.js diff --git a/device_home/client/js/actions.js b/device_home/client/js/actions.js old mode 100755 new mode 100644 index fdcb1c5..1ff3f9a --- a/device_home/client/js/actions.js +++ b/device_home/client/js/actions.js @@ -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)); }; diff --git a/device_home/service/app_proxy.js b/device_home/service/app_proxy.js old mode 100755 new mode 100644 index 1cd814c..d71fca1 --- a/device_home/service/app_proxy.js +++ b/device_home/service/app_proxy.js @@ -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 }); }); } -- 2.7.4