From bd26a893e409ab173a15a166ca362add507eab2c Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 19 Oct 2016 02:39:27 +0900 Subject: [PATCH] csapi-sensor: check feature value if sensor is supported or not - it checks the feature value which is in model-config Change-Id: I41158fee8cfb3dc46a9a57b96551d5ba032520e4 Signed-off-by: kibak.yoon --- .../Tizen.System.Sensor.Net45.project.json | 5 +++-- .../Tizen.System.Sensor.project.json | 3 ++- .../Tizen.System.Sensor/Plugins/Accelerometer.cs | 15 ++------------ .../Plugins/FaceDownGestureDetector.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/GravitySensor.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/Gyroscope.cs | 16 +++------------ .../Plugins/GyroscopeRotationVectorSensor.cs | 16 +++------------ .../Plugins/HeartRateMonitor.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/HumiditySensor.cs | 16 +++------------ .../Plugins/InVehicleActivityDetector.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/LightSensor.cs | 16 +++------------ .../Plugins/LinearAccelerationSensor.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/Magnetometer.cs | 16 +++------------ .../Plugins/MagnetometerRotationVectorSensor.cs | 4 +++- .../Plugins/OrientationSensor.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/Pedometer.cs | 16 +++------------ .../Plugins/PickUpGestureDetector.cs | 4 +++- .../Tizen.System.Sensor/Plugins/PressureSensor.cs | 15 +++----------- .../Tizen.System.Sensor/Plugins/ProximitySensor.cs | 16 +++------------ .../Plugins/RotationVectorSensor.cs | 16 +++------------ .../Plugins/RunningActivityDetector.cs | 16 +++------------ .../Tizen.System.Sensor/Plugins/SleepMonitor.cs | 15 +++----------- .../Plugins/StationaryActivityDetector.cs | 16 +++------------ .../Plugins/TemperatureSensor.cs | 15 +++----------- .../Plugins/UltravioletSensor.cs | 15 +++----------- .../Plugins/UncalibratedGyroscope.cs | 16 +++------------ .../Plugins/UncalibratedMagnetometer.cs | 16 +++------------ .../Plugins/WalkingActivityDetector.cs | 16 +++------------ .../Plugins/WristUpGestureDetector.cs | 16 +++------------ Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs | 23 +++++++++++++++++++++- packaging/csapi-system-sensor.spec | 1 + 31 files changed, 108 insertions(+), 327 deletions(-) mode change 100644 => 100755 Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json b/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json old mode 100644 new mode 100755 index ab1a0ee..503a8ff --- a/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json +++ b/Tizen.System.Sensor/Tizen.System.Sensor.Net45.project.json @@ -1,6 +1,7 @@ { "dependencies": { - "Tizen": "1.0.1" + "Tizen": "1.0.1", + "Tizen.System": "1.0.2" }, "frameworks": { "net45": {} @@ -8,4 +9,4 @@ "runtimes": { "win": {} } -} +} \ No newline at end of file diff --git a/Tizen.System.Sensor/Tizen.System.Sensor.project.json b/Tizen.System.Sensor/Tizen.System.Sensor.project.json index db7436c..5abf875 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor.project.json +++ b/Tizen.System.Sensor/Tizen.System.Sensor.project.json @@ -1,7 +1,8 @@ { "dependencies": { "NETStandard.Library": "1.6.0", - "Tizen": "1.0.1" + "Tizen": "1.0.1", + "Tizen.System": "1.0.2" }, "frameworks": { "netstandard1.3": {} diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs index f583f1e..cdc01bc 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Accelerometer.cs @@ -15,6 +15,7 @@ namespace Tizen.System.Sensor /// /// public class Accelerometer : Sensor { + private static string AccelerometerKey = "http://tizen.org/feature/sensor.accelerometer"; /// /// Gets the X component of the acceleration. /// @@ -38,7 +39,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the Accelerometer sensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.Accelerometer, AccelerometerKey); } } @@ -76,18 +77,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.Accelerometer, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if accelerometer sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs index 88ed660..2433b43 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/FaceDownGestureDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class FaceDownGestureDetector : Sensor { + private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; + /// /// Gets the state of the face down gesture. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the face down gesture detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.FaceDownGestureDetector, GestureDetectorKey); } } @@ -60,18 +62,6 @@ namespace Tizen.System.Sensor return SensorType.FaceDownGestureDetector; } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.FaceDownGestureDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if face down gesture detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs index def7954..1ce4212 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GravitySensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class GravitySensor : Sensor { + private const string GravitySensorKey = "http://tizen.org/feature/sensor.gravity"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the gravity. @@ -39,7 +41,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the GravitySensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.GravitySensor, GravitySensorKey); } } @@ -100,18 +102,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.GravitySensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if gravity sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs index 44dab8b..4766d4c 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Gyroscope.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class Gyroscope : Sensor { + private const string GyroscopeKey = "http://tizen.org/feature/sensor.gyroscope"; + /// /// Gets the X component of the acceleration. /// @@ -38,7 +40,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the Gyroscope sensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.Gyroscope, GyroscopeKey); } } @@ -76,18 +78,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.Gyroscope, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if gyroscope sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs index cc0a106..4e73e3e 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/GyroscopeRotationVectorSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class GyroscopeRotationVectorSensor : Sensor { + private const string GyroscopeRVKey = "http://tizen.org/feature/sensor.gyroscope_rotation_vector"; + /// /// Gets the X component of the gyroscope rotation vector. /// @@ -48,7 +50,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the GyroscopeRotationVectorSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.GyroscopeRotationVectorSensor, GyroscopeRVKey); } } @@ -86,18 +88,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.GyroscopeRotationVectorSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if gyroscope rotation vector sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs index 3cb37b1..c9da6ce 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HeartRateMonitor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class HeartRateMonitor : Sensor { + private const string HRMKey = "http://tizen.org/feature/sensor.heart_rate_monitor"; + /// /// Gets the value of the heart rate monitor. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the HeartRateMonitor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.HeartRateMonitor, HRMKey); } } @@ -66,18 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.HeartRateMonitor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if heart rate monitor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs index cb0dced..27cd506 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/HumiditySensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class HumiditySensor : Sensor { + private const string HumiditySensorKey = "http://tizen.org/feature/sensor.humidity"; + /// /// Gets the value of the humidity sensor. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the HumiditySensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.HumiditySensor, HumiditySensorKey); } } @@ -66,18 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.HumiditySensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if humidity sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs index 0f1f63e..7fec0e7 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/InVehicleActivityDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class InVehicleActivityDetector : ActivityDetector { + private const string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + /// /// Gets the state of in-vehicle activity detector /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the in-vehicle activity detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.InVehicleActivityDetector, ActivityDetectorKey); } } @@ -56,18 +58,6 @@ namespace Tizen.System.Sensor Log.Info(Globals.LogTag, "Creating in-vehicle activity detector object"); } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.InVehicleActivityDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if in-vehicle activity detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs index edc401c..43eee56 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LightSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class LightSensor : Sensor { + private const string LightSensorKey = "http://tizen.org/feature/sensor.photometer"; + /// /// Gets the Level of the light. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the LightSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.LightSensor, LightSensorKey); } } @@ -66,18 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.LightSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if light sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs index 6ca09e4..484181a 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/LinearAccelerationSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class LinearAccelerationSensor : Sensor { + private const string LinearAccelerationSensorKey = "http://tizen.org/feature/sensor.linear_acceleration"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the linear acceleration. @@ -39,7 +41,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the LinearAccelerationSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.LinearAccelerationSensor, LinearAccelerationSensorKey); } } @@ -100,18 +102,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.LinearAccelerationSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if linear acceleration sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs index 33e7eea..06967e9 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Magnetometer.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class Magnetometer : Sensor { + private static string MagnetometerKey = "http://tizen.org/feature/sensor.magnetometer"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the magnetometer. @@ -39,7 +41,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the Magnetometer is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.Magnetometer, MagnetometerKey); } } @@ -100,18 +102,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.Magnetometer, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if magnetometer is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs index 0987d7f..aeff39f 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/MagnetometerRotationVectorSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class MagnetometerRotationVectorSensor : Sensor { + private static string MagnetometerRVKey = "http://tizen.org/feature/sensor.geomagnetic_rotation_vector"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the magnetometer rotation vector. @@ -49,7 +51,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the MagnetometerRotationVectorSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.MagnetometerRotationVectorSensor, MagnetometerRVKey); } } diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs index 682db09..4586b13 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/OrientationSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class OrientationSensor : Sensor { + private static string OrientationSensorKey = "http://tizen.org/feature/sensor.tiltmeter"; + private event EventHandler _accuracyChanged; /// /// Gets the Azimuth component of the orientation. @@ -39,7 +41,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the OrientationSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.OrientationSensor, OrientationSensorKey); } } @@ -100,18 +102,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.OrientationSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if orientation sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs index d399f2c..5e9f611 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/Pedometer.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class Pedometer : Sensor { + private static string PedometerKey = "http://tizen.org/feature/sensor.pedometer"; + /// /// Gets the step count /// @@ -63,7 +65,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the Pedometer sensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.Pedometer, PedometerKey); } } @@ -101,18 +103,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.Pedometer, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if pedometer sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs index 48ba166..254cfed 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PickUpGestureDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class PickUpGestureDetector : Sensor { + private static string GestureDetectorKey = "http://tizen.org/feature/sensor.gesture_recognition"; + /// /// Gets the state of the pick up gesture. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the pick up gesture detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.PickUpGestureDetector, GestureDetectorKey); } } diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs index aa24f71..557cd8f 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/PressureSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class PressureSensor : Sensor { + private static string PressureSensorKey = "http://tizen.org/feature/sensor.barometer"; + /// /// Gets the value of the pressure sensor. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the PressureSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.PressureSensor, PressureSensorKey); } } @@ -66,17 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.PressureSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if pressure sensor is supported"); - isSupported = false; - } - return isSupported; - } private static int GetCount() { diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs index 55b0a28..58a8943 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/ProximitySensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class ProximitySensor : Sensor { + private static string ProximitySensorKey = "http://tizen.org/feature/sensor.proximity"; + /// /// Gets the proximity state. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the ProximitySensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.ProximitySensor, ProximitySensorKey); } } @@ -66,18 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.ProximitySensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if proximity sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs index 55505ee..10e6899 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RotationVectorSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class RotationVectorSensor : Sensor { + private static string RotationVectorKey = "http://tizen.org/feature/sensor.rotation_vector"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the rotation vector. @@ -49,7 +51,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the RotationVectorSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.RotationVectorSensor, RotationVectorKey); } } @@ -110,18 +112,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.RotationVectorSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if rotation vector sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs index 25b5e17..a799ace 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/RunningActivityDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class RunningActivityDetector : ActivityDetector { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + /// /// Gets the state of running activity detector /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the running activity detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.RunningActivityDetector, ActivityDetectorKey); } } @@ -56,18 +58,6 @@ namespace Tizen.System.Sensor Log.Info(Globals.LogTag, "Creating running activity detector object"); } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.RunningActivityDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if running activity detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs index cdb2d5c..9d6ea16 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/SleepMonitor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class SleepMonitor : Sensor { + private static string SleepMonitorKey = "http://tizen.org/feature/sensor.sleep_monitor"; + /// /// Gets the value of the sleep state. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the SleepMonitor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.SleepMonitor, SleepMonitorKey); } } @@ -66,17 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.SleepMonitor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if sleep monitor is supported"); - isSupported = false; - } - return isSupported; - } private static int GetCount() { diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs index cfa41be..ecfff67 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/StationaryActivityDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class StationaryActivityDetector : ActivityDetector { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + /// /// Gets the state of stationary activity detector /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the stationary activity detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.StationaryActivityDetector, ActivityDetectorKey); } } @@ -56,18 +58,6 @@ namespace Tizen.System.Sensor Log.Info(Globals.LogTag, "Creating stationary activity detector object"); } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.StationaryActivityDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if stationary activity detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs index 3be658c..6f3df1b 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/TemperatureSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class TemperatureSensor : Sensor { + private static string TemperatureSensorKey = "http://tizen.org/feature/sensor.temperature"; + /// /// Gets the value of the temperature sensor. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the TemperatureSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.TemperatureSensor, TemperatureSensorKey); } } @@ -66,17 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.TemperatureSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if temperature sensor is supported"); - isSupported = false; - } - return isSupported; - } private static int GetCount() { diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs index 40d21cd..03c9d0a 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UltravioletSensor.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class UltravioletSensor : Sensor { + private static string UltravioletSensorKey = "http://tizen.org/feature/sensor.ultraviolet"; + /// /// Gets the value of the ultraviolet sensor. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the UltravioletSensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.UltravioletSensor, UltravioletSensorKey); } } @@ -66,17 +68,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.UltravioletSensor, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if ultraviolet sensor is supported"); - isSupported = false; - } - return isSupported; - } private static int GetCount() { diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs index 8a092c1..c712d83 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedGyroscope.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class UncalibratedGyroscope : Sensor { + private static string UncalibratedGyroscopeKey = "http://tizen.org/feature/sensor.gyroscope.uncalibrated"; + /// /// Gets the X component of the acceleration. /// @@ -53,7 +55,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the UncalibratedGyroscope sensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.UncalibratedGyroscope, UncalibratedGyroscopeKey); } } @@ -91,18 +93,6 @@ namespace Tizen.System.Sensor public event EventHandler DataUpdated; - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.UncalibratedGyroscope, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if uncalibrated gyroscope sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs index fb3eb6f..24b080f 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/UncalibratedMagnetometer.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// /// public class UncalibratedMagnetometer : Sensor { + private static string UncalibratedMagnetometerKey = "http://tizen.org/feature/sensor.magnetometer.uncalibrated"; + private event EventHandler _accuracyChanged; /// /// Gets the X component of the acceleration. @@ -54,7 +56,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the UncalibratedMagnetometer sensor is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.UncalibratedMagnetometer, UncalibratedMagnetometerKey); } } @@ -115,18 +117,6 @@ namespace Tizen.System.Sensor } } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.UncalibratedMagnetometer, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if uncalibrated magnetometer sensor is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs index 0560ec8..f4ff0a9 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WalkingActivityDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class WalkingActivityDetector : ActivityDetector { + private static string ActivityDetectorKey = "http://tizen.org/feature/sensor.activity_recognition"; + /// /// Gets the state of walking activity detector /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the walking activity detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.WalkingActivityDetector, ActivityDetectorKey); } } @@ -56,18 +58,6 @@ namespace Tizen.System.Sensor Log.Info(Globals.LogTag, "Creating walking activity gesture detector object"); } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.WalkingActivityDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if walking activity detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs index 2df1a8d..8825709 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Plugins/WristUpGestureDetector.cs @@ -15,6 +15,8 @@ namespace Tizen.System.Sensor /// public class WristUpGestureDetector : Sensor { + private static string WristUpKey = "http://tizen.org/feature/sensor.wrist_up"; + /// /// Gets the state of the wrist up gesture. /// @@ -28,7 +30,7 @@ namespace Tizen.System.Sensor get { Log.Info(Globals.LogTag, "Checking if the wrist up gesture detector is supported"); - return CheckIfSupported(); + return CheckIfSupported(SensorType.WristUpGestureDetector, WristUpKey); } } @@ -60,18 +62,6 @@ namespace Tizen.System.Sensor return SensorType.WristUpGestureDetector; } - private static bool CheckIfSupported() - { - bool isSupported; - int error = Interop.SensorManager.SensorIsSupported(SensorType.WristUpGestureDetector, out isSupported); - if (error != (int)SensorError.None) - { - Log.Error(Globals.LogTag, "Error checking if wrist up gesture detector is supported"); - isSupported = false; - } - return isSupported; - } - private static int GetCount() { IntPtr list; diff --git a/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs index 3ff750e..b43bdb0 100644 --- a/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs +++ b/Tizen.System.Sensor/Tizen.System.Sensor/Sensor.cs @@ -7,7 +7,7 @@ // you entered into with Samsung. using System; - +using Tizen.System; namespace Tizen.System.Sensor { @@ -249,6 +249,27 @@ namespace Tizen.System.Sensor } } + internal static bool CheckIfSupported(SensorType type, String key) + { + bool isSupported = false; + bool error = SystemInfo.TryGetValue(key, out isSupported); + + if (!error || !isSupported) + { + Log.Error(Globals.LogTag, "Error checking if sensor is supported(systeminfo)"); + return false; + } + + int ret = Interop.SensorManager.SensorIsSupported(type, out isSupported); + if (ret != (int)SensorError.None) + { + Log.Error(Globals.LogTag, "Error checking if sensor is supported"); + isSupported = false; + } + + return isSupported; + } + /// /// Starts the sensor. /// After this the event handlers will start receiving events. diff --git a/packaging/csapi-system-sensor.spec b/packaging/csapi-system-sensor.spec index 0ca8547..09c18d6 100644 --- a/packaging/csapi-system-sensor.spec +++ b/packaging/csapi-system-sensor.spec @@ -25,6 +25,7 @@ BuildRequires: dotnet-build-tools # C# API Requries BuildRequires: csapi-tizen-nuget +BuildRequires: csapi-system-nuget %description Tizen Sensor API for C# -- 2.7.4