From 1988f06f5b3cf40d9d6bf6f8610ab63c838b6a6a Mon Sep 17 00:00:00 2001 From: James Montemagno Date: Mon, 11 Jun 2018 11:34:56 -0700 Subject: [PATCH] Fixes #252 adds IsFromMockProvider on Android 18+ --- src/Geolocator.Plugin/Abstractions/Position.shared.cs | 10 ++++++++++ .../Android/GeolocationUtils.android.cs | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/Geolocator.Plugin/Abstractions/Position.shared.cs b/src/Geolocator.Plugin/Abstractions/Position.shared.cs index f184511..8269772 100644 --- a/src/Geolocator.Plugin/Abstractions/Position.shared.cs +++ b/src/Geolocator.Plugin/Abstractions/Position.shared.cs @@ -33,6 +33,7 @@ public Position(Position position) Accuracy = position.Accuracy; Heading = position.Heading; Speed = position.Speed; + IsFromMockProvider = position.IsFromMockProvider; } /// @@ -109,6 +110,15 @@ public double Speed get; set; } + + /// + /// Gets or sets if from mock provider + /// + public bool IsFromMockProvider + { + get; + set; + } } /// diff --git a/src/Geolocator.Plugin/Android/GeolocationUtils.android.cs b/src/Geolocator.Plugin/Android/GeolocationUtils.android.cs index cfbb55d..52f9825 100644 --- a/src/Geolocator.Plugin/Android/GeolocationUtils.android.cs +++ b/src/Geolocator.Plugin/Android/GeolocationUtils.android.cs @@ -73,6 +73,12 @@ internal static Position ToPosition(this Location location) p.Longitude = location.Longitude; p.Latitude = location.Latitude; p.Timestamp = location.GetTimestamp(); + + if ((int)Android.OS.Build.VERSION.SdkInt >= 18) + p.IsFromMockProvider = location.IsFromMockProvider; + else + p.IsFromMockProvider = false; + return p; }