From b1cc37aced3e078a0b8b54022e3beb18bc588aa7 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Thu, 23 Feb 2017 19:59:15 +0900 Subject: [PATCH] csharp : location - New feature - Add passive method - Support multi method in one client - Fix mock location Change-Id: Icc52b3e9009d08b6842ca6bed100ceee059fc09d Signed-off-by: kj7.sung --- packaging/csapi-location.spec | 2 +- src/Tizen.Location/Interop/Interop.Location.cs | 6 ++-- src/Tizen.Location/Tizen.Location.project.json | 2 +- src/Tizen.Location/Tizen.Location/Locator.cs | 39 +++++++++++----------- .../Tizen.Location/LocatorEnumerations.cs | 1 + 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/packaging/csapi-location.spec b/packaging/csapi-location.spec index 286c3a4..9bf830a 100755 --- a/packaging/csapi-location.spec +++ b/packaging/csapi-location.spec @@ -1,6 +1,6 @@ Name: csapi-location Summary: Tizen Location API for C# -Version: 1.0.5 +Version: 1.0.6 Release: 1 Group: Development/Libraries License: Apache-2.0 diff --git a/src/Tizen.Location/Interop/Interop.Location.cs b/src/Tizen.Location/Interop/Interop.Location.cs index 39c918e..f890450 100755 --- a/src/Tizen.Location/Interop/Interop.Location.cs +++ b/src/Tizen.Location/Interop/Interop.Location.cs @@ -34,6 +34,9 @@ internal static partial class Interop [DllImport(Libraries.Location, EntryPoint = "location_manager_stop")] internal static extern int Stop(IntPtr handle); + [DllImport(Libraries.Location, EntryPoint = "location_manager_is_enabled_mock_location")] + internal static extern int IsEnabledMock(out bool status); + [DllImport(Libraries.Location, EntryPoint = "location_manager_enable_mock_location")] internal static extern int EnableMock(bool enable); @@ -43,9 +46,6 @@ internal static partial class Interop [DllImport(Libraries.Location, EntryPoint = "location_manager_clear_mock_location")] internal static extern int ClearMock(IntPtr handle); - [DllImport(Libraries.Location, EntryPoint = "location_manager_get_method")] - internal static extern int GetLocationType(IntPtr handle, out LocationType method); - [DllImport(Libraries.Location, EntryPoint = "location_manager_get_location")] internal static extern int GetLocation(IntPtr handle, out double altitude, out double latitude, out double longitude, out double climb, out double direction, out double speed, out int level, out double horizontal, out double vertical, out int timestamp); diff --git a/src/Tizen.Location/Tizen.Location.project.json b/src/Tizen.Location/Tizen.Location.project.json index ed54b3e..dacd88f 100755 --- a/src/Tizen.Location/Tizen.Location.project.json +++ b/src/Tizen.Location/Tizen.Location.project.json @@ -6,4 +6,4 @@ "frameworks": { "netstandard1.3": {} } -} \ No newline at end of file +} diff --git a/src/Tizen.Location/Tizen.Location/Locator.cs b/src/Tizen.Location/Tizen.Location/Locator.cs index 8dd4747..b5c374e 100755 --- a/src/Tizen.Location/Tizen.Location/Locator.cs +++ b/src/Tizen.Location/Tizen.Location/Locator.cs @@ -38,13 +38,12 @@ namespace Tizen.Location private int _stayInterval = 120; private int _requestId = 0; private double _distance = 120.0; - private bool _isEnableMock; + private bool _isEnableMock = false; private bool _disposed = false; private bool _isStarted = false; private IntPtr _handle; private LocationType _locationType; private Location _location = null; - private static Locator s_locatorReference; private Dictionary _callback_map = new Dictionary(); private Interop.LocatorEvent.ServiceStatechangedCallback _serviceStateChangedCallback; @@ -205,6 +204,7 @@ namespace Tizen.Location get { Log.Info(Globals.LogTag, "Getting getting Mock"); + _isEnableMock = GetEnableMock(); return _isEnableMock; } set @@ -219,12 +219,24 @@ namespace Tizen.Location return _handle; } + private bool GetEnableMock() + { + bool status = false; + int ret = Interop.Locator.IsEnabledMock(out status); + if (((LocationError)ret != LocationError.None)) + { + Log.Error(Globals.LogTag, "Error Get Enable Mock Status," + (LocationError)ret); + throw LocationErrorFactory.ThrowLocationException(ret); + } + return status; + } + private void SetEnableMock() { int ret = Interop.Locator.EnableMock(_isEnableMock); if (((LocationError)ret != LocationError.None)) { - Log.Error(Globals.LogTag, "Error Set Enable Mock Type," + (LocationError)ret); + Log.Error(Globals.LogTag, "Error Set Enable Mock Status," + (LocationError)ret); throw LocationErrorFactory.ThrowLocationException(ret); } } @@ -239,23 +251,13 @@ namespace Tizen.Location public void Start() { Log.Info(Globals.LogTag, "Starting Location Manager"); - if (Locator.s_locatorReference == null) - { - int ret = Interop.Locator.Start(_handle); - if (((LocationError)ret != LocationError.None)) - { - Log.Error(Globals.LogTag, "Error Starting Location Manager," + (LocationError)ret); - throw LocationErrorFactory.ThrowLocationException(ret); - } - Locator.s_locatorReference = this; - _isStarted = true; - Log.Info(Globals.LogTag, "Locator reference set"); - } - else + int ret = Interop.Locator.Start(_handle); + if (((LocationError)ret != LocationError.None)) { - Log.Error(Globals.LogTag, "Error, previous instance of Locator should be stopped before starting a new one," + LocationError.NotSupported); - throw LocationErrorFactory.ThrowLocationException((int)LocationError.NotSupported); + Log.Error(Globals.LogTag, "Error Starting Location Manager," + (LocationError)ret); + throw LocationErrorFactory.ThrowLocationException(ret); } + _isStarted = true; } /// @@ -274,7 +276,6 @@ namespace Tizen.Location Log.Error(Globals.LogTag, "Error stopping Location Manager," + (LocationError)ret); throw LocationErrorFactory.ThrowLocationException(ret); } - Locator.s_locatorReference = null; _isStarted = false; } diff --git a/src/Tizen.Location/Tizen.Location/LocatorEnumerations.cs b/src/Tizen.Location/Tizen.Location/LocatorEnumerations.cs index a6da9c4..cb20b8f 100755 --- a/src/Tizen.Location/Tizen.Location/LocatorEnumerations.cs +++ b/src/Tizen.Location/Tizen.Location/LocatorEnumerations.cs @@ -36,6 +36,7 @@ namespace Tizen.Location Hybrid = 0, /** -- 2.7.4