From b44067025dfc198b8ab6926027935cc046697bc9 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Thu, 10 Nov 2016 16:11:53 +0900 Subject: [PATCH] 1. Fix crash issue in destructor 2. Add exceptions for doxygen Change-Id: I19820ccaea06feb1013e9a1e294c4c1097d1e052 Signed-off-by: kj7.sung --- packaging/csapi-location.spec | 2 +- src/Tizen.Location/Tizen.Location/GpsSatellite.cs | 21 ++++++++ src/Tizen.Location/Tizen.Location/Location.cs | 4 ++ .../Tizen.Location/LocationBoundary.cs | 47 ++++++++++++++--- src/Tizen.Location/Tizen.Location/Locator.cs | 61 ++++++++++++++++++++-- src/Tizen.Location/Tizen.Location/LocatorHelper.cs | 3 ++ 6 files changed, 128 insertions(+), 10 deletions(-) diff --git a/packaging/csapi-location.spec b/packaging/csapi-location.spec index ff43c73..7a1301d 100755 --- a/packaging/csapi-location.spec +++ b/packaging/csapi-location.spec @@ -8,7 +8,7 @@ Name: csapi-location Summary: Tizen Location API for C# -Version: 1.0.1 +Version: 1.0.2 Release: 1 Group: Development/Libraries License: Apache-2.0 diff --git a/src/Tizen.Location/Tizen.Location/GpsSatellite.cs b/src/Tizen.Location/Tizen.Location/GpsSatellite.cs index 97bb78f..ce2cf23 100755 --- a/src/Tizen.Location/Tizen.Location/GpsSatellite.cs +++ b/src/Tizen.Location/Tizen.Location/GpsSatellite.cs @@ -34,6 +34,7 @@ namespace Tizen.Location /// The time interval between callback updates. /// Should be in the range [1~120] seconds. /// + /// Thrown when an invalid argument is used public int Interval { get @@ -63,6 +64,10 @@ namespace Tizen.Location /// /// The NMEAData from the Satellite. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public string Nmea { get @@ -89,6 +94,10 @@ namespace Tizen.Location /// /// The Count of Active satellites. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public int ActiveCount { get @@ -115,6 +124,10 @@ namespace Tizen.Location /// /// The Count of satellites in view. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public int InViewCount { get @@ -141,6 +154,10 @@ namespace Tizen.Location /// /// The list of satellites/last recorded satellites in view. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public IList Satellites { get @@ -172,6 +189,7 @@ namespace Tizen.Location /// The constructor of GpsSatellite class. /// Locator object initilized using Gps. /// + /// Thrown when an invalid argument is used public GpsSatellite(Locator locator) { Log.Info(Globals.LogTag, "Calling GpsSatellite constructor"); @@ -192,6 +210,9 @@ namespace Tizen.Location /// (event) SatelliteStatusUpdated is raised whenever satellite information is updated. /// The callback will be invoked periodically (every Interval seconds). /// + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public event EventHandler SatelliteStatusUpdated { add diff --git a/src/Tizen.Location/Tizen.Location/Location.cs b/src/Tizen.Location/Tizen.Location/Location.cs index 15604be..2041895 100755 --- a/src/Tizen.Location/Tizen.Location/Location.cs +++ b/src/Tizen.Location/Tizen.Location/Location.cs @@ -175,6 +175,8 @@ namespace Tizen.Location /// The latitude of the source location [-90.0 ~ 90.0] (degrees). /// The longitude of the source location[-180.0 ~ 180.0] (degrees). /// Returns the distance between source and destination. + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public static double GetDistanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude) { double result; @@ -193,6 +195,8 @@ namespace Tizen.Location /// /// The location object to which distance is to be calculated. /// Returns the distance to the specified location. + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public double GetDistanceTo(Location location) { double result; diff --git a/src/Tizen.Location/Tizen.Location/LocationBoundary.cs b/src/Tizen.Location/Tizen.Location/LocationBoundary.cs index d89e886..6d0a615 100755 --- a/src/Tizen.Location/Tizen.Location/LocationBoundary.cs +++ b/src/Tizen.Location/Tizen.Location/LocationBoundary.cs @@ -61,6 +61,8 @@ namespace Tizen.Location /// /// The overidden Dispose method of the IDisposable class. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public void Dispose() { Log.Info(Globals.LogTag, "Dispose"); @@ -101,6 +103,9 @@ namespace Tizen.Location /// /// The coordinate which constitute the top left handside of the rectangular boundary. /// The coordinate which constitute the bottom right handside of the rectangular boundary. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public RectangleBoundary(Coordinate topLeft, Coordinate bottomRight) { Log.Info(Globals.LogTag, "Calling RectangleBoundary constructor"); @@ -110,7 +115,7 @@ namespace Tizen.Location if ((LocationBoundError)ret != LocationBoundError.None) { Log.Error(Globals.LogTag, "Error Creating Rectangular Boundary," + (LocationBoundError)ret); - LocationErrorFactory.ThrowLocationBoundaryException(ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); } handle = boundsHandle; } @@ -168,6 +173,9 @@ namespace Tizen.Location /// /// The coordinates which constitute the center of the circular boundary. /// The radius value of the circular boundary. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public CircleBoundary(Coordinate coordinate, double radius) { Log.Info(Globals.LogTag, "Calling CircleBoundary constructor"); @@ -177,7 +185,7 @@ namespace Tizen.Location if ((LocationBoundError)ret != LocationBoundError.None) { Log.Error(Globals.LogTag, "Error Creating Circular Boundary," + (LocationBoundError)ret); - LocationErrorFactory.ThrowLocationBoundaryException(ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); } handle = boundsHandle; } @@ -185,6 +193,9 @@ namespace Tizen.Location /// /// Gets the coordinate of the center of a circular boundary. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public Coordinate Center { get @@ -196,6 +207,9 @@ namespace Tizen.Location /// /// Gets the radius of a circular boundary. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public double Radius { get @@ -209,7 +223,12 @@ namespace Tizen.Location Log.Info(Globals.LogTag, "Calling to get CoordinateItem Center"); Coordinate center; double radius; - Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius); + int ret = Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius); + if ((LocationBoundError)ret != LocationBoundError.None) + { + Log.Error(Globals.LogTag, "Error Get Circle Center," + (LocationBoundError)ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); + } return center; } @@ -217,7 +236,12 @@ namespace Tizen.Location { Coordinate center; double radius = 0; - Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius); + int ret = Interop.LocationBoundary.GetCircleCoordinates(handle, out center, out radius); + if ((LocationBoundError)ret != LocationBoundError.None) + { + Log.Error(Globals.LogTag, "Error Get Radius," + (LocationBoundError)ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); + } return radius; } } @@ -232,6 +256,9 @@ namespace Tizen.Location /// Constructor of the polygon boundary class. /// /// The coordinates which constitute the polgonal boundary. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public PolygonBoundary(IList coordinates) { Log.Info(Globals.LogTag, "Calling PolygonBoundary Constructor"); @@ -249,7 +276,7 @@ namespace Tizen.Location if ((LocationBoundError)ret != LocationBoundError.None) { Log.Error(Globals.LogTag, "Error Creating Polygon Boundary," + (LocationBoundError)ret); - LocationErrorFactory.ThrowLocationBoundaryException(ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); } handle = boundsHandle; } @@ -257,6 +284,9 @@ namespace Tizen.Location /// /// Gets the list of coordinates which constitute a polygonal boundary /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public IList Coordinates { get @@ -278,7 +308,12 @@ namespace Tizen.Location return true; }; - Interop.LocationBoundary.GetForEachPolygonCoordinates(handle, callback, IntPtr.Zero); + int ret = Interop.LocationBoundary.GetForEachPolygonCoordinates(handle, callback, IntPtr.Zero); + if ((LocationBoundError)ret != LocationBoundError.None) + { + Log.Error(Globals.LogTag, "Error Get foreach Boundary," + (LocationBoundError)ret); + throw LocationErrorFactory.ThrowLocationBoundaryException(ret); + } return coordinateList; } } diff --git a/src/Tizen.Location/Tizen.Location/Locator.cs b/src/Tizen.Location/Tizen.Location/Locator.cs index 0a21100..0d2f375 100755 --- a/src/Tizen.Location/Tizen.Location/Locator.cs +++ b/src/Tizen.Location/Tizen.Location/Locator.cs @@ -32,7 +32,7 @@ namespace Tizen.Location /// Notifications on events like service becoming enabled or disabled, new position data being available /// and others can also be acquired. /// - public class Locator:IDisposable + public class Locator : IDisposable { private int _interval = 1; private int _stayInterval = 120; @@ -57,6 +57,9 @@ namespace Tizen.Location /// The constructor of Locator class. /// /// The back-end positioning method to be used for LBS. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public Locator(LocationType locationType) { Log.Info(Globals.LogTag, "Locator Constructor"); @@ -82,6 +85,8 @@ namespace Tizen.Location /// The time interval between callback updates. /// Should be in the range [1~120] seconds. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public int Interval { get @@ -112,6 +117,8 @@ namespace Tizen.Location /// The time interval between Distance based location callback updates. /// Should be in the range [1~120] seconds. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public int StayInterval { get @@ -142,6 +149,8 @@ namespace Tizen.Location /// The distance between callback updates. /// Should be in the range [1-120] meters. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public double Distance { get @@ -195,6 +204,8 @@ namespace Tizen.Location /// /// Gets the status whether mock location is enabled or not. /// + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public bool EnableMock { get @@ -227,6 +238,10 @@ namespace Tizen.Location /// /// Starts the Location Manager which has been created using the specified method. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public void Start() { Log.Info(Globals.LogTag, "Starting Location Manager"); @@ -253,6 +268,9 @@ namespace Tizen.Location /// Stops the Location Manager which has been activated using the specified method. /// Does not destroy the manager. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public void Stop() { Log.Info(Globals.LogTag, "Stopping Location Manager"); @@ -270,6 +288,10 @@ namespace Tizen.Location /// Sets a mock location for the given location method. /// /// The location object containing the mock location details. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public void SetMockLocation(Location location) { Log.Info(Globals.LogTag, "Setting mock location"); @@ -293,6 +315,10 @@ namespace Tizen.Location /// /// Clears a mock location for the given location method. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public void ClearMock() { Log.Info(Globals.LogTag, "Clear mock location"); @@ -309,6 +335,10 @@ namespace Tizen.Location /// /// Timeout to stop requesting single location after(seconds). /// A task which contains the current location details + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public Task GetLocationAsync(int timeout) { var task = new TaskCompletionSource(); @@ -349,6 +379,10 @@ namespace Tizen.Location /// Gets the details of the location. /// /// which contains the current location details + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the app has no privilege to use the location + /// Thrown when the location is not supported public Location GetLocation() { double altitude = 0; @@ -394,6 +428,9 @@ namespace Tizen.Location /// Adds a bounds for a given locator. /// /// The boundary object to be added to the locator. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public void AddBoundary(LocationBoundary locationBoundary) { Log.Info(Globals.LogTag, "AddBoundary called"); @@ -410,6 +447,9 @@ namespace Tizen.Location /// Deletes a bounds for a given locator. /// /// The boundary object to be removed from the locator. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public void RemoveBoundary(LocationBoundary locationBoundary) { Log.Info(Globals.LogTag, "RemoveBoundary called"); @@ -424,6 +464,8 @@ namespace Tizen.Location /// /// The overidden Dispose method of the IDisposable class. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public void Dispose() { Dispose(true); @@ -435,7 +477,9 @@ namespace Tizen.Location if (_disposed) return; - DestroyHandle(); + if (disposing) + DestroyHandle(); + _disposed = true; } @@ -444,7 +488,7 @@ namespace Tizen.Location int ret = Interop.Locator.Destroy(_handle); if (((LocationError)ret != LocationError.None)) { - Log.Error(Globals.LogTag, "Error in Destroy handle" + (LocationError)ret); + Log.Error(Globals.LogTag, "Error in Destroy handle, " + (LocationError)ret); throw LocationErrorFactory.ThrowLocationException(ret); } } @@ -452,6 +496,8 @@ namespace Tizen.Location /// /// (event) ServiceStateChanged Event is invoked when the location service state is changed. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public event EventHandler ServiceStateChanged { add @@ -508,6 +554,8 @@ namespace Tizen.Location /// /// (event) ZoneChanged is invoked when the previously set boundary area is entered or left. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public event EventHandler ZoneChanged { add @@ -569,6 +617,9 @@ namespace Tizen.Location /// /// (event) SetttingChanged is raised when the location setting is changed. /// + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public event EventHandler SettingChanged { add @@ -626,6 +677,8 @@ namespace Tizen.Location /// (event) DistanceBasedLocationChanged is raised with updated location information. /// The callback will be invoked at minimum interval or minimum distance with updated position information. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public event EventHandler DistanceBasedLocationChanged { add @@ -684,6 +737,8 @@ namespace Tizen.Location /// (event)LocationUpdated is raised at defined intervals of time with updated location information. /// The callback will be invoked periodically. /// + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public event EventHandler LocationChanged { add diff --git a/src/Tizen.Location/Tizen.Location/LocatorHelper.cs b/src/Tizen.Location/Tizen.Location/LocatorHelper.cs index d3e2479..7de13b3 100755 --- a/src/Tizen.Location/Tizen.Location/LocatorHelper.cs +++ b/src/Tizen.Location/Tizen.Location/LocatorHelper.cs @@ -37,6 +37,9 @@ namespace Tizen.Location /// /// The back-end positioning method to be used for LBS. /// Returns a boolean value indicating whether or not the specified method is supported. + /// Thrown when the operation is invalid for the current state + /// Thrown when an invalid argument is used + /// Thrown when the location is not supported public static bool IsEnabledType(LocationType locationType) { Log.Info(Globals.LogTag, "Checking if the Location Manager type is Enabled"); -- 2.7.4