*/
var _global = window || global || {};
-var _document = document || {};
-setTimeout(function () {
- var device = {
- cordova: 'dummy-cordova-version',
- model: 'dummy-model',
- platform: 'dummy-platform',
- uuid: 'dummy-uuid',
- version: 'dummy-os-version',
- };
- _global.device = device;
- _document.dispatchEvent(new Event('deviceready'));
-}, 1000);
+var device = {
+ cordova: cordova.version,
+ model: tizen.systeminfo.getCapability('http://tizen.org/system/model_name'),
+ platform: tizen.systeminfo.getCapability('http://tizen.org/system/platform.name'),
+ uuid: tizen.systeminfo.getCapability('http://tizen.org/system/tizenid'),
+ version: tizen.systeminfo.getCapability('http://tizen.org/feature/platform.version'),
+ manufacturer: tizen.systeminfo.getCapability('http://tizen.org/system/manufacturer') // not documented, but required by tests
+};
+
+Object.freeze(device);
+Object.defineProperty(_global, 'device', {
+ configurable: false,
+ enumerable: true,
+ writable: false,
+ value: device
+});
+
+
+// fire the listener only once
+// TODO: find a better way of launching the listener, allowing more 'deviceready'
+// listeners to be registered
+var listener = function (event) {
+ if ('addEventListener' === event.fun) {
+ cordova._broker.removeEventListener('deviceready', listener);
+ event.obj.dispatchEvent(new Event('deviceready'));
+ }
+};
+
+cordova._broker.addEventListener('deviceready', listener);
console.log('Loaded cordova.device API');