diff --git a/Libraries/Geolocation/Geolocation.js b/Libraries/Geolocation/Geolocation.js index 8e943b035..6f6c27f20 100644 --- a/Libraries/Geolocation/Geolocation.js +++ b/Libraries/Geolocation/Geolocation.js @@ -31,7 +31,7 @@ type GeoOptions = { } /** - * The Geolocation API follows the web spec: + * The Geolocation API extends the web spec: * https://developer.mozilla.org/en-US/docs/Web/API/Geolocation * * As a browser polyfill, this API is available through the `navigator.geolocation` @@ -48,6 +48,9 @@ type GeoOptions = { * * `` * + * Android API >= 18 Positions will also contain a `mocked` boolean to indicate if position + * was created from a mock provider. + * */ var Geolocation = { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java index 52235a30c..ea0ed5a5c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java @@ -214,6 +214,11 @@ public class LocationModule extends ReactContextBaseJavaModule { coords.putDouble("speed", location.getSpeed()); map.putMap("coords", coords); map.putDouble("timestamp", location.getTime()); + + if (android.os.Build.VERSION.SDK_INT >= 18) { + map.putBoolean("mocked", location.isFromMockProvider()); + } + return map; } diff --git a/flow/Position.js b/flow/Position.js new file mode 100644 index 000000000..3ec6e087e --- /dev/null +++ b/flow/Position.js @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +declare class Position { + coords: Coordinates, + timestamp: number, + mocked: boolean, +}