From 9c27aea59399cdc194ecdecd382fcfbc47feb4cb Mon Sep 17 00:00:00 2001 From: sovalin <40753917+sovalin@users.noreply.github.com> Date: Mon, 15 Apr 2019 12:11:05 +0530 Subject: [PATCH] [Location]Modified Stop() for StopBatch() functionality (#775) * Modified code for StopBatch() Signed-off-by: Susnata Sovalin * Modified code for StopBatch() Signed-off-by: Susnata Sovalin * Modified code for StopBatch() Signed-off-by: Susnata Sovalin * Modified code for StopBatch() Signed-off-by: Susnata Sovalin --- src/Tizen.Location/Tizen.Location/Locator.cs | 26 +++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Tizen.Location/Tizen.Location/Locator.cs b/src/Tizen.Location/Tizen.Location/Locator.cs index 8a0c76468..cfc54c11e 100755 --- a/src/Tizen.Location/Tizen.Location/Locator.cs +++ b/src/Tizen.Location/Tizen.Location/Locator.cs @@ -43,6 +43,7 @@ namespace Tizen.Location private double _distance = 120.0; private bool _isEnableMock = false; private bool _disposed = false; + private bool _isBatchStarted; private IntPtr _handle; private LocationType _locationType; private Location _location = null; @@ -321,7 +322,8 @@ namespace Tizen.Location public void Start() { Log.Info(Globals.LogTag, "Starting Location Manager"); - if (_batchPeriod > 0 && _batchPeriod > _batchInterval) + _isBatchStarted = (_batchPeriod > 0 ) && (_batchPeriod > _batchInterval); + if (_isBatchStarted) { int ret = Interop.Locator.StartBatch(_handle); if (((LocationError)ret != LocationError.None)) @@ -352,13 +354,25 @@ namespace Tizen.Location public void Stop() { Log.Info(Globals.LogTag, "Stopping Location Manager"); - int ret = Interop.Locator.Stop(_handle); - if (((LocationError)ret != LocationError.None)) + if (_isBatchStarted) { - Log.Error(Globals.LogTag, "Error stopping Location Manager," + (LocationError)ret); - throw LocationErrorFactory.ThrowLocationException(ret); + int ret = Interop.Locator.StopBatch(_handle); + if (((LocationError)ret != LocationError.None)) + { + Log.Error(Globals.LogTag, "Error Stopping Location Batch mode," + (LocationError)ret); + throw LocationErrorFactory.ThrowLocationException(ret); + } } - } + else + { + int ret = Interop.Locator.Stop(_handle); + if (((LocationError)ret != LocationError.None)) + { + Log.Error(Globals.LogTag, "Error stopping Location Manager," + (LocationError)ret); + throw LocationErrorFactory.ThrowLocationException(ret); + } + } + } /// /// Sets a mock location for the given location method. -- 2.34.1