From 9b9d1a19964d4d0431d5efbdf4ba2aba60879980 Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Tue, 15 Nov 2016 19:26:01 +0900 Subject: [PATCH] csapi-sensor: fix bug about the lifetime of delegate When the callback is passed to the native layer using PInvoke, the lifetime of delegate has to be considered. if the member function is passed to the interop directly, the memory allocated within this function is not managed by the GC. Change-Id: I06ab30b0e62c1f4baba5bcb38dd75f9764a3b0d5 Signed-off-by: kibak.yoon --- .../Tizen.Sensor/Plugins/Accelerometer.cs | 26 ++++++------ .../Tizen.Sensor/Plugins/ActivityDetector.cs | 22 ---------- .../Plugins/FaceDownGestureDetector.cs | 22 +++++----- .../Tizen.Sensor/Plugins/GravitySensor.cs | 41 ++++++++++--------- src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs | 26 ++++++------ .../Plugins/GyroscopeRotationVectorSensor.cs | 30 +++++++------- .../Tizen.Sensor/Plugins/HeartRateMonitor.cs | 22 +++++----- .../Tizen.Sensor/Plugins/HumiditySensor.cs | 22 +++++----- .../Plugins/InVehicleActivityDetector.cs | 34 +++++++++++++--- .../Tizen.Sensor/Plugins/LightSensor.cs | 22 +++++----- .../Plugins/LinearAccelerationSensor.cs | 41 ++++++++++--------- .../Tizen.Sensor/Plugins/Magnetometer.cs | 41 ++++++++++--------- .../Plugins/MagnetometerRotationVectorSensor.cs | 46 +++++++++++---------- .../Tizen.Sensor/Plugins/OrientationSensor.cs | 41 ++++++++++--------- src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs | 36 +++++++++-------- .../Tizen.Sensor/Plugins/PickUpGestureDetector.cs | 22 +++++----- .../Tizen.Sensor/Plugins/PressureSensor.cs | 22 +++++----- .../Tizen.Sensor/Plugins/ProximitySensor.cs | 22 +++++----- .../Tizen.Sensor/Plugins/RotationVectorSensor.cs | 46 +++++++++++---------- .../Plugins/RunningActivityDetector.cs | 34 +++++++++++++--- .../Tizen.Sensor/Plugins/SleepMonitor.cs | 22 +++++----- .../Plugins/StationaryActivityDetector.cs | 34 +++++++++++++--- .../Tizen.Sensor/Plugins/TemperatureSensor.cs | 22 +++++----- .../Tizen.Sensor/Plugins/UltravioletSensor.cs | 22 +++++----- .../Tizen.Sensor/Plugins/UncalibratedGyroscope.cs | 32 ++++++++------- .../Plugins/UncalibratedMagnetometer.cs | 47 ++++++++++++---------- .../Plugins/WalkingActivityDetector.cs | 34 +++++++++++++--- .../Tizen.Sensor/Plugins/WristUpGestureDetector.cs | 22 +++++----- src/Tizen.Sensor/Tizen.Sensor/Sensor.cs | 0 29 files changed, 487 insertions(+), 366 deletions(-) mode change 100755 => 100644 src/Tizen.Sensor/Tizen.Sensor/Sensor.cs diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs index 7b84293..3e18ad8 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Accelerometer.cs @@ -103,9 +103,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for accelerometer sensor"); @@ -122,16 +135,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for accelerometer"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new AccelerometerDataUpdatedEventArgs(sensorData.values)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs index d62d9d3..8e33972 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ActivityDetector.cs @@ -37,30 +37,8 @@ namespace Tizen.Sensor /// public SensorDataAccuracy ActivityAccuracy { get; protected set; } - internal abstract void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data); - internal ActivityDetector(uint index) : base(index) { } - - internal override void EventListenStart() - { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error setting event callback for activity detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for activity detector"); - } - } - - internal override void EventListenStop() - { - int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error unsetting event callback for activity detector"); - throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for activity detector"); - } - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs index 842516e..1902855 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/FaceDownGestureDetector.cs @@ -93,9 +93,20 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + FaceDown = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new FaceDownGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for face down gesture detector"); @@ -112,14 +123,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for face down gesture detector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - FaceDown = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new FaceDownGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs index dd1f4b7..41d90e3 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GravitySensor.cs @@ -128,9 +128,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new GravitySensorDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for gravity sensor"); @@ -148,9 +161,16 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for gravity sensor"); @@ -167,22 +187,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for gravity"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new GravitySensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs index b1b701d..09be0a1 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Gyroscope.cs @@ -104,9 +104,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new GyroscopeDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for gyroscope sensor"); @@ -123,16 +136,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new GyroscopeDataUpdatedEventArgs(sensorData.values)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs index 278bc0e..dfecaab 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/GyroscopeRotationVectorSensor.cs @@ -114,9 +114,24 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + W = sensorData.values[3]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new GyroscopeRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for gyroscope rotation vector sensor"); @@ -133,18 +148,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for gyroscope rotation vector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new GyroscopeRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs index d3f26b7..154abc2 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HeartRateMonitor.cs @@ -98,9 +98,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + HeartRate = (int)sensorData.values[0]; + + DataUpdated?.Invoke(this, new HeartRateMonitorDataUpdatedEventArgs((int)sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for heart rate monitor"); @@ -117,14 +128,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for heart rate"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - HeartRate = (int)sensorData.values[0]; - - DataUpdated?.Invoke(this, new HeartRateMonitorDataUpdatedEventArgs((int)sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs index 60bf89f..0c992e6 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/HumiditySensor.cs @@ -94,9 +94,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Humidity = sensorData.values[0]; + + DataUpdated?.Invoke(this, new HumiditySensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for humidity sensor"); @@ -113,14 +124,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for humidity"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Humidity = sensorData.values[0]; - - DataUpdated?.Invoke(this, new HumiditySensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs index 3e0dcaa..5c35a18 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/InVehicleActivityDetector.cs @@ -89,14 +89,36 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; - internal override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + private static Interop.SensorListener.SensorEventCallback _callback; + + internal override void EventListenStart() { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - InVehicle = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + InVehicle = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new InVehicleActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for invehicle activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for invehicle activity detector"); + } + } - DataUpdated?.Invoke(this, new InVehicleActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + internal override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for invehicle activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for invehicle activity detector"); + } } internal override SensorType GetSensorType() diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs index c27c7e3..fffdfc9 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LightSensor.cs @@ -94,9 +94,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Level = sensorData.values[0]; + + DataUpdated?.Invoke(this, new LightSensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for light sensor"); @@ -113,14 +124,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for light"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Level = sensorData.values[0]; - - DataUpdated?.Invoke(this, new LightSensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs index d82906d..1017506 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/LinearAccelerationSensor.cs @@ -128,9 +128,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new LinearAccelerationSensorDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for linear acceleration sensor"); @@ -148,9 +161,16 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for linear acceleration sensor"); @@ -167,22 +187,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for linear acceleration sensor"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new LinearAccelerationSensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs index df9f04b..a695cf1 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Magnetometer.cs @@ -128,9 +128,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + + DataUpdated?.Invoke(this, new MagnetometerDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for magnetometer"); @@ -148,9 +161,16 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer"); @@ -167,22 +187,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - - DataUpdated?.Invoke(this, new MagnetometerDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs index c92fc78..e033043 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/MagnetometerRotationVectorSensor.cs @@ -150,9 +150,24 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + W = sensorData.values[3]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new MagnetometerRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for magnetometer rotation vector sensor"); @@ -170,9 +185,17 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + Accuracy = accuracy; + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for magnetometer rotation vector sensor"); @@ -189,24 +212,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for magnetometer rotation vector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new MagnetometerRotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - Accuracy = accuracy; - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs index c619811..3488523 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/OrientationSensor.cs @@ -128,9 +128,22 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Azimuth = sensorData.values[0]; + Pitch = sensorData.values[1]; + Roll = sensorData.values[2]; + + DataUpdated?.Invoke(this, new OrientationSensorDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for orientation sensor"); @@ -148,9 +161,16 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for orientation sensor"); @@ -167,22 +187,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for orientation"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Azimuth = sensorData.values[0]; - Pitch = sensorData.values[1]; - Roll = sensorData.values[2]; - - DataUpdated?.Invoke(this, new OrientationSensorDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs index 63ccd2a..48bb1b0 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/Pedometer.cs @@ -133,9 +133,27 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + StepCount = (uint)sensorData.values[0]; + WalkStepCount = (uint)sensorData.values[1]; + RunStepCount = (uint)sensorData.values[2]; + MovingDistance = sensorData.values[3]; + CalorieBurned = sensorData.values[4]; + LastSpeed = sensorData.values[5]; + LastSteppingFrequency = sensorData.values[6]; + LastStepStatus = (PedometerState)sensorData.values[7]; + + DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for pedometer sensor"); @@ -152,21 +170,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pedometer"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - StepCount = (uint)sensorData.values[0]; - WalkStepCount = (uint)sensorData.values[1]; - RunStepCount = (uint)sensorData.values[2]; - MovingDistance = sensorData.values[3]; - CalorieBurned = sensorData.values[4]; - LastSpeed = sensorData.values[5]; - LastSteppingFrequency = sensorData.values[6]; - LastStepStatus = (PedometerState)sensorData.values[7]; - - DataUpdated?.Invoke(this, new PedometerDataUpdatedEventArgs(sensorData.values)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs index ef8661c..486d941 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PickUpGestureDetector.cs @@ -105,9 +105,20 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + PickUp = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new PickUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for pick up gesture detector"); @@ -124,14 +135,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pick up gesture detector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - PickUp = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new PickUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs index ab4e4a7..58ebdb4 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/PressureSensor.cs @@ -95,9 +95,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Pressure = sensorData.values[0]; + + DataUpdated?.Invoke(this, new PressureSensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for pressure sensor"); @@ -114,14 +125,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for pressure"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Pressure = sensorData.values[0]; - - DataUpdated?.Invoke(this, new PressureSensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs index 413992e..a91645b 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/ProximitySensor.cs @@ -94,9 +94,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Proximity = (ProximitySensorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new ProximitySensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for proximity sensor"); @@ -113,14 +124,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for proximity"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Proximity = (ProximitySensorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new ProximitySensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs index 797bbd0..8d0f0f7 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RotationVectorSensor.cs @@ -138,9 +138,24 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + W = sensorData.values[3]; + Accuracy = sensorData.accuracy; + + DataUpdated?.Invoke(this, new RotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for rotation vector sensor"); @@ -158,9 +173,17 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + Accuracy = accuracy; + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for rotation vector sensor"); @@ -177,24 +200,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for rotation vector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - Accuracy = sensorData.accuracy; - - DataUpdated?.Invoke(this, new RotationVectorSensorDataUpdatedEventArgs(sensorData.values, sensorData.accuracy)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - Accuracy = accuracy; - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs index d23f190..fc08d41 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/RunningActivityDetector.cs @@ -89,14 +89,36 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; - internal override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + private static Interop.SensorListener.SensorEventCallback _callback; + + internal override void EventListenStart() { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Running = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Running = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new RunningActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for running activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for running activity detector"); + } + } - DataUpdated?.Invoke(this, new RunningActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + internal override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for running activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for running activity detector"); + } } internal override SensorType GetSensorType() diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs index 79ea10d..ed4b12c 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/SleepMonitor.cs @@ -99,9 +99,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + SleepState = (SleepMonitorState)sensorData.values[0]; + + DataUpdated?.Invoke(this, new SleepMonitorDataUpdatedEventArgs((int)sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for sleep monitor"); @@ -118,14 +129,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for sleep"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - SleepState = (SleepMonitorState)sensorData.values[0]; - - DataUpdated?.Invoke(this, new SleepMonitorDataUpdatedEventArgs((int)sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs index d2193d0..2c42f13 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/StationaryActivityDetector.cs @@ -89,14 +89,36 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; - internal override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + internal static Interop.SensorListener.SensorEventCallback _callback; + + internal override void EventListenStart() { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Stationary = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Stationary = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new StationaryActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for stationary activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for stationary activity detector"); + } + } - DataUpdated?.Invoke(this, new StationaryActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + internal override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for stationary activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for stationary activity detector"); + } } internal override SensorType GetSensorType() diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs index db54a9c..6d3e848 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/TemperatureSensor.cs @@ -95,9 +95,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Temperature = sensorData.values[0]; + + DataUpdated?.Invoke(this, new TemperatureSensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for temperature sensor"); @@ -114,14 +125,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for temperature"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Temperature = sensorData.values[0]; - - DataUpdated?.Invoke(this, new TemperatureSensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs index ca66280..5ab32e4 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UltravioletSensor.cs @@ -95,9 +95,20 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + UltravioletIndex = sensorData.values[0]; + + DataUpdated?.Invoke(this, new UltravioletSensorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for ultraviolet sensor"); @@ -114,14 +125,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for ultraviolet"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - UltravioletIndex = sensorData.values[0]; - - DataUpdated?.Invoke(this, new UltravioletSensorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs index c3f157e..ef10c79 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedGyroscope.cs @@ -119,9 +119,25 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + BiasX = sensorData.values[3]; + BiasY = sensorData.values[4]; + BiasZ = sensorData.values[5]; + + DataUpdated?.Invoke(this, new UncalibratedGyroscopeDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated gyroscope sensor"); @@ -138,19 +154,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for uncalibrated gyroscope"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - BiasX = sensorData.values[3]; - BiasY = sensorData.values[4]; - BiasZ = sensorData.values[5]; - - DataUpdated?.Invoke(this, new UncalibratedGyroscopeDataUpdatedEventArgs(sensorData.values)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs index b17dbe8..350acaa 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/UncalibratedMagnetometer.cs @@ -143,9 +143,25 @@ namespace Tizen.Sensor return count; } + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + X = sensorData.values[0]; + Y = sensorData.values[1]; + Z = sensorData.values[2]; + BiasX = sensorData.values[3]; + BiasY = sensorData.values[4]; + BiasZ = sensorData.values[5]; + + DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for uncalibrated magnetometer sensor"); @@ -163,9 +179,16 @@ namespace Tizen.Sensor } } + private static Interop.SensorListener.SensorAccuracyCallback _accuracyCallback; + private void AccuracyListenStart() { - int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, AccuracyEventCallback, IntPtr.Zero); + _accuracyCallback = (IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) => { + TimeSpan = new TimeSpan((Int64)timestamp); + _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); + }; + + int error = Interop.SensorListener.SetAccuracyCallback(ListenerHandle, _accuracyCallback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting accuracy event callback for uncalibrated magnetometer"); @@ -182,25 +205,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset accuracy event callback for uncalibrated magnetometer"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - X = sensorData.values[0]; - Y = sensorData.values[1]; - Z = sensorData.values[2]; - BiasX = sensorData.values[3]; - BiasY = sensorData.values[4]; - BiasZ = sensorData.values[5]; - - DataUpdated?.Invoke(this, new UncalibratedMagnetometerDataUpdatedEventArgs(sensorData.values)); - } - - private void AccuracyEventCallback(IntPtr sensorHandle, UInt64 timestamp, SensorDataAccuracy accuracy, IntPtr data) - { - TimeSpan = new TimeSpan((Int64)timestamp); - _accuracyChanged?.Invoke(this, new SensorAccuracyChangedEventArgs(new TimeSpan((Int64)timestamp), accuracy)); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs index 8afd9b3..391f3ae 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WalkingActivityDetector.cs @@ -89,14 +89,36 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; - internal override void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) + internal static Interop.SensorListener.SensorEventCallback _callback; + + internal override void EventListenStart() { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - Walking = (DetectorState)sensorData.values[0]; - ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + Walking = (DetectorState)sensorData.values[0]; + ActivityAccuracy = (SensorDataAccuracy) sensorData.accuracy; + + DataUpdated?.Invoke(this, new WalkingActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error setting event callback for walking activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to set event callback for walking activity detector"); + } + } - DataUpdated?.Invoke(this, new WalkingActivityDetectorDataUpdatedEventArgs(sensorData.values[0])); + internal override void EventListenStop() + { + int error = Interop.SensorListener.UnsetEventCallback(ListenerHandle); + if (error != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error unsetting event callback for walking activity detector"); + throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for walking activity detector"); + } } internal override SensorType GetSensorType() diff --git a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs index bcc7cfc..f182c81 100644 --- a/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs +++ b/src/Tizen.Sensor/Tizen.Sensor/Plugins/WristUpGestureDetector.cs @@ -93,9 +93,20 @@ namespace Tizen.Sensor /// public event EventHandler DataUpdated; + private static Interop.SensorListener.SensorEventCallback _callback; + internal override void EventListenStart() { - int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, SensorEventCallback, IntPtr.Zero); + _callback = (IntPtr sensorHandle, IntPtr eventPtr, IntPtr data) => { + Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(eventPtr); + + TimeSpan = new TimeSpan((Int64)sensorData.timestamp); + WristUp = (DetectorState) sensorData.values[0]; + + DataUpdated?.Invoke(this, new WristUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); + }; + + int error = Interop.SensorListener.SetEventCallback(ListenerHandle, Interval, _callback, IntPtr.Zero); if (error != (int)SensorError.None) { Log.Error(Globals.LogTag, "Error setting event callback for wrist up gesture detector"); @@ -112,14 +123,5 @@ namespace Tizen.Sensor throw SensorErrorFactory.CheckAndThrowException(error, "Unable to unset event callback for wrist up gesture detector"); } } - - private void SensorEventCallback(IntPtr sensorHandle, IntPtr sensorPtr, IntPtr data) - { - Interop.SensorEventStruct sensorData = Interop.IntPtrToEventStruct(sensorPtr); - TimeSpan = new TimeSpan((Int64)sensorData.timestamp); - WristUp = (DetectorState) sensorData.values[0]; - - DataUpdated?.Invoke(this, new WristUpGestureDetectorDataUpdatedEventArgs(sensorData.values[0])); - } } } diff --git a/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs b/src/Tizen.Sensor/Tizen.Sensor/Sensor.cs old mode 100755 new mode 100644 -- 2.7.4