[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);
[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);
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;
get
{
Log.Info(Globals.LogTag, "Getting getting Mock");
+ _isEnableMock = GetEnableMock();
return _isEnableMock;
}
set
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);
}
}
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>
Log.Error(Globals.LogTag, "Error stopping Location Manager," + (LocationError)ret);
throw LocationErrorFactory.ThrowLocationException(ret);
}
- Locator.s_locatorReference = null;
_isStarted = false;
}