From db7f5e64147a9b0881f00757db512681b0be73d5 Mon Sep 17 00:00:00 2001 From: SangYong Park Date: Sat, 21 Sep 2019 01:33:18 +0900 Subject: [PATCH] [Service][UI] Add startService handler This adds startService handler. Change-Id: I9008245b9affee2faf7b04d767755445852b84ad Signed-off-by: SangYong Park --- wrt_app/src/runtime.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index bc07eb9..2fb132b 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -176,6 +176,22 @@ class Runtime { if (_this.webApplication) _this.webApplication.lowMemory(); }); + wrt.on('message', function(event, type, params) { + console.log('message type(' + type + ') params : ' + params); + if (type === 'startService') { + const vm = require('vm'); + const fs = require('fs'); + let sandbox = { + console: console, + module: module, + require: require, + }; + let options = {}; + let code = fs.readFileSync(params[1]); + vm.runInNewContext(code, sandbox, options); + event.preventDefault(); + } + }); wrt.on('wgt-installed', function(event, path) { console.log('wgt-installed at ' + path); if (AddonManager.isAddon(path)) { -- 2.7.4