csharp : location - New feature 37/116237/1 accepted/tizen/common/20170227.043237 accepted/tizen/ivi/20170227.050528 accepted/tizen/mobile/20170227.050454 accepted/tizen/tv/20170227.050502 submit/tizen/20170224.113719 submit/tizen_unified/20170308.100407
authorkj7.sung <kj7.sung@samsung.com>
Thu, 23 Feb 2017 10:59:15 +0000 (19:59 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Thu, 23 Feb 2017 10:59:20 +0000 (19:59 +0900)
- Add passive method
- Support multi method in one client
- Fix mock location

Change-Id: Icc52b3e9009d08b6842ca6bed100ceee059fc09d
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
Tizen.Location/Interop/Interop.Location.cs
Tizen.Location/Tizen.Location.project.json
Tizen.Location/Tizen.Location/Locator.cs
Tizen.Location/Tizen.Location/LocatorEnumerations.cs
packaging/csapi-location.spec

index 39c918e..f890450 100755 (executable)
@@ -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);
 
index ed54b3e..dacd88f 100755 (executable)
@@ -6,4 +6,4 @@
   "frameworks": {\r
     "netstandard1.3": {}\r
   }\r
-}
\ No newline at end of file
+}\r
index 8dd4747..b5c374e 100755 (executable)
@@ -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<IntPtr, Interop.LocatorEvent.LocationUpdatedCallback> _callback_map = new Dictionary<IntPtr, Interop.LocatorEvent.LocationUpdatedCallback>();
 
         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;
         }
 
         /// <summary>
@@ -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;
        }
 
index a6da9c4..cb20b8f 100755 (executable)
@@ -36,6 +36,7 @@ namespace Tizen.Location
         Hybrid = 0, /**<This method selects the best method available at the moment.*/
         Gps, /**<This method uses Global Positioning System.*/
         Wps, /**<This method uses WiFi Positioning System.*/
+        Passive, /**<This method uses passive mode.*/
     }
 
     /// <summary>
index 286c3a4..9bf830a 100755 (executable)
@@ -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