Supports an ambient mode for watch applications 07/220607/10
authorjaekuk, lee <juku1999@samsung.com>
Fri, 20 Dec 2019 03:16:57 +0000 (12:16 +0900)
committerjaekuk lee <juku1999@samsung.com>
Tue, 24 Dec 2019 07:54:06 +0000 (07:54 +0000)
When wearable device enables the ambient mode,
watch application displayed on an idle screen can show a limited UI
to reduce power consumption.

Depends on: https://review.tizen.org/gerrit/220615

Change-Id: Iba2a8e0b922027973270d4df9f90ec721b34d893
Signed-off-by: jaekuk, lee <juku1999@samsung.com>
wrt_app/src/runtime.js [changed mode: 0644->0755]
wrt_app/src/web_application.js

old mode 100644 (file)
new mode 100755 (executable)
index c0a59ce..45b69b8
@@ -282,6 +282,15 @@ class Runtime {
                 event.preventDefault();
             }
         });
+        wrt.on('ambient-tick', function() {
+            if (_this.webApplication)
+                _this.webApplication.ambientTick();
+        });
+        wrt.on('ambient-changed', function(event, ambient_mode) {
+            console.log('ambient-changed , ambient_mode:' + ambient_mode);
+            if (_this.webApplication)
+                _this.webApplication.ambientChanged(ambient_mode);
+        });
         wrt.on('addon-installed', function(event, path) {
             console.log('addon-installed at ' + path);
             let dbInfo = AddonManager.checkAddon(path);
index 7680eae..725e88f 100755 (executable)
@@ -446,5 +446,30 @@ class WebApplication {
             });
         }
     }
+    ambientTick() {
+        const kAmbientTickEventScript =
+            '(function(){' +
+            'var __event = document.createEvent(\"CustomEvent\");' +
+            '__event.initCustomEvent(\"timetick\", true, true);' +
+            'document.dispatchEvent(__event);' +
+            'for (var i=0; i < window.frames.length; i++)' +
+            '{ window.frames[i].document.dispatchEvent(__event); }' +
+            '})()';
+        wrt.executeJS(this.mainWindow.webContents, kAmbientTickEventScript);
+    }
+    ambientChanged(ambient_mode) {
+        const kAmbientChangedEventScript =
+            '(function(){' +
+            'var __event = document.createEvent(\"CustomEvent\");' +
+            'var __detail = {};' +
+            '__event.initCustomEvent(\"ambientmodechanged\",true,true,__detail);' +
+            '__event.detail.ambientMode = ' +
+            (ambient_mode ? 'true' : 'false') + ';' +
+            'document.dispatchEvent(__event);' +
+            'for (var i=0; i < window.frames.length; i++)' +
+            '{ window.frames[i].document.dispatchEvent(__event); }' +
+            '})()';
+        wrt.executeJS(this.mainWindow.webContents, kAmbientChangedEventScript);
+    }
 }
 module.exports = WebApplication;