Esempio n. 1
0
        private void SetZoneChangedCallback()
        {
            Log.Info(Globals.LogTag, "Inside SetZoneChangedCallback");
            if (_zoneChangedCallback == null)
            {
                _zoneChangedCallback = (state, latitude, longitude, altitude, timestamp, userData) =>
                {
                    Log.Info(Globals.LogTag, "Inside ZoneChangedCallback");
                    DateTime timeStamp = DateTime.Now;
                    if (timestamp != 0)
                    {
                        DateTime start = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(timestamp), DateTimeKind.Utc);
                        timeStamp = start.ToLocalTime();
                    }
                    _zoneChanged?.Invoke(this, new ZoneChangedEventArgs(state, latitude, longitude, altitude, timeStamp));
                };
            }

            int ret = Interop.LocatorEvent.SetZoneChangedCallback(_handle, _zoneChangedCallback, IntPtr.Zero);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Setting Zone Changed Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The constructor of the Polygon Boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="coordinates"> The coordinates which constitute the polgonal boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public PolygonBoundary(IList <Coordinate> coordinates)
        {
            Log.Info(Globals.LogTag, "Calling PolygonBoundary Constructor");
            if (coordinates == null)
            {
                Log.Error(Globals.LogTag, "coordingtes list is null");
                throw LocationErrorFactory.ThrowLocationException((int)LocationError.InvalidParameter);
            }

            BoundaryType = BoundaryType.Polygon;
            IntPtr listPointer = Marshal.AllocHGlobal(Marshal.SizeOf(coordinates[0]) * coordinates.Count);
            IntPtr boundsHandle;

            for (int i = 0; i < coordinates.Count; i++)
            {
                Marshal.StructureToPtr(coordinates[i], listPointer + i * Marshal.SizeOf(coordinates[0]), false);
            }
            int ret = Interop.LocationBoundary.CreatePolygonBoundary(listPointer, coordinates.Count, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Polygon Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
Esempio n. 3
0
        private void SetSatelliteStatusChangeCallback()
        {
            Log.Info(Globals.LogTag, "SetSatelliteStatusChangeCallback");
            if (_satelliteStatuschangedCallback == null)
            {
                _satelliteStatuschangedCallback = (numActive, numInView, timestamp, userData) =>
                {
                    Log.Info(Globals.LogTag, "Inside SatelliteStatusChangedCallback");
                    DateTime timeStamp = DateTime.Now;

                    if (timestamp != 0)
                    {
                        DateTime start = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(timestamp), DateTimeKind.Utc);
                        timeStamp = start.ToLocalTime();
                    }
                    _satelliteStatusChanged?.Invoke(_handle, new SatelliteStatusChangedEventArgs(numActive, numInView, timeStamp));
                };
            }

            GCHandle handle = GCHandle.Alloc(this);
            int      ret    = Interop.GpsSatellite.SetSatelliteStatusChangedCallback(_handle, _satelliteStatuschangedCallback, _interval, GCHandle.ToIntPtr(handle));

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in setting satellite status changed callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 4
0
        private void SetLocationBatchCallback()
        {
            Log.Info(Globals.LogTag, "Calling SetLocationBatchCallback");
            int ret;

            if (_locationBatchCallback == null)
            {
                _locationBatchCallback = (batch_size, userData) =>
                {
                    Log.Info(Globals.LogTag, "LocationBatchCallback has been called, size : " + batch_size);

                    _locationBatchGetCallback = (latitude, longitude, altitude, speed, direction, horizontal, vertical, timestamp, batchUserData) =>
                    {
                        Log.Info(Globals.LogTag, "GetLocationBatch has been called");
                        Location location = new Location(latitude, longitude, altitude, speed, direction, horizontal, timestamp);
                        _location = location;
                        _locationChanged?.Invoke(this, new LocationChangedEventArgs(location));
                    };

                    ret = Interop.LocatorEvent.GetLocationBatch(_handle, _locationBatchGetCallback, IntPtr.Zero);
                    if (((LocationError)ret != LocationError.None))
                    {
                        Log.Error(Globals.LogTag, "Error in Setting location batch Callback," + (LocationError)ret);
                        throw LocationErrorFactory.ThrowLocationException(ret);
                    }
                };
            }

            ret = Interop.LocatorEvent.SetLocationBatchCallback(_handle, _locationBatchCallback, _batchInterval, _batchPeriod, IntPtr.Zero);
            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Setting location batch Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 5
0
        private void DestroyHandle()
        {
            int ret = Interop.Locator.Destroy(_handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Destroy handle, " + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 6
0
        private void SetEnableMock()
        {
            int ret = Interop.Locator.EnableMock(_isEnableMock);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error Set Enable Mock Status," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 7
0
        private void UnSetSettingChangedCallback()
        {
            Log.Info(Globals.LogTag, "Calling UnSetSettingChangedCallback");
            int ret = Interop.LocatorEvent.UnSetSettingChangedCallback((int)_locationType);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Unsetting Setting's Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 8
0
        private void UnSetLocationBatchCallback()
        {
            Log.Info(Globals.LogTag, "Calling UnSetLocationBatchCallback");
            int ret = Interop.LocatorEvent.UnSetLocationBatchCallback(_handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in UnSetting location batch Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Sets the specified geographical positioning type.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <privilege>http://tizen.org/privilege/location.enable</privilege>
        /// <privlevel>platform</privlevel>
        /// <param name="locationType">The back-end positioning method to be used for LBS.</param>
        /// <param name="status">The location setting value.</param>
        /// <feature>http://tizen.org/feature/location.gps</feature>
        /// <feature>http://tizen.org/feature/location.wps</feature>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public static void EnableType(LocationType locationType, bool status)
        {
            Log.Info(Globals.LogTag, "Sets the location setting status");
            int ret = Interop.LocatorHelper.EnableType((int)locationType, status);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error Sets the Location type," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Deletes a bound for a given locator.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="locationBoundary"> The boundary object to be removed from the locator.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public void RemoveBoundary(LocationBoundary locationBoundary)
        {
            Log.Info(Globals.LogTag, "RemoveBoundary called");
            int ret = Interop.Locator.RemoveBoundary(_handle, locationBoundary.GetHandle());

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Removing Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
        }
Esempio n. 11
0
        private void DestroyHandle()
        {
            Log.Info(Globals.LogTag, "DestroyBoundaryHandle");
            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);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Clears a mock location for the given location method.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <privilege>http://tizen.org/privilege/location</privilege>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when the application has no privilege to use the location.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public void ClearMock()
        {
            Log.Info(Globals.LogTag, "Clear mock location");
            int ret = Interop.Locator.ClearMock(_handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in clear up location mocking," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Stops the Location Manager which has been activated using the specified method.
        /// Does not destroy the manager.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public void Stop()
        {
            Log.Info(Globals.LogTag, "Stopping Location Manager");
            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);
            }
        }
Esempio n. 14
0
        private void UnSetSatelliteStatusChangeCallback()
        {
            Log.Info(Globals.LogTag, "UnSetSatelliteStatusChangeCallback");
            int ret = Interop.GpsSatellite.UnSetSatelliteStatusChangedCallback(_handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Getting Unsetting satellite status changed callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 15
0
        private void UnSetDistanceBasedLocationChangedCallback()
        {
            Log.Info(Globals.LogTag, "UnSetDistanceBasedLocationChangedCallback");
            int ret = Interop.LocatorEvent.UnSetDistanceBasedLocationChangedCallback(_handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in UnSetting Distance based location changed Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            _distanceBasedLocationChanged = null;
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        private string GetNmea()
        {
            string value = null;
            int    ret   = Interop.GpsSatellite.GetNMEAData(_handle, out value);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error getting the NMEAData," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }

            return(value);
        }
Esempio n. 18
0
        private double GetRadius()
        {
            Coordinate center;
            double     radius = 0;
            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);
        }
Esempio n. 19
0
        /// <summary>
        /// The constructor of the Locator class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="locationType"> The back-end positioning method to be used for LBS.</param>
        /// <feature>http://tizen.org/feature/location.gps</feature>
        /// <feature>http://tizen.org/feature/location.wps</feature>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public Locator(LocationType locationType)
        {
            Log.Info(Globals.LogTag, "Locator Constructor");
            int ret = Interop.Locator.Create((int)locationType, out _handle);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error creating Location Manager," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            _location     = new Location();
            _locationType = locationType;
        }
Esempio n. 20
0
        /// <summary>
        /// Checks if the specified geographical positioning type is enabled or not.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="locationType">The back-end positioning method to be used for LBS.</param>
        /// <feature>http://tizen.org/feature/location.gps</feature>
        /// <feature>http://tizen.org/feature/location.wps</feature>
        /// <returns>Returns a boolean value indicating whether or not the specified method is supported.</returns>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public static bool IsEnabledType(LocationType locationType)
        {
            Log.Info(Globals.LogTag, "Checking if the Location Manager type is Enabled");
            bool status;
            int  ret = Interop.LocatorHelper.IsEnabled((int)locationType, out status);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error Checking the Location Manager type is Enabled," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            return(status);
        }
Esempio n. 21
0
        /// <summary>
        /// The constructor of the Rectangle boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="topLeft"> The coordinate which constitutes the top-left handside of the rectangular boundary.</param>
        /// <param name="bottomRight"> The coordinate which constitutes the bottom-right handside of the rectangular boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public RectangleBoundary(Coordinate topLeft, Coordinate bottomRight)
        {
            Log.Info(Globals.LogTag, "Calling RectangleBoundary constructor");
            BoundaryType = BoundaryType.Rectangle;
            IntPtr boundsHandle;
            int    ret = Interop.LocationBoundary.CreateRectangularBoundary(topLeft, bottomRight, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Rectangular Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
Esempio n. 22
0
        private Coordinate GetCircleCenter()
        {
            Log.Info(Globals.LogTag, "Calling to get CoordinateItem Center");
            Coordinate center;
            double     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);
        }
Esempio n. 23
0
        /// <summary>
        /// Gets the distance between the current and the specified location.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="location"> The location object to which distance is to be calculated.</param>
        /// <returns>Returns the distance to the specified location.</returns>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public double GetDistanceTo(Location location)
        {
            double result;

            Log.Info(Globals.LogTag, "Calling GetDistanceTo");
            int ret = Interop.Location.GetDistanceBetween(this.Latitude, this.Longitude, location.Latitude, location.Longitude, out result);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error getting distance information to the specifed location," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            return(result);
        }
Esempio n. 24
0
        /// <summary>
        /// Gets the distance between the two given coordinates.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="startLatitude">The latitude of the source location [-90.0 ~ 90.0] \(degrees).</param>
        /// <param name="startLongitude">The longitude of the source location[-180.0 ~ 180.0] \(degrees).</param>
        /// <param name="endLatitude">The latitude of the source location [-90.0 ~ 90.0] \(degrees).</param>
        /// <param name="endLongitude">The longitude of the source location[-180.0 ~ 180.0] \(degrees).</param>
        /// <returns>Returns the distance between the source and the destination.</returns>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public static double GetDistanceBetween(double startLatitude, double startLongitude, double endLatitude, double endLongitude)
        {
            double result;

            Log.Info(Globals.LogTag, "Calling GetDistanceBetween");
            int ret = Interop.Location.GetDistanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, out result);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error getting single distance information ," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            return(result);
        }
Esempio n. 25
0
        /// <summary>
        /// The constructor of the Circular boundary class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="coordinate"> The coordinates which constitute the center of the circular boundary.</param>
        /// <param name="radius"> The radius value of the circular boundary.</param>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public CircleBoundary(Coordinate coordinate, double radius)
        {
            Log.Info(Globals.LogTag, "Calling CircleBoundary constructor");
            BoundaryType = BoundaryType.Circle;
            IntPtr boundsHandle;
            int    ret = Interop.LocationBoundary.CreateCircleBoundary(coordinate, radius, out boundsHandle);

            if ((LocationBoundError)ret != LocationBoundError.None)
            {
                Log.Error(Globals.LogTag, "Error Creating Circular Boundary," + (LocationBoundError)ret);
                throw LocationErrorFactory.ThrowLocationBoundaryException(ret);
            }
            handle = boundsHandle;
        }
Esempio n. 26
0
        /// <summary>
        /// Gets the details of the location.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <returns> Which contains the current location details.</returns>
        /// <privilege>http://tizen.org/privilege/location</privilege>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when the application has no privilege to use the location.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public Location GetLocation()
        {
            double latitude  = 0;
            double longitude = 0;
            double altitude  = 0;
            double climb     = 0;
            double speed     = 0;
            double direction = 0;
            int    level     = 0;
            double accuracy  = 0;
            double vertical  = 0;
            int    timestamp = 0;

            Log.Info(Globals.LogTag, "Get current location information");
            int ret = Interop.Locator.GetLocation(_handle, out altitude, out latitude, out longitude, out climb, out direction, out speed, out level, out accuracy, out vertical, out timestamp);

            if (((LocationError)ret != LocationError.None))
            {
                if ((LocationError)ret == LocationError.ServiceNotAvailable)
                {
                    Log.Info(Globals.LogTag, "Get last location information");
                    ret = Interop.Locator.GetLastLocation(_handle, out altitude, out latitude, out longitude, out climb, out direction, out speed, out level, out accuracy, out vertical, out timestamp);
                    if (((LocationError)ret != LocationError.None))
                    {
                        Log.Error(Globals.LogTag, "Error in get last location information," + (LocationError)ret);
                        throw LocationErrorFactory.ThrowLocationException(ret);
                    }
                    else
                    {
                        if (latitude == 0.0 && longitude == 0.0)
                        {
                            Log.Error(Globals.LogTag, "Error fail to get last location information");
                            throw LocationErrorFactory.ThrowLocationException((int)LocationError.ServiceNotAvailable);
                        }
                    }
                }
                else
                {
                    Log.Error(Globals.LogTag, "Error in get current location information," + (LocationError)ret);
                    throw LocationErrorFactory.ThrowLocationException(ret);
                }
            }

            Location location = new Location(latitude, longitude, altitude, speed, direction, accuracy, timestamp);

            _location = location;

            return(location);
        }
Esempio n. 27
0
        private uint GetInViewCount()
        {
            Log.Info(Globals.LogTag, "Getting the In view count of satellites");
            uint numActive;
            uint numInView = 0;
            int  timestamp;
            int  ret = Interop.GpsSatellite.GetSatelliteStatus(_handle, out numActive, out numInView, out timestamp);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error getting the satellite" + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
            return(numInView);
        }
Esempio n. 28
0
        /// <summary>
        /// Sets a mock location for the given location method.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        /// <param name="location"> The location object containing the mock location details.</param>
        /// <privilege>http://tizen.org/privilege/location</privilege>
        /// <exception cref="InvalidOperationException">Thrown when the operation is invalid for the current state.</exception>
        /// <exception cref="ArgumentException">Thrown when an invalid argument is used.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when the application has no privilege to use the location.</exception>
        /// <exception cref="NotSupportedException">Thrown when the location is not supported.</exception>
        public void SetMockLocation(Location location)
        {
            Log.Info(Globals.LogTag, "Setting mock location");
            int ret = Interop.Locator.SetMockLocation(_handle, location.Latitude, location.Longitude, location.Altitude, location.Speed, location.Direction, location.Accuracy);

            if (((LocationError)ret == LocationError.None))
            {
                _location.Latitude  = location.Latitude;
                _location.Longitude = location.Longitude;
                _location.Altitude  = location.Altitude;
                _location.Speed     = location.Speed;
                _location.Direction = location.Direction;
                _location.Accuracy  = location.Accuracy;
            }
            else
            {
                Log.Error(Globals.LogTag, "Error in setting up location mocking," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 29
0
        private void SetSettingChangedCallback()
        {
            Log.Info(Globals.LogTag, "Calling SetSettingChangedCallback");
            if (_settingChangedCallback == null)
            {
                _settingChangedCallback = (method, enable, userData) =>
                {
                    Log.Info(Globals.LogTag, "Calling SettingChangedCallback");
                    _settingChanged?.Invoke(this, new SettingChangedEventArgs(method, enable));
                };
            }

            int ret = Interop.LocatorEvent.SetSettingChangedCallback((int)_locationType, _settingChangedCallback, IntPtr.Zero);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Setting Changed Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }
Esempio n. 30
0
        private void SetServiceStateChangedCallback()
        {
            Log.Info(Globals.LogTag, "Calling Interop.LocatorEvent.SetServiceStateChangedCallback");
            if (_serviceStateChangedCallback == null)
            {
                _serviceStateChangedCallback = (state, userData) =>
                {
                    Log.Info(Globals.LogTag, "Inside ServiceStateChangedCallback");
                    _serviceStateChanged?.Invoke(this, new ServiceStateChangedEventArgs(state));
                };
            }

            int ret = Interop.LocatorEvent.SetServiceStateChangedCallback(_handle, _serviceStateChangedCallback, IntPtr.Zero);

            if (((LocationError)ret != LocationError.None))
            {
                Log.Error(Globals.LogTag, "Error in Setting Service State Changed Callback," + (LocationError)ret);
                throw LocationErrorFactory.ThrowLocationException(ret);
            }
        }