From 8dd4ffb00c51fcc7d0af5314b96970bd792140d4 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Tue, 8 Nov 2016 16:36:53 +0900 Subject: [PATCH] 1. Add dispose of LocationBoundary 2. Remove None method type Change-Id: Icbd07c12b1dff5d42aaeed01bbc04ef5b97a8559 Signed-off-by: kj7.sung --- Tizen.Location/Interop/Interop.Location.cs | 4 +- Tizen.Location/Tizen.Location/Location.cs | 52 +++++++++++----------- Tizen.Location/Tizen.Location/LocationBoundary.cs | 43 +++++++++++++++++- Tizen.Location/Tizen.Location/Locator.cs | 2 +- .../Tizen.Location/LocatorEnumerations.cs | 3 +- 5 files changed, 72 insertions(+), 32 deletions(-) diff --git a/Tizen.Location/Interop/Interop.Location.cs b/Tizen.Location/Interop/Interop.Location.cs index 44ef576..9998fbf 100755 --- a/Tizen.Location/Interop/Interop.Location.cs +++ b/Tizen.Location/Interop/Interop.Location.cs @@ -142,7 +142,7 @@ internal static partial class Interop public static extern bool IsValidCoordinates(IntPtr handle, Coordinate coordinate); [DllImport(Libraries.Location, EntryPoint = "location_bounds_destroy")] - public static extern bool DestroyBoundary(IntPtr handle); + public static extern int DestroyBoundary(IntPtr handle); } internal static partial class GpsSatellite @@ -175,4 +175,4 @@ internal static partial class Interop return dateTime; } -} \ No newline at end of file +} diff --git a/Tizen.Location/Tizen.Location/Location.cs b/Tizen.Location/Tizen.Location/Location.cs index f57f53d..15604be 100755 --- a/Tizen.Location/Tizen.Location/Location.cs +++ b/Tizen.Location/Tizen.Location/Location.cs @@ -25,12 +25,12 @@ namespace Tizen.Location /// public class Location { - private double _altitude; private double _latitude; private double _longitude; + private double _altitude; + private double _horizontal; private double _direction; private double _speed; - private double _horizontal; internal int _timestamp; /// @@ -62,92 +62,92 @@ namespace Tizen.Location } /// - /// The current altitude (meters). + /// The current latitude [-90.0 ~ 90.0] (degrees). /// - public double Altitude + public double Latitude { get { - return _altitude; + return _latitude; } set { - _altitude = value; + _latitude = value; } } /// - /// The current latitude [-90.0 ~ 90.0] (degrees). + /// The current longitude [-180.0 ~ 180.0] (degrees). /// - public double Latitude + public double Longitude { get { - return _latitude; + return _longitude; } set { - _latitude = value; + _longitude = value; } } /// - /// The current longitude [-180.0 ~ 180.0] (degrees). + /// The current altitude (meters). /// - public double Longitude + public double Altitude { get { - return _longitude; + return _altitude; } set { - _longitude = value; + _altitude = value; } } /// - /// The direction, degrees from the north. + /// The horizontal accuracy. /// - public double Direction + public double HorizontalAccuracy { get { - return _direction; + return _horizontal; } set { - _direction = value; + _horizontal = value; } } /// - /// The Device Speed (km/h). + /// The direction, degrees from the north. /// - public double Speed + public double Direction { get { - return _speed; + return _direction; } set { - _speed = value; + _direction = value; } } /// - /// The horizontal accuracy. + /// The Device Speed (km/h). /// - public double HorizontalAccuracy + public double Speed { get { - return _horizontal; + return _speed; } set { - _horizontal = value; + _speed = value; } } diff --git a/Tizen.Location/Tizen.Location/LocationBoundary.cs b/Tizen.Location/Tizen.Location/LocationBoundary.cs index 5e5aca5..d89e886 100755 --- a/Tizen.Location/Tizen.Location/LocationBoundary.cs +++ b/Tizen.Location/Tizen.Location/LocationBoundary.cs @@ -23,15 +23,25 @@ namespace Tizen.Location /// /// Abstract class which provides functions related to geographic bounds information. /// - public abstract class LocationBoundary + public abstract class LocationBoundary : IDisposable { internal IntPtr handle; + private bool _disposed = false; /// /// Gets the location boundary type. /// public BoundaryType BoundaryType{ get; internal set; } + /// + /// The destructor of LocationBoundary class. + /// + ~LocationBoundary() + { + Log.Info(Globals.LogTag, "The destructor of LocationBoundary class"); + Dispose(false); + } + internal IntPtr GetHandle() { return handle; @@ -47,6 +57,37 @@ namespace Tizen.Location Log.Info(Globals.LogTag, "Checking if coordinates are contained within boundary"); return Interop.LocationBoundary.IsValidCoordinates(handle, coordinate); } + + /// + /// The overidden Dispose method of the IDisposable class. + /// + public void Dispose() + { + Log.Info(Globals.LogTag, "Dispose"); + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + Log.Info(Globals.LogTag, "Dispose"); + if (_disposed) + return; + + DestroyHandle(); + _disposed = true; + } + + private void DestroyHandle() + { + Log.Info(Globals.LogTag, "DestroyHandle"); + int ret = Interop.LocationBoundary.DestroyBoundary(handle); + if (((LocationError)ret != LocationError.None)) + { + Log.Error(Globals.LogTag, "Error in DestroyBoundary handle" + (LocationError)ret); + throw LocationErrorFactory.ThrowLocationException(ret); + } + } } /// diff --git a/Tizen.Location/Tizen.Location/Locator.cs b/Tizen.Location/Tizen.Location/Locator.cs index d95f6e3..0a21100 100755 --- a/Tizen.Location/Tizen.Location/Locator.cs +++ b/Tizen.Location/Tizen.Location/Locator.cs @@ -276,7 +276,7 @@ namespace Tizen.Location int ret = Interop.Locator.SetMockLocation(_handle, location.Latitude, location.Longitude, location.Altitude, location.Speed, location.Direction, location.HorizontalAccuracy); if (((LocationError)ret == LocationError.None)) { - _location.Altitude = 0; + _location.Altitude = location.Altitude; _location.Latitude = location.Latitude; _location.Longitude = location.Longitude; _location.Speed = location.Speed; diff --git a/Tizen.Location/Tizen.Location/LocatorEnumerations.cs b/Tizen.Location/Tizen.Location/LocatorEnumerations.cs index 5ab9e1d..95c6725 100755 --- a/Tizen.Location/Tizen.Location/LocatorEnumerations.cs +++ b/Tizen.Location/Tizen.Location/LocatorEnumerations.cs @@ -33,8 +33,7 @@ namespace Tizen.Location /// public enum LocationType { - None = -1, /**