From 4e24cb72b87eefb58b7f7954324fc804cd68d278 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Thu, 9 Feb 2017 13:43:36 +0100 Subject: [PATCH 01/16] [Bluetooth] Private member initialized [Verification] TCT tests passed Change-Id: I1238a5955511f381afcdfb835c4627418679bdf7 Signed-off-by: Szymon Jastrzebski --- src/bluetooth/bluetooth_instance.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bluetooth/bluetooth_instance.cc b/src/bluetooth/bluetooth_instance.cc index 16a2f5a..322f45f 100755 --- a/src/bluetooth/bluetooth_instance.cc +++ b/src/bluetooth/bluetooth_instance.cc @@ -30,6 +30,7 @@ BluetoothInstance::BluetoothInstance() : bluetooth_adapter_(*this), bluetooth_device_(bluetooth_adapter_), bluetooth_health_application_(bluetooth_health_profile_handler_), + bluetooth_health_channel_(), bluetooth_health_profile_handler_(*this), bluetooth_service_handler_(bluetooth_adapter_), bluetooth_socket_(bluetooth_adapter_), -- 2.7.4 From bfb1e6cb00eb73dd9de1ef96f42b16a4a6ca604f Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Mon, 13 Feb 2017 12:26:27 +0100 Subject: [PATCH 02/16] [version] 1.73 Change-Id: Ia097923cbc7957619e95250fd0af7c1efd64a7e5 Signed-off-by: Lukasz Bardeli --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 04b188c..4c11b79 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.72 +Version: 1.73 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 6f186adc6ab5953f587db70e0399cafdd10cbb90 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Thu, 16 Feb 2017 12:59:45 +0100 Subject: [PATCH 03/16] [Bluetooth] Fixing initialization order Change-Id: I83a2b3b265dc69c203b98c7314501be5a2e23c3a Signed-off-by: Szymon Jastrzebski --- src/bluetooth/bluetooth_instance.cc | 2 +- src/bluetooth/bluetooth_instance.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bluetooth/bluetooth_instance.cc b/src/bluetooth/bluetooth_instance.cc index 322f45f..158555f 100755 --- a/src/bluetooth/bluetooth_instance.cc +++ b/src/bluetooth/bluetooth_instance.cc @@ -29,9 +29,9 @@ using namespace common; BluetoothInstance::BluetoothInstance() : bluetooth_adapter_(*this), bluetooth_device_(bluetooth_adapter_), - bluetooth_health_application_(bluetooth_health_profile_handler_), bluetooth_health_channel_(), bluetooth_health_profile_handler_(*this), + bluetooth_health_application_(bluetooth_health_profile_handler_), bluetooth_service_handler_(bluetooth_adapter_), bluetooth_socket_(bluetooth_adapter_), bluetooth_le_adapter_(*this), diff --git a/src/bluetooth/bluetooth_instance.h b/src/bluetooth/bluetooth_instance.h index daeabef..30bb4cf 100755 --- a/src/bluetooth/bluetooth_instance.h +++ b/src/bluetooth/bluetooth_instance.h @@ -50,9 +50,9 @@ class BluetoothInstance: public common::ParsedInstance { private: BluetoothAdapter bluetooth_adapter_; BluetoothDevice bluetooth_device_; - BluetoothHealthApplication bluetooth_health_application_; BluetoothHealthChannel bluetooth_health_channel_; BluetoothHealthProfileHandler bluetooth_health_profile_handler_; + BluetoothHealthApplication bluetooth_health_application_; BluetoothServiceHandler bluetooth_service_handler_; BluetoothSocket bluetooth_socket_; BluetoothLEAdapter bluetooth_le_adapter_; -- 2.7.4 From c3a9dfda3d7aa4c7dcb0f3a60ec6d6d9beb5def7 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 22 Feb 2017 08:09:45 +0100 Subject: [PATCH 04/16] [version] 1.74 Change-Id: I67ad8db60f5fd22287d700aeca8eb8316006e3b8 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 4c11b79..4be9038 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.73 +Version: 1.74 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From c62b44462e4ab5929b710854776fd4873b209d4f Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Mon, 27 Feb 2017 12:31:56 +0100 Subject: [PATCH 05/16] [Common] JS logs are turned off with debugging flag [Feature] console.log is disabled by default but can be easily enable with setting a flag to 'true' value. [Verification] Related TCTs result didn't change. Change-Id: If19acaf3a9e2cd8d33bbeb15118b5c6d72f75ac2 Signed-off-by: Piotr Kosko --- src/account/account_api.js | 3 +- src/alarm/alarm_api.js | 5 +- src/application/application_api.js | 7 +- src/archive/archive_api.js | 7 +- src/bluetooth/bluetooth_api.js | 108 ++++++++-------- src/callhistory/callhistory_api.js | 2 +- src/contact/js/contact.js | 4 +- src/content/js/datatypes.js | 2 +- src/convergence/convergence_api.js | 2 +- src/download/download_api.js | 7 +- src/filesystem/js/common.js | 4 +- src/filesystem/js/file.js | 2 +- .../humanactivitymonitor_api.js | 2 +- src/iotcon/iotcon_api.js | 9 +- src/messageport/messageport_api.js | 3 +- src/messaging/messaging_api.js | 3 +- src/nfc/nfc_api.js | 2 +- src/secureelement/secureelement_api.js | 6 +- src/systeminfo/systeminfo_api.js | 4 +- src/time/time_api.js | 144 ++++++++++----------- src/utils/utils_api.js | 8 ++ 21 files changed, 175 insertions(+), 159 deletions(-) diff --git a/src/account/account_api.js b/src/account/account_api.js index 8ea2311..3f9a31b 100755 --- a/src/account/account_api.js +++ b/src/account/account_api.js @@ -18,6 +18,7 @@ var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var T_ = xwalk.utils.type; var native_ = new xwalk.utils.NativeManager(extension); +var privUtils_ = xwalk.utils; function InternalValues_(data) { @@ -361,7 +362,7 @@ function AccountListeners() { break; default: - console.log('Unknown event: ' + event.action); + privUtils_.log('Unknown event: ' + event.action); break; } diff --git a/src/alarm/alarm_api.js b/src/alarm/alarm_api.js index 5db5edc..78f22ad 100755 --- a/src/alarm/alarm_api.js +++ b/src/alarm/alarm_api.js @@ -17,6 +17,7 @@ var T = xwalk.utils.type; var Converter = xwalk.utils.converter; var AV = xwalk.utils.validator; +var privUtils_ = xwalk.utils; var native = new xwalk.utils.NativeManager(extension); @@ -227,7 +228,7 @@ tizen.AlarmRelative.prototype.getRemainingSeconds = function () { }; function makeDateConst(obj) { - console.log('Enter MakeConst'); + privUtils_.log('Enter MakeConst'); obj.setDate = function() {}; obj.setFullYear = function() {}; obj.setHours = function() {}; @@ -244,7 +245,7 @@ function makeDateConst(obj) { obj.setUTCMonth = function() {}; obj.setUTCSeconds = function() {}; obj.setYear = function() {}; - console.log('Leave MakeConst'); + privUtils_.log('Leave MakeConst'); } //class AlarmAbsolute ////////////////////////////////////////////////// diff --git a/src/application/application_api.js b/src/application/application_api.js index 77805ef..b0d5774 100755 --- a/src/application/application_api.js +++ b/src/application/application_api.js @@ -17,6 +17,7 @@ var T = xwalk.utils.type; var Converter = xwalk.utils.converter; var AV = xwalk.utils.validator; +var privUtils_ = xwalk.utils; var native = new xwalk.utils.NativeManager(extension); @@ -517,7 +518,7 @@ ListenerManager.prototype.onListenerCalled = function(msg) { break; default: - console.logd('Unknown mode: ' + msg.action); + privUtils_.log('Unknown mode: ' + msg.action); return; } @@ -529,7 +530,7 @@ ListenerManager.prototype.onListenerCalled = function(msg) { }; ListenerManager.prototype.addListener = function(callback) { - console.log('ListenerManager.prototype.addListener'); + privUtils_.log('ListenerManager.prototype.addListener'); var id = this.nextId; if (!this.nativeSet) { this.native.addListener(this.listenerName, this.onListenerCalled.bind(this)); @@ -683,7 +684,7 @@ Application.prototype.addEventListener = function(event, callback) { var parsedName = eventName.split('.'); var eventInfo = {}; if (parsedName.length < 3) { - console.logd('Invalid event name returned' + eventName); + privUtils_.log('Invalid event name returned' + eventName); } for (var id in event_listeners_[eventName]) { if (event_listeners_[eventName].hasOwnProperty(id)) { diff --git a/src/archive/archive_api.js b/src/archive/archive_api.js index 4de31ab..f2fca29 100755 --- a/src/archive/archive_api.js +++ b/src/archive/archive_api.js @@ -17,6 +17,7 @@ var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var native_ = new xwalk.utils.NativeManager(extension); +var privUtils_ = xwalk.utils; function CommonFS() {}; @@ -37,7 +38,7 @@ function _initializeCache() { }; } } catch(e) { - console.log("Exception while getting widget paths was thrown: " + e); + privUtils_.log("Exception while getting widget paths was thrown: " + e); } } @@ -62,7 +63,7 @@ CommonFS.toRealPath = function(aPath) { } else { _fileRealPath = aPath; } - console.log("REAL PATH:" + _fileRealPath); + privUtils_.log("REAL PATH:" + _fileRealPath); if (_fileRealPath === "undefined" || _fileRealPath === "null") { throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); } @@ -110,7 +111,7 @@ var Property = { * } * * m.name = 'A brand new name'; - * console.log(m.name); // Name + * privUtils_.log(m.name); // Name */ function propertyFactory_(that, name, value, flags, options) { flags = flags || 0; diff --git a/src/bluetooth/bluetooth_api.js b/src/bluetooth/bluetooth_api.js index bebe73e..117ff30 100755 --- a/src/bluetooth/bluetooth_api.js +++ b/src/bluetooth/bluetooth_api.js @@ -413,7 +413,7 @@ var BluetoothClass = function(data) { }; var BluetoothClass_hasService = function() { - console.log('Entered BluetoothClass.hasService()'); + privUtils_.log('Entered BluetoothClass.hasService()'); privUtils_.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_GAP); var args = AV.validateMethod(arguments, [ @@ -458,7 +458,7 @@ function BluetoothSocketListeners() { callback(); } } else { - console.log('Received event for an unknown socket: ' + event.id); + privUtils_.log('Received event for an unknown socket: ' + event.id); } }; } @@ -497,7 +497,7 @@ var BluetoothSocket = function(data) { }; BluetoothSocket.prototype.writeData = function() { - console.log('Entered BluetoothSocket.writeData()'); + privUtils_.log('Entered BluetoothSocket.writeData()'); var args = AV.validateMethod(arguments, [ { @@ -522,7 +522,7 @@ BluetoothSocket.prototype.writeData = function() { }; BluetoothSocket.prototype.readData = function() { - console.log('Entered BluetoothSocket.readData()'); + privUtils_.log('Entered BluetoothSocket.readData()'); var callArgs = { id : this._id @@ -538,7 +538,7 @@ BluetoothSocket.prototype.readData = function() { }; BluetoothSocket.prototype.close = function() { - console.log('Entered BluetoothSocket.close()'); + privUtils_.log('Entered BluetoothSocket.close()'); if (_BLUETOOTH_SOCKET_STATE_CLOSED !== this.state) { var callArgs = { @@ -613,7 +613,7 @@ var BluetoothLEDevice = function(data) { }; BluetoothLEDevice.prototype.connect = function() { - console.log('Entered BluetoothLEDevice.connect()'); + privUtils_.log('Entered BluetoothLEDevice.connect()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -644,7 +644,7 @@ BluetoothLEDevice.prototype.connect = function() { }; BluetoothLEDevice.prototype.disconnect = function() { - console.log('Entered BluetoothLEDevice.disconnect()'); + privUtils_.log('Entered BluetoothLEDevice.disconnect()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -674,7 +674,7 @@ BluetoothLEDevice.prototype.disconnect = function() { }; BluetoothLEDevice.prototype.getService = function() { - console.log('Entered BluetoothLEDevice.getService()'); + privUtils_.log('Entered BluetoothLEDevice.getService()'); var args = AV.validateMethod(arguments, [ { name: 'uuid', @@ -696,7 +696,7 @@ BluetoothLEDevice.prototype.getService = function() { }; BluetoothLEDevice.prototype.getServiceAllUuids = function() { - console.log('Entered BluetoothLEDevice.getServiceAllUuids()'); + privUtils_.log('Entered BluetoothLEDevice.getServiceAllUuids()'); var callArgs = { address : this.address @@ -712,7 +712,7 @@ BluetoothLEDevice.prototype.getServiceAllUuids = function() { }; BluetoothLEDevice.prototype.addConnectStateChangeListener = function() { - console.log('Entered BluetoothLEDevice.addConnectStateChangeListener()'); + privUtils_.log('Entered BluetoothLEDevice.addConnectStateChangeListener()'); var args = AV.validateMethod(arguments, [ { name: 'listener', @@ -735,7 +735,7 @@ BluetoothLEDevice.prototype.addConnectStateChangeListener = function() { }; BluetoothLEDevice.prototype.removeConnectStateChangeListener = function() { - console.log('Entered BluetoothLEDevice.removeConnectStateChangeListener()'); + privUtils_.log('Entered BluetoothLEDevice.removeConnectStateChangeListener()'); var args = AV.validateMethod(arguments, [ { @@ -812,7 +812,7 @@ var BluetoothDevice = function(data) { }; BluetoothDevice.prototype.connectToServiceByUUID = function() { - console.log('Entered BluetoothDevice.connectToServiceByUUID()'); + privUtils_.log('Entered BluetoothDevice.connectToServiceByUUID()'); var args = AV.validateMethod(arguments, [ { @@ -858,7 +858,7 @@ function BluetoothServiceListeners() { var result = new BluetoothSocket(e); if (service) { - console.log(service); + privUtils_.log(service); service.onconnect(result); } }; @@ -914,7 +914,7 @@ var BluetoothServiceHandler = function(data) { }; BluetoothServiceHandler.prototype.unregister = function() { - console.log('Entered BluetoothServiceHandler.unregister()'); + privUtils_.log('Entered BluetoothServiceHandler.unregister()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -967,13 +967,13 @@ function BluetoothHealthApplicationListeners() { break; default: - console.log('Unknown event: ' + event.event); + privUtils_.log('Unknown event: ' + event.event); break; } callback(param); } } else { - console.log('Received event for an unknown application: ' + event.id); + privUtils_.log('Received event for an unknown application: ' + event.id); } }; } @@ -1010,7 +1010,7 @@ var BluetoothHealthApplication = function(data) { }; BluetoothHealthApplication.prototype.unregister = function() { - console.log('Entered BluetoothHealthApplication.unregister()'); + privUtils_.log('Entered BluetoothHealthApplication.unregister()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -1067,7 +1067,7 @@ BluetoothHealthProfileHandler.prototype = new BluetoothProfileHandler(); BluetoothHealthProfileHandler.prototype.constructor = BluetoothProfileHandler; BluetoothHealthProfileHandler.prototype.registerSinkApplication = function() { - console.log('Entered BluetoothHealthProfileHandler.registerSinkApplication()'); + privUtils_.log('Entered BluetoothHealthProfileHandler.registerSinkApplication()'); var args = AV.validateMethod(arguments, [ { @@ -1110,7 +1110,7 @@ BluetoothHealthProfileHandler.prototype.registerSinkApplication = function() { }; BluetoothHealthProfileHandler.prototype.connectToSource = function() { - console.log('Entered BluetoothHealthProfileHandler.connectToSource()'); + privUtils_.log('Entered BluetoothHealthProfileHandler.connectToSource()'); var args = AV.validateMethod(arguments, [ { @@ -1177,7 +1177,7 @@ var BluetoothHealthChannel = function(data) { }; BluetoothHealthChannel.prototype.close = function() { - console.log('Entered BluetoothHealthChannel.close()'); + privUtils_.log('Entered BluetoothHealthChannel.close()'); if (this.isConnected) { var callArgs = { @@ -1196,7 +1196,7 @@ BluetoothHealthChannel.prototype.close = function() { }; BluetoothHealthChannel.prototype.sendData = function() { - console.log('Entered BluetoothHealthChannel.sendData()'); + privUtils_.log('Entered BluetoothHealthChannel.sendData()'); var args = AV.validateMethod(arguments, [ { name : 'data', @@ -1235,7 +1235,7 @@ function _BluetoothHealthChannelChangeCallback(event) { break; default: - console.log('Unknown mode: ' + e.event); + privUtils_.log('Unknown mode: ' + e.event); return; } @@ -1245,7 +1245,7 @@ function _BluetoothHealthChannelChangeCallback(event) { } var BluetoothHealthChannel_setListener = function() { - console.log('Entered BluetoothHealthChannel.setListener()'); + privUtils_.log('Entered BluetoothHealthChannel.setListener()'); privUtils_.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_HEALTH); var args = AV.validateMethod(arguments, [ { @@ -1268,7 +1268,7 @@ BluetoothHealthChannel.prototype.setListener = function() { }; var BluetoothHealthChannel_unsetListener = function() { - console.log('Entered BluetoothHealthChannel.unsetListener ()'); + privUtils_.log('Entered BluetoothHealthChannel.unsetListener ()'); if (T.isEmptyObject(_healthListeners)) { privUtils_.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_HEALTH); } @@ -1355,7 +1355,7 @@ var _bleScanListener = _singleListenerBuilder('BluetoothLEScanCallback', return ret; default: - console.log('Unknown mode: ' + event.action); + privUtils_.log('Unknown mode: ' + event.action); return ret; } if (successCallback) { @@ -1387,7 +1387,7 @@ var _bleAdvertiseListener = _singleListenerBuilder('BluetoothLEAdvertiseCallback return ret; default: - console.log('Unknown mode: ' + event.action); + privUtils_.log('Unknown mode: ' + event.action); return ret; } }); @@ -1397,7 +1397,7 @@ var BluetoothLEAdapter = function() { }; BluetoothLEAdapter.prototype.startScan = function() { - console.log('Entered BluetoothLEAdapter.startScan()'); + privUtils_.log('Entered BluetoothLEAdapter.startScan()'); var args = AV.validateMethod(arguments, [{ name: 'successCallback', type: AV.Types.FUNCTION @@ -1417,7 +1417,7 @@ BluetoothLEAdapter.prototype.startScan = function() { }; BluetoothLEAdapter.prototype.stopScan = function() { - console.log('Entered BluetoothLEAdapter.stopScan()'); + privUtils_.log('Entered BluetoothLEAdapter.stopScan()'); _bleScanListener.removeListener(); @@ -1439,7 +1439,7 @@ var _BluetoothAdvertisingMode = { }; BluetoothLEAdapter.prototype.startAdvertise = function() { - console.log('Entered BluetoothLEAdapter.startAdvertise()'); + privUtils_.log('Entered BluetoothLEAdapter.startAdvertise()'); var args = AV.validateMethod(arguments, [{ name: 'advertiseData', type: AV.Types.PLATFORM_OBJECT, @@ -1486,7 +1486,7 @@ BluetoothLEAdapter.prototype.startAdvertise = function() { }; BluetoothLEAdapter.prototype.stopAdvertise = function() { - console.log('Entered BluetoothLEAdapter.stopAdvertise()'); + privUtils_.log('Entered BluetoothLEAdapter.stopAdvertise()'); var result = native.callSync('BluetoothLEAdapter_stopAdvertise', {}); @@ -1646,7 +1646,7 @@ var BluetoothGATTCharacteristic = function(data, address) { }); this.readValue = function() { - console.log('Entered BluetoothGATTCharacteristic.readValue()'); + privUtils_.log('Entered BluetoothGATTCharacteristic.readValue()'); var args = AV.validateMethod(arguments, [{ name: 'successCallback', type: AV.Types.FUNCTION @@ -1676,7 +1676,7 @@ var BluetoothGATTCharacteristic = function(data, address) { }; this.writeValue = function() { - console.log('Entered BluetoothGATTCharacteristic.writeValue()'); + privUtils_.log('Entered BluetoothGATTCharacteristic.writeValue()'); var args = AV.validateMethod(arguments, [{ name: 'value', type: AV.Types.ARRAY, @@ -1711,7 +1711,7 @@ var BluetoothGATTCharacteristic = function(data, address) { }; var addValueChangeListener = function() { - console.log('Entered BluetoothGATTCharacteristic.addValueChangeListener()'); + privUtils_.log('Entered BluetoothGATTCharacteristic.addValueChangeListener()'); privUtils_.checkPrivilegeAccess4Ver("2.4", Privilege.BLUETOOTH, Privilege.BLUETOOTH_ADMIN); var args = AV.validateMethod(arguments, [{ name: 'callback', @@ -1734,7 +1734,7 @@ var BluetoothGATTCharacteristic = function(data, address) { }; this.removeValueChangeListener = function() { - console.log('Entered BluetoothGATTCharacteristic.removeValueChangeListener()'); + privUtils_.log('Entered BluetoothGATTCharacteristic.removeValueChangeListener()'); var args = AV.validateMethod(arguments, [{ name: 'watchID', @@ -1860,7 +1860,7 @@ var BluetoothGATTDescriptor = function(data, address) { var address_ = address; this.readValue = function() { - console.log('Entered BluetoothGATTDescriptor.readValue()'); + privUtils_.log('Entered BluetoothGATTDescriptor.readValue()'); var args = AV.validateMethod(arguments, [{ name: 'successCallback', type: AV.Types.FUNCTION @@ -1890,7 +1890,7 @@ var BluetoothGATTDescriptor = function(data, address) { }; this.writeValue = function() { - console.log('Entered BluetoothGATTDescriptor.writeValue()'); + privUtils_.log('Entered BluetoothGATTDescriptor.writeValue()'); var args = AV.validateMethod(arguments, [{ name: 'value', type: AV.Types.ARRAY, @@ -1994,7 +1994,7 @@ var BluetoothAdapter = function() { }; BluetoothAdapter.prototype.setName = function() { - console.log('Entered BluetoothAdapter.setName()'); + privUtils_.log('Entered BluetoothAdapter.setName()'); var args = AV.validateMethod(arguments, [ { name : 'name', @@ -2033,7 +2033,7 @@ BluetoothAdapter.prototype.setName = function() { }; BluetoothAdapter.prototype.setPowered = function() { - console.log('Entered BluetoothAdapter.setPowered()'); + privUtils_.log('Entered BluetoothAdapter.setPowered()'); console.warn('DEPRECATION WARNING: setPowered() is deprecated and will be removed from next release. ' + 'Let the user turn on/off Bluetooth through the Settings application instead.'); @@ -2077,7 +2077,7 @@ BluetoothAdapter.prototype.setPowered = function() { // This method is deprecated since Tizen 2.3 and will be removed in Tizen 3.0. BluetoothAdapter.prototype.setVisible = function() { - console.log('Entered BluetoothAdapter.setVisible()'); + privUtils_.log('Entered BluetoothAdapter.setVisible()'); var args = AV.validateMethod(arguments, [ { name : 'visible', @@ -2132,7 +2132,7 @@ BluetoothAdapter.prototype.setVisible = function() { var _listener; function _BluetoothAdapterChangeCallback(event) { - console.log('_BluetoothAdapterChangeCallback'); + privUtils_.log('_BluetoothAdapterChangeCallback'); var e = event; var d; @@ -2151,7 +2151,7 @@ function _BluetoothAdapterChangeCallback(event) { break; default: - console.log('Unknown mode: ' + e.action); + privUtils_.log('Unknown mode: ' + e.action); return; } @@ -2161,7 +2161,7 @@ function _BluetoothAdapterChangeCallback(event) { } BluetoothAdapter.prototype.setChangeListener = function() { - console.log('Entered BluetoothAdapter.setChangeListener()'); + privUtils_.log('Entered BluetoothAdapter.setChangeListener()'); var args = AV.validateMethod(arguments, [ { name : 'changeCallback', @@ -2177,7 +2177,7 @@ BluetoothAdapter.prototype.setChangeListener = function() { }; BluetoothAdapter.prototype.unsetChangeListener = function() { - console.log('Entered BluetoothAdapter.unsetChangeListener()'); + privUtils_.log('Entered BluetoothAdapter.unsetChangeListener()'); if (!T.isNullOrUndefined(_listener)) { native.removeListener('BluetoothAdapterChangeCallback', _BluetoothAdapterChangeCallback); _listener = undefined; @@ -2218,7 +2218,7 @@ function _BluetoothDiscoverDevicesSuccessCallback(event) { break; default: - console.log('Unknown mode: ' + e.action); + privUtils_.log('Unknown mode: ' + e.action); return; } @@ -2235,7 +2235,7 @@ function _BluetoothDiscoverDevicesErrorCallback(event) { } BluetoothAdapter.prototype.discoverDevices = function() { - console.log('Entered BluetoothAdapter.discoverDevices()'); + privUtils_.log('Entered BluetoothAdapter.discoverDevices()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -2269,7 +2269,7 @@ BluetoothAdapter.prototype.discoverDevices = function() { }; BluetoothAdapter.prototype.stopDiscovery = function() { - console.log('Entered BluetoothAdapter.stopDiscovery()'); + privUtils_.log('Entered BluetoothAdapter.stopDiscovery()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -2300,7 +2300,7 @@ BluetoothAdapter.prototype.stopDiscovery = function() { }; BluetoothAdapter.prototype.getKnownDevices = function() { - console.log('Entered BluetoothAdapter.getKnownDevices()'); + privUtils_.log('Entered BluetoothAdapter.getKnownDevices()'); var args = AV.validateMethod(arguments, [ { name : 'successCallback', @@ -2334,7 +2334,7 @@ BluetoothAdapter.prototype.getKnownDevices = function() { }; BluetoothAdapter.prototype.getDevice = function() { - console.log('Entered BluetoothAdapter.getDevice()'); + privUtils_.log('Entered BluetoothAdapter.getDevice()'); var args = AV.validateMethod(arguments, [ { name : 'address', @@ -2367,7 +2367,7 @@ BluetoothAdapter.prototype.getDevice = function() { }; BluetoothAdapter.prototype.createBonding = function() { - console.log('Entered BluetoothAdapter.createBonding()'); + privUtils_.log('Entered BluetoothAdapter.createBonding()'); var args = AV.validateMethod(arguments, [ { name : 'address', @@ -2406,7 +2406,7 @@ BluetoothAdapter.prototype.createBonding = function() { }; BluetoothAdapter.prototype.destroyBonding = function() { - console.log('Entered BluetoothAdapter.destroyBonding()'); + privUtils_.log('Entered BluetoothAdapter.destroyBonding()'); var args = AV.validateMethod(arguments, [ { name : 'address', @@ -2445,7 +2445,7 @@ BluetoothAdapter.prototype.destroyBonding = function() { }; BluetoothAdapter.prototype.registerRFCOMMServiceByUUID = function() { - console.log('Entered BluetoothAdapter.registerRFCOMMServiceByUUID()'); + privUtils_.log('Entered BluetoothAdapter.registerRFCOMMServiceByUUID()'); var args = AV.validateMethod(arguments, [ { name : 'uuid', @@ -2489,7 +2489,7 @@ BluetoothAdapter.prototype.registerRFCOMMServiceByUUID = function() { }; BluetoothAdapter.prototype.getBluetoothProfileHandler = function() { - console.log('Entered BluetoothAdapter.getBluetoothProfileHandler()'); + privUtils_.log('Entered BluetoothAdapter.getBluetoothProfileHandler()'); var args = AV.validateMethod(arguments, [ { @@ -2545,7 +2545,7 @@ var BluetoothManager_getDefaultAdapter = function() { BluetoothManager.prototype.getDefaultAdapter = function() { - console.log('Entered BluetoothManager.getDefaultAdapter()'); + privUtils_.log('Entered BluetoothManager.getDefaultAdapter()'); return BluetoothManager_getDefaultAdapter(); }; @@ -2556,7 +2556,7 @@ var BluetoothManager_getLEAdapter = function() { }; BluetoothManager.prototype.getLEAdapter = function() { - console.log('Entered BluetoothManager.getLEAdapter()'); + privUtils_.log('Entered BluetoothManager.getLEAdapter()'); return BluetoothManager_getLEAdapter(); }; // exports /////////////////////////////////////////////////////////////////// diff --git a/src/callhistory/callhistory_api.js b/src/callhistory/callhistory_api.js index 79e8c8b..e2ed279 100755 --- a/src/callhistory/callhistory_api.js +++ b/src/callhistory/callhistory_api.js @@ -64,7 +64,7 @@ ListenerManager.prototype.onListenerCalled = function(msg) { break; default: - console.log('Unknown mode: ' + msg.action); + privUtils_.log('Unknown mode: ' + msg.action); return; } diff --git a/src/contact/js/contact.js b/src/contact/js/contact.js index bb2f168..af317de 100755 --- a/src/contact/js/contact.js +++ b/src/contact/js/contact.js @@ -362,14 +362,14 @@ var _contactAddressToString = function(obj) { // Convert email address from Contact object to string var _contactEmailToString = function(obj) { if (!type_.isArray(obj.emails) || obj.emails.length === 0) { - console.log('Empty email list'); + utils_.log('Empty email list'); return ''; } var str = ''; for (var mail in obj.emails) { if (!mail instanceof ContactEmailAddress || !type_.isArray(mail.types) || mail.types.length === 0) { - console.log('Incorrect email type'); + utils_.log('Incorrect email type'); continue; } str += 'EMAIL;'; diff --git a/src/content/js/datatypes.js b/src/content/js/datatypes.js index 0768f9f..adb826d 100755 --- a/src/content/js/datatypes.js +++ b/src/content/js/datatypes.js @@ -478,7 +478,7 @@ function AudioContent(data) { var result = native_.callSync('ContentManager_getLyrics', data); if (native_.isFailure(result)) { - console.log('Getting lyrics failed for ' + data.contentURI); + utils_.log('Getting lyrics failed for ' + data.contentURI); return; } diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 49d6b21..6b02506 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -204,7 +204,7 @@ ConvergenceManager.prototype.startDiscovery = function(successCallback, convergenceDevices = []; } else { - console.log('UNKNOWN discovery state exception'); + utils_.log('UNKNOWN discovery state exception'); } } }); diff --git a/src/download/download_api.js b/src/download/download_api.js index 018bfca..b47ddd0 100755 --- a/src/download/download_api.js +++ b/src/download/download_api.js @@ -13,7 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + +var privUtils_ = xwalk.utils; var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var check_ = xwalk.utils.type; @@ -28,10 +29,10 @@ extension.setMessageListener(function(json) { var result = JSON.parse(json); var callback = callbacks[result.callbackId]; - //console.log("PostMessage received: " + result.status); + //privUtils_.log("PostMessage received: " + result.status); if (!callback) { - console.logd('Ignoring unknown callback: ' + result.callbackId); + privUtils_.log('Ignoring unknown callback: ' + result.callbackId); return; } setTimeout(function() { diff --git a/src/filesystem/js/common.js b/src/filesystem/js/common.js index 15cc697..6eeddca 100644 --- a/src/filesystem/js/common.js +++ b/src/filesystem/js/common.js @@ -130,7 +130,7 @@ var commonFS_ = (function() { }); listenerRegistered = true; } catch (e) { - console.log('Failed to register storage change listener, ' + privUtils_.log('Failed to register storage change listener, ' + 'storage information may be corrupted: ' + e.message); } } @@ -189,7 +189,7 @@ var commonFS_ = (function() { function convertForEarlierVersionPath(aPath) { if (isAppForEarlierVersion) { if (aPath && aPath.indexOf(tizen24home) === 0) { - console.log("Converting 2.4 style path to 3.0 pattern"); + privUtils_.log("Converting 2.4 style path to 3.0 pattern"); aPath = homeDir + aPath.substr(tizen24home.length); } } diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 4b07da6..7622d53 100644 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -37,7 +37,7 @@ function File(data) { return null; } } catch (err) { - console.log(err.name, err.message); + privUtils_.log(err.name, err.message); return null; } }(data)), diff --git a/src/humanactivitymonitor/humanactivitymonitor_api.js b/src/humanactivitymonitor/humanactivitymonitor_api.js index 736b9a4..81002eb 100755 --- a/src/humanactivitymonitor/humanactivitymonitor_api.js +++ b/src/humanactivitymonitor/humanactivitymonitor_api.js @@ -320,7 +320,7 @@ HumanActivityMonitorManager.prototype.start = function(type, changedCallback) { }; } - console.log("callbackInterval = " + callbackInterval + ", sampleInterval = " + sampleInterval); + utils_.log("callbackInterval = " + callbackInterval + ", sampleInterval = " + sampleInterval); startListener(listenerId, listener, 'HumanActivityMonitorManager_start', diff --git a/src/iotcon/iotcon_api.js b/src/iotcon/iotcon_api.js index e33a562..9290d32 100644 --- a/src/iotcon/iotcon_api.js +++ b/src/iotcon/iotcon_api.js @@ -20,6 +20,7 @@ var types = validator.Types; var T = xwalk.utils.type; var kIdKey = Symbol(); var converter = xwalk.utils.converter; +var privUtils_ = xwalk.utils; function createListener(name, c) { var listenerName = name; @@ -601,7 +602,7 @@ function prepareResourceInfo(that, notIncludeOptions){ var callArgs = {}; callArgs.id = that[kIdKey]; if (!callArgs.id) { - console.log("RemoteResource is not already stored in C++ layer, adding all members"); + privUtils_.log("RemoteResource is not already stored in C++ layer, adding all members"); callArgs.hostAddress = that.hostAddress; callArgs.connectivityType = that.connectivityType; callArgs.uriPath = that.uriPath; @@ -618,7 +619,7 @@ function prepareResourceInfo(that, notIncludeOptions){ callArgs.options = that.options; } } else { - console.log("Already stored in C++, all needed info is id"); + privUtils_.log("Already stored in C++, all needed info is id"); } return callArgs; } @@ -626,9 +627,9 @@ function prepareResourceInfo(that, notIncludeOptions){ function manageId(that, result) { if (result.keepId) { that[kIdKey] = result.id; - console.log("Keep id of resource: " + that[kIdKey]); + privUtils_.log("Keep id of resource: " + that[kIdKey]); } else { - console.log("Clear id of resource"); + privUtils_.log("Clear id of resource"); delete that[kIdKey]; } delete result.keepId; diff --git a/src/messageport/messageport_api.js b/src/messageport/messageport_api.js index acc1cae..cada46b 100755 --- a/src/messageport/messageport_api.js +++ b/src/messageport/messageport_api.js @@ -18,6 +18,7 @@ var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var type_ = xwalk.utils.type; var converter_ = xwalk.utils.converter; +var privUtils_ = xwalk.utils; var callbackId = 0; var callbacks = {}; @@ -28,7 +29,7 @@ extension.setMessageListener(function(json) { var listeners = callbacks[msg['local_port_id']]; var rmp; - console.log('Listeners length:' + listeners.length); + privUtils_.log('Listeners length:' + listeners.length); if (!msg.hasOwnProperty('remotePort')) rmp = null; diff --git a/src/messaging/messaging_api.js b/src/messaging/messaging_api.js index dbae2b4..fe4f4f7 100755 --- a/src/messaging/messaging_api.js +++ b/src/messaging/messaging_api.js @@ -18,6 +18,7 @@ var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var T_ = xwalk.utils.type; var native = new xwalk.utils.NativeManager(extension); +var privUtils_ = xwalk.utils; function throwException_(err) { throw new WebAPIException(err.code, err.name, err.message); @@ -75,7 +76,7 @@ function addTypeToFilter_(data) * } * * m.name = 'A brand new name'; - * console.log(m.name); // Name + * privUtils_.log(m.name); // Name */ function propertyFactory_(that, name, value, flags, options) { flags = flags || 0; diff --git a/src/nfc/nfc_api.js b/src/nfc/nfc_api.js index c97646f..db3d0e3 100644 --- a/src/nfc/nfc_api.js +++ b/src/nfc/nfc_api.js @@ -992,7 +992,7 @@ function NFCTag(tagid) { return; } - console.log('Current result: ' + result); + privUtils_.log('Current result: ' + result); var result_array = {}; for (var i in result.result) { diff --git a/src/secureelement/secureelement_api.js b/src/secureelement/secureelement_api.js index e175529..db67d02 100644 --- a/src/secureelement/secureelement_api.js +++ b/src/secureelement/secureelement_api.js @@ -42,7 +42,7 @@ ListenerManager.prototype.onListenerCalled = function(msg) { d = new Reader(msg.handle); break; default: - console.log('Unknown mode: ' + msg.action); + privUtils_.log('Unknown mode: ' + msg.action); return; } @@ -184,7 +184,7 @@ function Reader(reader_handle) { var callArgs = { handle: reader_handle }; var result = native_.callSync('SEReader_isPresent', callArgs); if (native_.isFailure(result)) { - console.log('SEReader_isPresent error: ' + native_.getErrorObject(result)); + privUtils_.log('SEReader_isPresent error: ' + native_.getErrorObject(result)); return false; } else { return native_.getResultObject(result); @@ -306,7 +306,7 @@ function Session(session_handle) { var callArgs = { handle: session_handle }; var result = native_.callSync('SESession_isClosed', callArgs); if (native_.isFailure(result)) { - console.log('SESession_isClosed error: ' + native_.getErrorObject(result)); + privUtils_.log('SESession_isClosed error: ' + native_.getErrorObject(result)); return true; } else { return native_.getResultObject(result); diff --git a/src/systeminfo/systeminfo_api.js b/src/systeminfo/systeminfo_api.js index d6b9634..ce4755b 100644 --- a/src/systeminfo/systeminfo_api.js +++ b/src/systeminfo/systeminfo_api.js @@ -1221,7 +1221,7 @@ var _listenerFunction = function(msg) { if (propertyId) { _propertyContainer[propertyId].broadcastFunction(msg); } else { - console.log("No propertyId provided - ignoring"); + privUtils_.log("No propertyId provided - ignoring"); } } native_.addListener("SysteminfoCommonListenerLabel", _listenerFunction); @@ -1275,7 +1275,7 @@ var _unregisterListener = function (watchId, isTimeout) { } catch (e) { // if it is "auto" timeout call it should not throw an exception if (isTimeout) { - console.log('Listener was already deleted'); + privUtils_.log('Listener was already deleted'); return; } throw e; diff --git a/src/time/time_api.js b/src/time/time_api.js index 67ae674..95c9d6f 100644 --- a/src/time/time_api.js +++ b/src/time/time_api.js @@ -77,7 +77,7 @@ function _constructTZDate(obj, privateTZDate) { switch (tzName) { case _LOCAL_ID: - console.log('Entered _constructTZDate for local timezone'); + utils_.log('Entered _constructTZDate for local timezone'); tzName = tizen.time.getLocalTimezone(); @@ -87,7 +87,7 @@ function _constructTZDate(obj, privateTZDate) { break; case _GMT_ID: - console.log('Entered _constructTZDate for GMT'); + utils_.log('Entered _constructTZDate for GMT'); if (T.isNullOrUndefined(offset)) { offset = 0; @@ -95,7 +95,7 @@ function _constructTZDate(obj, privateTZDate) { break; default: - console.log('Entered _constructTZDate for: ' + tzName); + utils_.log('Entered _constructTZDate for: ' + tzName); if (T.isNullOrUndefined(offset)) { // throws if tzName is invalid offset = _getTimezoneOffset(utcTimestamp, tzName).offset; @@ -113,7 +113,7 @@ function _constructTZDate(obj, privateTZDate) { //class TZDate //////////////////////////////////////////////////// tizen.TZDate = function(p1, p2, day, hours, minutes, seconds, milliseconds, timezone) { - console.log("Entered tizen.TZDate"); + utils_.log("Entered tizen.TZDate"); validator_.validateConstructorCall(this, tizen.TZDate); var priv; @@ -122,7 +122,7 @@ tizen.TZDate = function(p1, p2, day, hours, minutes, seconds, milliseconds, time priv = p1; } else { //Public constructor section - console.log('Entered TZDate constructor with: ' + arguments.length + ' attributes'); + utils_.log('Entered TZDate constructor with: ' + arguments.length + ' attributes'); var date; @@ -187,7 +187,7 @@ tizen.TZDate = function(p1, p2, day, hours, minutes, seconds, milliseconds, time }; tizen.TZDate.prototype.getDate = function() { - console.log('Entered TZDate.getDate'); + utils_.log('Entered TZDate.getDate'); //getters realized with pattern //---> use _shiftedTimestamp (_utcTimestamp (UTC) with added _timezoneOffset) //---> create Date instance @@ -227,157 +227,157 @@ function _updateTZDateUTC(tzdate, args, param, func) { } tizen.TZDate.prototype.setDate = function() { - console.log('Entered TZDate.setDate'); + utils_.log('Entered TZDate.setDate'); _updateTZDate(this, arguments, 'date', 'setUTCDate'); }; tizen.TZDate.prototype.getDay = function() { - console.log('Entered TZDate.getDay'); + utils_.log('Entered TZDate.getDay'); return _createShiftedDate(this).getUTCDay(); }; tizen.TZDate.prototype.getFullYear = function() { - console.log('Entered TZDate.getFullYear'); + utils_.log('Entered TZDate.getFullYear'); return _createShiftedDate(this).getUTCFullYear(); }; tizen.TZDate.prototype.setFullYear = function() { - console.log('Entered TZDate.setFullYear'); + utils_.log('Entered TZDate.setFullYear'); _updateTZDate(this, arguments, 'year', 'setUTCFullYear'); }; tizen.TZDate.prototype.getHours = function() { - console.log('Entered TZDate.getHours'); + utils_.log('Entered TZDate.getHours'); return _createShiftedDate(this).getUTCHours(); }; tizen.TZDate.prototype.setHours = function() { - console.log('Entered TZDate.setHours'); + utils_.log('Entered TZDate.setHours'); _updateTZDate(this, arguments, 'hours', 'setUTCHours'); }; tizen.TZDate.prototype.getMilliseconds = function() { - console.log('Entered TZDate.getMilliseconds'); + utils_.log('Entered TZDate.getMilliseconds'); return _createShiftedDate(this).getUTCMilliseconds(); }; tizen.TZDate.prototype.setMilliseconds = function() { - console.log('Entered TZDate.setMilliseconds'); + utils_.log('Entered TZDate.setMilliseconds'); _updateTZDate(this, arguments, 'ms', 'setUTCMilliseconds'); }; tizen.TZDate.prototype.getMinutes = function() { - console.log('Entered TZDate.getMinutes'); + utils_.log('Entered TZDate.getMinutes'); return _createShiftedDate(this).getUTCMinutes(); }; tizen.TZDate.prototype.setMinutes = function() { - console.log('Entered TZDate.setMinutes'); + utils_.log('Entered TZDate.setMinutes'); _updateTZDate(this, arguments, 'minutes', 'setUTCMinutes'); }; tizen.TZDate.prototype.getMonth = function() { - console.log('Entered TZDate.getMonth'); + utils_.log('Entered TZDate.getMonth'); return _createShiftedDate(this).getUTCMonth(); }; tizen.TZDate.prototype.setMonth = function() { - console.log('Entered TZDate.setMonth'); + utils_.log('Entered TZDate.setMonth'); _updateTZDate(this, arguments, 'month', 'setUTCMonth'); }; tizen.TZDate.prototype.getSeconds = function() { - console.log('Entered TZDate.getSeconds'); + utils_.log('Entered TZDate.getSeconds'); return _createShiftedDate(this).getUTCSeconds(); }; tizen.TZDate.prototype.setSeconds = function() { - console.log('Entered TZDate.setSeconds'); + utils_.log('Entered TZDate.setSeconds'); _updateTZDate(this, arguments, 'seconds', 'setUTCSeconds'); }; tizen.TZDate.prototype.getUTCDate = function() { - console.log('Entered TZDate.getUTCDate'); + utils_.log('Entered TZDate.getUTCDate'); return _createUTCDate(this).getUTCDate(); }; tizen.TZDate.prototype.setUTCDate = function() { - console.log('Entered TZDate.setUTCDate'); + utils_.log('Entered TZDate.setUTCDate'); _updateTZDateUTC(this, arguments, 'date', 'setUTCDate'); }; tizen.TZDate.prototype.getUTCDay = function() { - console.log('Entered TZDate.getUTCDay'); + utils_.log('Entered TZDate.getUTCDay'); return _createUTCDate(this).getUTCDay(); }; tizen.TZDate.prototype.getUTCFullYear = function() { - console.log('Entered TZDate.getUTCFullYear'); + utils_.log('Entered TZDate.getUTCFullYear'); return _createUTCDate(this).getUTCFullYear(); }; tizen.TZDate.prototype.setUTCFullYear = function() { - console.log('Entered TZDate.setUTCFullYear'); + utils_.log('Entered TZDate.setUTCFullYear'); _updateTZDateUTC(this, arguments, 'year', 'setUTCFullYear'); }; tizen.TZDate.prototype.getUTCHours = function() { - console.log('Entered TZDate.getUTCHours'); + utils_.log('Entered TZDate.getUTCHours'); return _createUTCDate(this).getUTCHours(); }; tizen.TZDate.prototype.setUTCHours = function() { - console.log('Entered TZDate.setUTCHours'); + utils_.log('Entered TZDate.setUTCHours'); _updateTZDateUTC(this, arguments, 'hours', 'setUTCHours'); }; tizen.TZDate.prototype.getUTCMilliseconds = function() { - console.log('Entered TZDate.getUTCMilliseconds'); + utils_.log('Entered TZDate.getUTCMilliseconds'); return _createUTCDate(this).getUTCMilliseconds(); }; tizen.TZDate.prototype.setUTCMilliseconds = function() { - console.log('Entered TZDate.setUTCMilliseconds'); + utils_.log('Entered TZDate.setUTCMilliseconds'); _updateTZDateUTC(this, arguments, 'ms', 'setUTCMilliseconds'); }; tizen.TZDate.prototype.getUTCMinutes = function() { - console.log('Entered TZDate.getUTCMinutes'); + utils_.log('Entered TZDate.getUTCMinutes'); return _createUTCDate(this).getUTCMinutes(); }; tizen.TZDate.prototype.setUTCMinutes = function() { - console.log('Entered TZDate.setUTCMinutes'); + utils_.log('Entered TZDate.setUTCMinutes'); _updateTZDateUTC(this, arguments, 'minutes', 'setUTCMinutes'); }; tizen.TZDate.prototype.getUTCMonth = function() { - console.log('Entered TZDate.getUTCMonth'); + utils_.log('Entered TZDate.getUTCMonth'); return _createUTCDate(this).getUTCMonth(); }; tizen.TZDate.prototype.setUTCMonth = function() { - console.log('Entered TZDate.setUTCMonth'); + utils_.log('Entered TZDate.setUTCMonth'); _updateTZDateUTC(this, arguments, 'month', 'setUTCMonth'); }; tizen.TZDate.prototype.getUTCSeconds = function() { - console.log('Entered TZDate.getUTCSeconds'); + utils_.log('Entered TZDate.getUTCSeconds'); return _createUTCDate(this).getUTCSeconds(); }; tizen.TZDate.prototype.setUTCSeconds = function() { - console.log('Entered TZDate.setUTCSeconds'); + utils_.log('Entered TZDate.setUTCSeconds'); _updateTZDateUTC(this, arguments, 'seconds', 'setUTCSeconds'); }; tizen.TZDate.prototype.getTimezone = function() { - console.log('Entered TZDate.getTimezone'); + utils_.log('Entered TZDate.getTimezone'); return this._timezoneName; }; tizen.TZDate.prototype.toTimezone = function() { - console.log('Entered TZDate.toTimezone'); + utils_.log('Entered TZDate.toTimezone'); var args = validator_.validateMethod(arguments, [ { name : 'timezone', @@ -388,17 +388,17 @@ tizen.TZDate.prototype.toTimezone = function() { }; tizen.TZDate.prototype.toLocalTimezone = function() { - console.log('Entered TZDate.toLocalTimezone'); + utils_.log('Entered TZDate.toLocalTimezone'); return new tizen.TZDate(new PrivateTZDate(this._utcTimestamp, _LOCAL_ID)); }; tizen.TZDate.prototype.toUTC = function() { - console.log('Entered TZDate.toUTC'); + utils_.log('Entered TZDate.toUTC'); return new tizen.TZDate(new PrivateTZDate(this._utcTimestamp, _GMT_ID)); }; tizen.TZDate.prototype.difference = function() { - console.log('Entered TZDate.difference'); + utils_.log('Entered TZDate.difference'); var args = validator_.validateMethod(arguments, [ { name : 'other', @@ -416,7 +416,7 @@ tizen.TZDate.prototype.difference = function() { }; tizen.TZDate.prototype.equalsTo = function() { - console.log('Entered TZDate.equalsTo'); + utils_.log('Entered TZDate.equalsTo'); var args = validator_.validateMethod(arguments, [ { name : 'other', @@ -428,7 +428,7 @@ tizen.TZDate.prototype.equalsTo = function() { }; tizen.TZDate.prototype.earlierThan = function() { - console.log('Entered TZDate.earlierThan'); + utils_.log('Entered TZDate.earlierThan'); var args = validator_.validateMethod(arguments, [ { name : 'other', @@ -440,7 +440,7 @@ tizen.TZDate.prototype.earlierThan = function() { }; tizen.TZDate.prototype.laterThan = function() { - console.log('Entered TZDate.laterThan'); + utils_.log('Entered TZDate.laterThan'); var args = validator_.validateMethod(arguments, [ { name : 'other', @@ -452,7 +452,7 @@ tizen.TZDate.prototype.laterThan = function() { }; tizen.TZDate.prototype.addDuration = function() { - console.log('Entered TZDate.addDuration'); + utils_.log('Entered TZDate.addDuration'); var args = validator_.validateMethod(arguments, [ { name : 'duration', @@ -466,7 +466,7 @@ tizen.TZDate.prototype.addDuration = function() { }; tizen.TZDate.prototype.toLocaleDateString = function() { - console.log('Entered TZDate.toLocaleDateString'); + utils_.log('Entered TZDate.toLocaleDateString'); var result = native_.callSync('TZDate_toLocaleDateString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -477,7 +477,7 @@ tizen.TZDate.prototype.toLocaleDateString = function() { }; tizen.TZDate.prototype.toLocaleTimeString = function() { - console.log('Entered TZDate.toLocaleTimeString'); + utils_.log('Entered TZDate.toLocaleTimeString'); var result = native_.callSync('TZDate_toLocaleTimeString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -488,7 +488,7 @@ tizen.TZDate.prototype.toLocaleTimeString = function() { }; tizen.TZDate.prototype.toLocaleString = function() { - console.log('Entered TZDate.toLocaleString'); + utils_.log('Entered TZDate.toLocaleString'); var result = native_.callSync('TZDate_toLocaleString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -499,7 +499,7 @@ tizen.TZDate.prototype.toLocaleString = function() { }; tizen.TZDate.prototype.toDateString = function() { - console.log('Entered TZDate.toDateString'); + utils_.log('Entered TZDate.toDateString'); var result = native_.callSync('TZDate_toDateString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -510,7 +510,7 @@ tizen.TZDate.prototype.toDateString = function() { }; tizen.TZDate.prototype.toTimeString = function() { - console.log('Entered TZDate.toTimeString'); + utils_.log('Entered TZDate.toTimeString'); var result = native_.callSync('TZDate_toTimeString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -521,7 +521,7 @@ tizen.TZDate.prototype.toTimeString = function() { }; tizen.TZDate.prototype.toString = function() { - console.log('Entered TZDate.toString'); + utils_.log('Entered TZDate.toString'); var result = native_.callSync('TZDate_toString', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -532,7 +532,7 @@ tizen.TZDate.prototype.toString = function() { }; tizen.TZDate.prototype.getTimezoneAbbreviation = function() { - console.log('Entered TZDate.getTimezoneAbbreviation'); + utils_.log('Entered TZDate.getTimezoneAbbreviation'); console.warn('DEPRECATION WARNING: getTimezoneAbbreviation() is deprecated and will be removed from next release.'); var result = native_.callSync('TZDate_getTimezoneAbbreviation', @@ -545,12 +545,12 @@ tizen.TZDate.prototype.getTimezoneAbbreviation = function() { }; tizen.TZDate.prototype.secondsFromUTC = function() { - console.log('Entered TZDate.secondsFromUTC'); + utils_.log('Entered TZDate.secondsFromUTC'); return -this._timezoneOffset/1000; }; tizen.TZDate.prototype.isDST = function() { - console.log('Entered TZDate.isDST'); + utils_.log('Entered TZDate.isDST'); var result = native_.callSync('TZDate_isDST', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -561,7 +561,7 @@ tizen.TZDate.prototype.isDST = function() { }; tizen.TZDate.prototype.getPreviousDSTTransition = function() { - console.log('Entered TZDate.getPreviousDSTTransition'); + utils_.log('Entered TZDate.getPreviousDSTTransition'); var result = native_.callSync('TZDate_getPreviousDSTTransition', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -574,7 +574,7 @@ tizen.TZDate.prototype.getPreviousDSTTransition = function() { }; tizen.TZDate.prototype.getNextDSTTransition = function() { - console.log('Entered TZDate.getNextDSTTransition'); + utils_.log('Entered TZDate.getNextDSTTransition'); var result = native_.callSync('TZDate_getNextDSTTransition', {timezone: String(this._timezoneName), timestamp: String(this._utcTimestamp)}); @@ -643,7 +643,7 @@ function _convertMsecsToBiggestPossibleUnit(len) { //class tizen.TimeDuration //////////////////////////////////////////////////// tizen.TimeDuration = function(length, unit) { - console.log('Entered TimeDuration constructor'); + utils_.log('Entered TimeDuration constructor'); validator_.validateConstructorCall(this, tizen.TimeDuration); var l, u; if (arguments.length >= 2) { @@ -690,7 +690,7 @@ tizen.TimeDuration = function(length, unit) { } tizen.TimeDuration.prototype.difference = function() { - console.log('Entered TimeDuration.difference'); + utils_.log('Entered TimeDuration.difference'); var args = validator_.validateMethod(arguments, [ { @@ -710,7 +710,7 @@ tizen.TimeDuration.prototype.difference = function() { }; tizen.TimeDuration.prototype.equalsTo = function() { - console.log('Entered TimeDuration.equalsTo'); + utils_.log('Entered TimeDuration.equalsTo'); var args = validator_.validateMethod(arguments, [ { @@ -730,7 +730,7 @@ tizen.TimeDuration.prototype.equalsTo = function() { }; tizen.TimeDuration.prototype.lessThan = function() { - console.log('Entered TimeDuration.lessThan'); + utils_.log('Entered TimeDuration.lessThan'); var args = validator_.validateMethod(arguments, [ { @@ -750,7 +750,7 @@ tizen.TimeDuration.prototype.lessThan = function() { }; tizen.TimeDuration.prototype.greaterThan = function() { - console.log('Entered TimeDuration.greaterThan'); + utils_.log('Entered TimeDuration.greaterThan'); var args = validator_.validateMethod(arguments, [ { @@ -772,12 +772,12 @@ tizen.TimeDuration.prototype.greaterThan = function() { //class TimeUtil //////////////////////////////////////////////////// exports.getCurrentDateTime = function() { - console.log('Entered TimeUtil.getCurrentDateTime'); + utils_.log('Entered TimeUtil.getCurrentDateTime'); return new tizen.TZDate(); }; exports.getLocalTimezone = function() { - console.log('Entered TimeUtil.getLocalTimezone'); + utils_.log('Entered TimeUtil.getLocalTimezone'); var result = native_.callSync('TZDate_getLocalTimezone', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -788,7 +788,7 @@ exports.getLocalTimezone = function() { var _availableTimezones = []; //an array for holding available timezones exports.getAvailableTimezones = function() { - console.log('Entered TimeUtil.getAvailableTimezones'); + utils_.log('Entered TimeUtil.getAvailableTimezones'); if (_availableTimezones.length === 0) { var result = native_.callSync('TimeUtil_getAvailableTimezones', {}); if (native_.isFailure(result)) { @@ -801,7 +801,7 @@ exports.getAvailableTimezones = function() { }; exports.getDateFormat = function() { - console.log('Entered TimeUtil.getDateFormat'); + utils_.log('Entered TimeUtil.getDateFormat'); var args = validator_.validateMethod(arguments, [ { @@ -824,7 +824,7 @@ exports.getDateFormat = function() { }; exports.getTimeFormat = function() { - console.log('Entered TimeUtil.getTimeFormat'); + utils_.log('Entered TimeUtil.getTimeFormat'); var result = native_.callSync('TimeUtil_getTimeFormat', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -833,7 +833,7 @@ exports.getTimeFormat = function() { }; exports.isLeapYear = function() { - console.log('Entered TimeUtil.isLeapYear'); + utils_.log('Entered TimeUtil.isLeapYear'); var args = validator_.validateMethod(arguments, [ { @@ -849,12 +849,12 @@ exports.isLeapYear = function() { var _timeUtilDateTimeChangeListener; function _timeChangedListenerCallback(eventObj) { - console.log("_timeChangedListenerCallback"); + utils_.log("_timeChangedListenerCallback"); native_.callIfPossible(_timeUtilDateTimeChangeListener); } exports.setDateTimeChangeListener = function() { - console.log('Entered TimeUtil.setDateTimeChangeListener'); + utils_.log('Entered TimeUtil.setDateTimeChangeListener'); var args = validator_.validateMethod(arguments, [ { name : 'changeCallback', @@ -870,7 +870,7 @@ exports.setDateTimeChangeListener = function() { }; exports.unsetDateTimeChangeListener = function() { - console.log('Entered TimeUtil.unsetDateTimeChangeListener'); + utils_.log('Entered TimeUtil.unsetDateTimeChangeListener'); var result = native_.callSync('TimeUtil_unsetDateTimeChangeListener', {}); if (native_.isFailure(result)) { throw native_.getErrorObject(result); @@ -881,12 +881,12 @@ exports.unsetDateTimeChangeListener = function() { var _timeUtilTimezoneChangeListener; function _timezoneListenerCallback(eventObj) { - console.log("_timezoneListenerCallback"); + utils_.log("_timezoneListenerCallback"); native_.callIfPossible(_timeUtilTimezoneChangeListener); } exports.setTimezoneChangeListener = function() { - console.log('Entered TimeUtil.setTimezoneChangeListener'); + utils_.log('Entered TimeUtil.setTimezoneChangeListener'); var args = validator_.validateMethod(arguments, [ { name : 'changeCallback', @@ -904,7 +904,7 @@ exports.setTimezoneChangeListener = function() { }; exports.unsetTimezoneChangeListener = function() { - console.log('Entered TimeUtil.unsetTimezoneChangeListener'); + utils_.log('Entered TimeUtil.unsetTimezoneChangeListener'); native_.removeListener('TimezoneChangeListener'); var result = native_.callSync('TimeUtil_unsetTimezoneChangeListener', {}); _timeUtilTimezoneChangeListener = undefined; diff --git a/src/utils/utils_api.js b/src/utils/utils_api.js index 3710455..85fdc33 100644 --- a/src/utils/utils_api.js +++ b/src/utils/utils_api.js @@ -3,6 +3,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +var _enableJsLogs = false; + var _global = {}; if (typeof window != 'undefined') { _global = window; @@ -139,6 +141,12 @@ function Utils() { }); } +Utils.prototype.log = function() { + if (_enableJsLogs) { + console.log.apply(console, arguments); + } +} + Utils.prototype.repackFilter = function(filter) { if (filter instanceof tizen.AttributeFilter) { return { -- 2.7.4 From 3ed9e1b0c702647aa09ed63b826cb54d989a5bc2 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Tue, 28 Feb 2017 08:25:49 +0100 Subject: [PATCH 06/16] [Notification] Notification.progressValue should be set to null when is not defined by user Below comparision should always be true. tizen.notification.post(noti); tizen.notification.get(id).progressValue === noti.progressValue // true [Verification] Notification TCT tests passed 100% Change-Id: Ia53a25eaf5aee110e4fe3128d18e87fdaa2deb9f Signed-off-by: Szymon Jastrzebski --- src/notification/status_notification.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/notification/status_notification.cc b/src/notification/status_notification.cc index 13fe62c..1b55a50 100644 --- a/src/notification/status_notification.cc +++ b/src/notification/status_notification.cc @@ -1314,14 +1314,19 @@ PlatformResult StatusNotification::FromJson(const picojson::object& args, return status; } + double progressValue; if (val.contains("progressValue") && !IsNull(noti_obj, "progressValue")) { - double progressValue = common::FromJson(noti_obj, "progressValue"); - status = SetProgressValue(noti_handle, progress_type, progressValue, - is_update); + progressValue = common::FromJson(noti_obj, "progressValue"); + } + else { + progressValue = -1; + } - if (status.IsError()) { - return status; - } + status = SetProgressValue(noti_handle, progress_type, progressValue, + is_update); + + if (status.IsError()) { + return status; } status = SetText(noti_handle, -- 2.7.4 From b7f8941d093d718ebd3b10c32eddee1032d76f87 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 1 Mar 2017 12:40:45 +0100 Subject: [PATCH 07/16] [version] 1.75 Change-Id: Iacd048e44ffd0dd9dc551c6ef7243f759dbc1baa Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 4be9038..ddeb8ce 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.74 +Version: 1.75 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From dc80f733c10e3aa6e368e64df079602e4564aeab Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Mon, 6 Mar 2017 10:09:43 +0100 Subject: [PATCH 08/16] [Bluetooth] Fix GATT characteristic value change listener Function registered with addValueChangeListener was not called. Change-Id: Ida88778e21884510fece8c30b93da265b246db2b --- src/bluetooth/bluetooth_gatt_service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth/bluetooth_gatt_service.cc b/src/bluetooth/bluetooth_gatt_service.cc index fce5b56..1171038 100755 --- a/src/bluetooth/bluetooth_gatt_service.cc +++ b/src/bluetooth/bluetooth_gatt_service.cc @@ -586,7 +586,7 @@ void BluetoothGATTService::OnCharacteristicValueChanged( } picojson::value result = picojson::value(picojson::object()); - picojson::object result_obj = result.get(); + picojson::object& result_obj = result.get(); result_obj.insert(std::make_pair(kHandle, picojson::value((double)(long)characteristic))); -- 2.7.4 From 1a1584fc0d8775682b9b6ddbbe9081c8a49801a3 Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Tue, 7 Mar 2017 11:14:14 +0100 Subject: [PATCH 09/16] [Bluetooth] Fix Bluetooth LE advertising initialzation startAdvertise() could not obtain "uuids" field of BluetoothLEAdvertiseData and "uuid" of BluetoothLEServiceData. [Verification] After a call to startAdvertise() in application's debug mode, the device becomes discoverable by other devices with its service and serviceData. Change-Id: Iedf239e1e79df15b32f8c4de9df397635d789eb6 Signed-off-by: Pawel Wasowski --- src/bluetooth/bluetooth_le_adapter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bluetooth/bluetooth_le_adapter.cc b/src/bluetooth/bluetooth_le_adapter.cc index 7447289..b63fc32 100755 --- a/src/bluetooth/bluetooth_le_adapter.cc +++ b/src/bluetooth/bluetooth_le_adapter.cc @@ -105,7 +105,7 @@ class BluetoothLEServiceData : public ParsedDataHolder { static bool ParseUUID(const picojson::value& obj, BluetoothLEServiceData* out) { LoggerD("Entered"); - const auto& uuid = obj.get("serviceuuid"); + const auto& uuid = obj.get("uuid"); if (uuid.is()) { out->uuid_ = uuid.get(); } else { @@ -261,7 +261,7 @@ class BluetoothLEAdvertiseData : public ParsedDataHolder { static bool ParseServiceUUIDs(const picojson::value& obj, BluetoothLEAdvertiseData* out) { LoggerD("Entered"); - const auto& service_uuids = obj.get("serviceuuids"); + const auto& service_uuids = obj.get("uuids"); if (service_uuids.is()) { for (const auto& i : service_uuids.get()) { if (i.is()) { -- 2.7.4 From 68f7df1a50ca9dcef7cd97857794d13c0a448b8c Mon Sep 17 00:00:00 2001 From: Pawel Wasowski Date: Tue, 7 Mar 2017 11:30:43 +0100 Subject: [PATCH 10/16] [Bluetooth] Fix typo in log message format string [Verification] Proper log message appears in sdb dlog. Change-Id: I43ea562f1e90034097f97c2c3a348284112b5f44 Signed-off-by: Pawel Wasowski --- src/bluetooth/bluetooth_gatt_service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth/bluetooth_gatt_service.cc b/src/bluetooth/bluetooth_gatt_service.cc index 1171038..98d0b53 100755 --- a/src/bluetooth/bluetooth_gatt_service.cc +++ b/src/bluetooth/bluetooth_gatt_service.cc @@ -576,7 +576,7 @@ common::PlatformResult BluetoothGATTService::GetServiceAllUuids( void BluetoothGATTService::OnCharacteristicValueChanged( bt_gatt_h characteristic, char* value, int length, void* user_data) { - LoggerD("Entered, characteristic: [%p], len: [d], user_data: [%p]", characteristic, length, user_data); + LoggerD("Entered, characteristic: [%p], len: [%d], user_data: [%p]", characteristic, length, user_data); auto service = static_cast(user_data); -- 2.7.4 From 413b911df17e420f85e3bcb19e5fd61f5811374b Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Tue, 7 Mar 2017 12:38:30 +0100 Subject: [PATCH 11/16] [Common] Added cache for mapping privileges [Feature] Mapped privileges are stored in static map and there is no need to connect to database on each call. This would increase the performance of webapi calls, when performed repeatedly. [Verification] Checking privileges works, checked with chrome console. Privilege TCT 100% passrate. Change-Id: Ie25b636412715e2d1678c9d382d923e4be162256 Signed-off-by: Piotr Kosko --- src/common/tools.cc | 120 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 42 deletions(-) diff --git a/src/common/tools.cc b/src/common/tools.cc index 8a6a3d3..638352f 100644 --- a/src/common/tools.cc +++ b/src/common/tools.cc @@ -266,6 +266,13 @@ PlatformResult CheckAccess(const std::string& privilege) { PlatformResult CheckAccess(const std::vector& privileges) { LoggerD("Enter"); + // Local cache of mapped privilege strings. This routine can be called many times, especially + // during application launch, generating a high overhead of retrieving mapped privileges from + // the underlying databases. This is especially the case since the same mappings can end up + // being retrieved several times. + using MappedPrivilegeCache = std::map>; + static MappedPrivilegeCache mapped_privilege_cache; + std::string api_version; PlatformResult res = common::tools::GetPkgApiVersion(&api_version); if (res.IsError()) { @@ -283,30 +290,45 @@ PlatformResult CheckAccess(const std::vector& privileges) { g_list_free(mapped_glist); }; - input_glist = g_list_append(input_glist, (void*)input_priv.c_str()); - int ret = privilege_manager_get_mapped_privilege_list(api_version.c_str(), - PRVMGR_PACKAGE_TYPE_WRT, - input_glist, - &mapped_glist); - if (ret != PRVMGR_ERR_NONE) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get mapped privilege list"); - } - - LoggerD("Mapped privileges:"); - std::vector mapped_vector; - auto push_elem = [](gpointer data, gpointer user_data) -> void { - if (data && user_data) { - std::vector* mapped_vector = - static_cast*>(user_data); - char* char_data = static_cast(data); - mapped_vector->push_back(char_data); - LoggerD("mapped to: %s", char_data); + std::vector* mapped_vector_ptr = nullptr; + + // Check if mapped privilege is in local cache first + MappedPrivilegeCache::const_iterator it = mapped_privilege_cache.find(input_priv); + if (mapped_privilege_cache.end() == it) { + LoggerD("Mapped privileges - need to be fetched from database"); + // Not in cache - retrieve from underlying databases. + input_glist = g_list_append(input_glist, (void*)input_priv.c_str()); + int ret = privilege_manager_get_mapped_privilege_list(api_version.c_str(), + PRVMGR_PACKAGE_TYPE_WRT, + input_glist, + &mapped_glist); + if (PRVMGR_ERR_NONE != ret) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get mapped privilege list"); } - }; - g_list_foreach (mapped_glist, push_elem, &mapped_vector); - if (!AccessControl::GetInstance().CheckAccess(mapped_vector)){ - for (const auto& mapped_priv : mapped_vector) { + // initialize empty cache vector + mapped_privilege_cache[input_priv] = std::vector(); + LoggerD("Mapped privileges:"); + auto push_elem = [](gpointer data, gpointer user_data) -> void { + if (data && user_data) { + std::vector* mapped_vector = + static_cast*>(user_data); + char* char_data = static_cast(data); + mapped_vector->push_back(char_data); + LoggerD("mapped to: %s", char_data); + } + }; + // fill the vector with data + g_list_foreach (mapped_glist, push_elem, &mapped_privilege_cache[input_priv]); + mapped_vector_ptr = &mapped_privilege_cache[input_priv]; + } else { + // Retrieve from local cache + LoggerD("Mapped privileges already in cache"); + mapped_vector_ptr = (std::vector*) &(it->second); + } + + if (!AccessControl::GetInstance().CheckAccess(*mapped_vector_ptr)){ + for (const auto& mapped_priv : *mapped_vector_ptr) { LoggerD("Access to privilege: %s has been denied.", mapped_priv.c_str()); } return PlatformResult(ErrorCode::SECURITY_ERR, "Permission denied"); @@ -318,6 +340,12 @@ PlatformResult CheckAccess(const std::vector& privileges) { PlatformResult GetPkgApiVersion(std::string* api_version) { LoggerD("Entered"); + // Local cache of API version string. This can be expensive to retrieve from + // underlying databases and this routine can be called many times during + // application launch. + static std::string cached_api_version; + static int cached_pid = -1; + char* app_id = nullptr; char* pkgid = nullptr; char* api_ver = nullptr; @@ -340,32 +368,40 @@ PlatformResult GetPkgApiVersion(std::string* api_version) { }; pid_t pid = getpid(); - int ret = app_manager_get_app_id(pid, &app_id); - if (ret != APP_MANAGER_ERROR_NONE) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get app id"); - } + if (cached_pid == pid) { + *api_version = cached_api_version; // Retrieve from local cache + } else { + int ret = app_manager_get_app_id(pid, &app_id); + if (ret != APP_MANAGER_ERROR_NONE) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get app id"); + } - ret = app_info_create(app_id, &app_handle); - if (ret != APP_MANAGER_ERROR_NONE) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get app info"); - } + ret = app_info_create(app_id, &app_handle); + if (ret != APP_MANAGER_ERROR_NONE) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get app info"); + } - ret = app_info_get_package(app_handle, &pkgid); - if ((ret != APP_MANAGER_ERROR_NONE) || (pkgid == nullptr)) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get pkg id"); - } + ret = app_info_get_package(app_handle, &pkgid); + if ((ret != APP_MANAGER_ERROR_NONE) || (pkgid == nullptr)) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get pkg id"); + } - ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, getuid(), &pkginfo_handle); - if (ret != PMINFO_R_OK) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get pkginfo_h"); - } + ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, getuid(), &pkginfo_handle); + if (ret != PMINFO_R_OK) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get pkginfo_h"); + } + + ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo_handle, &api_ver); + if (ret != PMINFO_R_OK) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get api version"); + } + + cached_api_version = api_ver; // Save in local cache + cached_pid = pid; - ret = pkgmgrinfo_pkginfo_get_api_version(pkginfo_handle, &api_ver); - if (ret != PMINFO_R_OK) { - return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Fail to get api version"); + *api_version = api_ver; } - *api_version = api_ver; return PlatformResult(ErrorCode::NO_ERROR); } -- 2.7.4 From a3816b0c239d3ad3f4c78b5c43acd29124eddd24 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 8 Mar 2017 08:52:10 +0100 Subject: [PATCH 12/16] [Download] Fix in onFailed cleaning resources [Feature] missing unregistration was added [Verification] TCT passrate 100%. Change-Id: I363d1bf41496f05128620c3d00c9f0cb2ac839b0 Signed-off-by: Piotr Kosko --- src/download/download_instance.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/download/download_instance.cc b/src/download/download_instance.cc index eeb071b..0950619 100755 --- a/src/download/download_instance.cc +++ b/src/download/download_instance.cc @@ -443,7 +443,17 @@ gboolean DownloadInstance::OnFailed(void* user_data) { ("download_get_error error: %d (%s)", error, get_error_message(error))); } - int ret = download_destroy(diPtr->download_id); + int ret = download_unset_state_changed_cb(diPtr->download_id); + if (ret != DOWNLOAD_ERROR_NONE) { + LoggerE("%s", get_error_message(ret)); + } + + ret = download_unset_progress_cb(diPtr->download_id); + if (ret != DOWNLOAD_ERROR_NONE) { + LoggerE("%s", get_error_message(ret)); + } + + ret = download_destroy(diPtr->download_id); if (DOWNLOAD_ERROR_NONE != ret) { LoggerE("%s", get_error_message(ret)); } -- 2.7.4 From 85751b0e0b5268b9bd8b1d43c7441afd2b7a2048 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 8 Mar 2017 11:31:28 +0100 Subject: [PATCH 13/16] [version] 1.76 Change-Id: I13301870fffc46da89e2ade6331798d617e0f500 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index ddeb8ce..456b61c 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.75 +Version: 1.76 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 18afa4ce89f133e378f7e0bb0f26b4b4de9d71d3 Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Mon, 13 Mar 2017 11:31:34 +0100 Subject: [PATCH 14/16] [Alarm] Fixing AlarmRelative/Absolute .period When alarm.period wasn't set by user, tizen.alarm.getAll()/get() should set alarm.period to null, not 0. After adding alarm period is updated. [Verification] TCTs passed 59/1/0/0 Failing test case needs to be fixed Change-Id: I800477b4cefbdfe152b7abb0db750b6713cd0ed3 Signed-off-by: Szymon Jastrzebski --- src/alarm/alarm_api.js | 89 +++++++++++++++++++++++++++++++++++++++++----- src/alarm/alarm_manager.cc | 45 ++++++++++++++++++----- 2 files changed, 117 insertions(+), 17 deletions(-) diff --git a/src/alarm/alarm_api.js b/src/alarm/alarm_api.js index 78f22ad..47725dc 100755 --- a/src/alarm/alarm_api.js +++ b/src/alarm/alarm_api.js @@ -30,6 +30,20 @@ var AlarmManager = function () { }); }; +var EditManager = function() { + this.canEdit = false; +}; + +EditManager.prototype.allow = function() { + this.canEdit = true; +}; + +EditManager.prototype.disallow = function() { + this.canEdit = false; +}; + +var _edit = new EditManager(); + function InternalData_(data) { if (!(this instanceof InternalData_)) { return new InternalData_(data); @@ -90,12 +104,15 @@ AlarmManager.prototype.add = function () { callArgs.type = type; callArgs.seconds = Converter.toString(seconds); + callArgs.isPeriodSet = !T.isNullOrUndefined(args.alarm.period); var result = native.callSync('AlarmManager_add', callArgs); if (native.isFailure(result)) { throw native.getErrorObject(result); } else { + _edit.allow(); UpdateInternalData_(args.alarm, native.getResultObject(result)); + _edit.disallow(); } }; @@ -202,16 +219,38 @@ tizen.AlarmRelative = function(delay, period, internal) { var m_delay = Converter.toLong(delay); if (arguments.length >= 2) { - m_period = Converter.toLong(period, true); + if(!T.isNullOrUndefined(period)){ + m_period = Converter.toLong(period, true); + } } Alarm.call(this, internal); Object.defineProperties(this, { - delay: { value: m_delay, writable: false, enumerable: true}, - period: { value: m_period, writable: false, enumerable: true} + delay: { + get: function() { + return m_delay; + }, + set: function(v) { + if (_edit.canEdit && v) { + m_delay = Converter.toLong(v.delay); + } + }, + enumerable: true + }, + period: { + get: function() { + return m_period; + }, + set: function(v) { + if (_edit.canEdit && v) { + m_period = Converter.toLong(v.period); + } + }, + enumerable: true + } }); -} +}; tizen.AlarmRelative.prototype = new Alarm(); @@ -261,7 +300,9 @@ tizen.AlarmAbsolute = function(date, second, internal) { if(T.isArray(second)){ m_daysOfWeek = second; } else { - m_period = Converter.toLong(second); + if(!T.isNullOrUndefined(second)){ + m_period = Converter.toLong(second); + } } } @@ -271,11 +312,41 @@ tizen.AlarmAbsolute = function(date, second, internal) { } makeDateConst(m_date); Object.defineProperties(this, { - date: { value: m_date, writable: false, enumerable: true}, - period: { value: m_period, writable: false, enumerable: true}, - daysOfTheWeek: { value: m_daysOfWeek, writable: false, enumerable: true} + date: { + get: function() { + return m_date; + }, + set: function(v) { + if (_edit.canEdit && T.isDate(v.date)) { + m_date = v.date; + } + }, + enumerable: true + }, + period: { + get: function() { + return m_period; + }, + set: function(v) { + if (_edit.canEdit && v) { + m_period = Converter.toLong(v.period); + } + }, + enumerable: true + }, + daysOfTheWeek: { + get: function() { + return m_daysOfWeek; + }, + set: function(v) { + if (_edit.canEdit && T.isArray(v.second)) { + m_daysOfWeek = v.second; + } + }, + enumerable: true + } }); -} +}; tizen.AlarmAbsolute.prototype = new Alarm(); diff --git a/src/alarm/alarm_manager.cc b/src/alarm/alarm_manager.cc index 5bc8d84..3dc9f21 100755 --- a/src/alarm/alarm_manager.cc +++ b/src/alarm/alarm_manager.cc @@ -111,6 +111,11 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { app_control_set_app_id(app_control, app_id.c_str()); int alarm_id = 0; + int period = 0; + + // result object + picojson::value result = picojson::value(picojson::object()); + picojson::object& result_obj = result.get(); if (kAlarmRelative == alarm_type) { app_control_add_extra_data(app_control, kAlarmKeyType, kAlarmTypeValueRelative); @@ -124,11 +129,15 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { } int delay = static_cast(it_delay->second.get()); - int period = 0; if (it_period->second.is()) { period = static_cast(it_period->second.get()); } + bool isPeriodSet = false; + if (args.contains("isPeriodSet")) { + isPeriodSet = args.get("isPeriodSet").get(); + } + std::string delay_str = std::to_string(delay); int ret = app_control_add_extra_data(app_control, kAlarmRelativeDelayKey, delay_str.c_str()); if (APP_CONTROL_ERROR_NONE != ret) { @@ -138,7 +147,7 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { return; } - if(period == 0){ + if(!isPeriodSet){ ret = alarm_schedule_once_after_delay(app_control, delay, &alarm_id); }else{ ret = alarm_schedule_after_delay(app_control, delay, period, &alarm_id); @@ -149,6 +158,17 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { ("Error while add alarm to server: %d (%s)", ret, get_error_message(ret))); return; } + + ret = alarm_get_scheduled_period(alarm_id, &period); + if (ALARM_ERROR_NONE != ret) { + LogAndReportError(PlatformResult( + ErrorCode::UNKNOWN_ERR, "Unknown error occurred."), &out, + ("Unknown error occurred: %d (%s)", ret, get_error_message(ret))); + return; + } + if(period != 0){ + result_obj.insert(std::make_pair("period", picojson::value(std::to_string(period)))); + } } else { app_control_add_extra_data(app_control, kAlarmKeyType, kAlarmTypeValueAbsolute); @@ -183,8 +203,17 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { if (alarm.end() != it_period && it_period->second.is()) { app_control_add_extra_data( app_control, kAlarmAbsoluteRecurrenceTypeKey, kAlarmAbsoluteReccurrenceTypeInterval); - int period = static_cast(it_period->second.get()); + period = static_cast(it_period->second.get()); ret = alarm_schedule_at_date(app_control, &start_date, period, &alarm_id); + if (ALARM_ERROR_NONE != ret) { + LogAndReportError(PlatformResult(ErrorCode::UNKNOWN_ERR, "Adding alarm to server failed."), + &out, + ("Adding alarm to server failed: %d (%s)", ret, get_error_message(ret))); + return; + } + + ret = alarm_get_scheduled_period(alarm_id, &period); + result_obj.insert(std::make_pair("period", picojson::value(std::to_string(period)))); } else if (alarm.end() != it_daysOfTheWeek && it_daysOfTheWeek->second.is() && !(it_daysOfTheWeek->second.get()).empty()) { app_control_add_extra_data( @@ -229,10 +258,6 @@ void AlarmManager::Add(const picojson::value& args, picojson::object& out) { } } - // result object - picojson::value result = picojson::value(picojson::object()); - picojson::object& result_obj = result.get(); - result_obj.insert(std::make_pair("id", picojson::value(std::to_string(alarm_id)))); ReportSuccess(result, out); } @@ -397,7 +422,11 @@ PlatformResult AlarmManager::GetAlarm(int id, picojson::object& obj) { obj.insert(std::make_pair("type", picojson::value(kAlarmRelative))); obj.insert(std::make_pair("delay", picojson::value(delay_string))); - obj.insert(std::make_pair("period", picojson::value(std::to_string(interval)))); + if (interval != 0) { + //according to documentation interval will not be lower than 600, + //thus 0 from native means period wasn't set by user + obj.insert(std::make_pair("period", picojson::value(std::to_string(interval)))); + } } else { return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Unknown error occurred."); } -- 2.7.4 From ef728910b19af6576c7f25f21444ffa923aac854 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Mon, 13 Mar 2017 13:19:35 +0100 Subject: [PATCH 15/16] [Filesystem] Fix for writing data with 'w' mode [Feature] If stream is opened with 'w' mode and file exists its content is discarded before writing data. [Verification] Code compiles. TCT (Auto) pass rate 100% Change-Id: I5579b7f17175c39a8bf57b210a2a1ff29c1e7e2e Signed-off-by: Tomasz Marciniak --- src/filesystem/filesystem_file.cc | 11 +++++++++-- src/filesystem/filesystem_file.h | 2 +- src/filesystem/filesystem_instance.cc | 7 ++++++- src/filesystem/filesystem_manager.cc | 3 ++- src/filesystem/filesystem_manager.h | 1 + src/filesystem/js/file_stream.js | 17 ++++++++++++++--- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/filesystem/filesystem_file.cc b/src/filesystem/filesystem_file.cc index fc3d89c..a12047e 100644 --- a/src/filesystem/filesystem_file.cc +++ b/src/filesystem/filesystem_file.cc @@ -218,9 +218,16 @@ bool FilesystemFile::Read(FilesystemBuffer* data, return true; } -bool FilesystemFile::Write(const FilesystemBuffer& data, size_t offset) { +bool FilesystemFile::Write(const FilesystemBuffer& data, size_t offset, bool rewrite) { LoggerD("Enter"); - FILE* file = fopen(path.c_str(), "r+"); + + FILE* file = nullptr; + if (rewrite) { + file = fopen(path.c_str(), "w"); + } else { + file = fopen(path.c_str(), "r+"); + } + if (!file) { LoggerE("Cannot open file %s to write!", path.c_str()); return false; diff --git a/src/filesystem/filesystem_file.h b/src/filesystem/filesystem_file.h index 5779eaf..c7f2ece 100644 --- a/src/filesystem/filesystem_file.h +++ b/src/filesystem/filesystem_file.h @@ -45,7 +45,7 @@ class FilesystemFile { FilesystemFile(const std::string& path_); bool Read(FilesystemBuffer* data, size_t offset, size_t length); - bool Write(const FilesystemBuffer& data, size_t offset); + bool Write(const FilesystemBuffer& data, size_t offset, bool rewrite); }; } // namespace filesystem diff --git a/src/filesystem/filesystem_instance.cc b/src/filesystem/filesystem_instance.cc index 54b0a2e..47ffc97 100644 --- a/src/filesystem/filesystem_instance.cc +++ b/src/filesystem/filesystem_instance.cc @@ -216,11 +216,13 @@ void FilesystemInstance::FileWrite(const picojson::value& args, CHECK_EXIST(args, "location", out) CHECK_EXIST(args, "data", out) CHECK_EXIST(args, "offset", out) + CHECK_EXIST(args, "rewrite", out) double callback_id = args.get("callbackId").get(); const std::string& location = args.get("location").get(); const std::string& data = args.get("data").get(); size_t offset = static_cast(args.get("location").get()); + bool rewrite = static_cast(args.get("rewrite").get()); auto onSuccess = [this, callback_id]() { LoggerD("enter"); @@ -247,6 +249,7 @@ void FilesystemInstance::FileWrite(const picojson::value& args, location, data, offset, + rewrite, onSuccess, onError)); } @@ -258,10 +261,12 @@ void FilesystemInstance::FileWriteSync(const picojson::value& args, CHECK_EXIST(args, "location", out) CHECK_EXIST(args, "data", out) CHECK_EXIST(args, "offset", out) + CHECK_EXIST(args, "rewrite", out) const std::string& location = args.get("location").get(); const std::string& data = args.get("data").get(); size_t offset = static_cast(args.get("offset").get()); + bool rewrite = static_cast(args.get("rewrite").get()); auto onSuccess = [this, &out]() { LoggerD("enter"); @@ -274,7 +279,7 @@ void FilesystemInstance::FileWriteSync(const picojson::value& args, }; FilesystemManager::GetInstance().FileWrite( - location, data, offset, onSuccess, onError); + location, data, offset, rewrite, onSuccess, onError); } void FilesystemInstance::FileStat(const picojson::value& args, diff --git a/src/filesystem/filesystem_manager.cc b/src/filesystem/filesystem_manager.cc index 468a095..dc96e58 100644 --- a/src/filesystem/filesystem_manager.cc +++ b/src/filesystem/filesystem_manager.cc @@ -412,6 +412,7 @@ void FilesystemManager::FileWrite( const std::string& path, const std::string& data, size_t offset, + bool rewrite, const std::function& success_cb, const std::function& error_cb) { @@ -425,7 +426,7 @@ void FilesystemManager::FileWrite( return; } - if (file.Write(buffer, offset)) { + if (file.Write(buffer, offset, rewrite)) { success_cb(); } else { LoggerE("Cannot write to file %s!", path.c_str()); diff --git a/src/filesystem/filesystem_manager.h b/src/filesystem/filesystem_manager.h index d455ed9..b2060fb 100644 --- a/src/filesystem/filesystem_manager.h +++ b/src/filesystem/filesystem_manager.h @@ -101,6 +101,7 @@ class FilesystemManager { void FileWrite(const std::string& path, const std::string& data, size_t offset, + bool rewrite, const std::function& success_cb, const std::function& error_cb); diff --git a/src/filesystem/js/file_stream.js b/src/filesystem/js/file_stream.js index 1d3f708..221f87e 100644 --- a/src/filesystem/js/file_stream.js +++ b/src/filesystem/js/file_stream.js @@ -68,6 +68,11 @@ function FileStream(data, mode, encoding) { value: false, writable: true, enumerable: false + }, + _rewrite: { + value: mode === 'w' ? true : false, + writable: true, + enumerable: false } }); } @@ -277,7 +282,8 @@ function write() { var data = { location: commonFS_.toRealPath(this._file.fullPath), offset: this.position, - data: Base64.encodeString(args.stringData) + data: Base64.encodeString(args.stringData), + rewrite: this._rewrite }; var result = native_.callSync('File_writeSync', data); @@ -288,6 +294,7 @@ function write() { can_change_size = true; this.position = this.position + args.stringData.length; can_change_size = false; + this._rewrite = false; }; FileStream.prototype.write = function() { @@ -314,7 +321,8 @@ function writeBytes() { var data = { location: commonFS_.toRealPath(this._file.fullPath), offset: this.position, - data: Base64.encode(args.byteData) + data: Base64.encode(args.byteData), + rewrite: this._rewrite }; var result = native_.callSync('File_writeSync', data); @@ -325,6 +333,7 @@ function writeBytes() { can_change_size = true; this.position = this.position + args.byteData.length; can_change_size = false; + this._rewrite = false; }; FileStream.prototype.writeBytes = function() { @@ -359,7 +368,8 @@ function writeBase64() { var data = { location: commonFS_.toRealPath(this._file.fullPath), offset: this.position, - data: args.base64Data + data: args.base64Data, + rewrite: this._rewrite }; var result = native_.callSync('File_writeSync', data); @@ -373,6 +383,7 @@ function writeBase64() { can_change_size = true; this.position += decoded.length; can_change_size = false; + this._rewrite = false; }; FileStream.prototype.writeBase64 = function() { -- 2.7.4 From cbcc7502c457b34a73a69ba6a82ab6a9621288d3 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 15 Mar 2017 07:58:38 +0100 Subject: [PATCH 16/16] [version] 1.77 Change-Id: Ic2142cc6efbf4a3d7292b8e779bca13adb31eecd Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 456b61c..4b722c8 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.76 +Version: 1.77 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4