| Index: device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
|
| diff --git a/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java b/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
|
| index 3ffc36af9dbcdfa4e6d41a423772a568009bad44..33809e99f5b029103da2e8b3a8fb8645aac03e06 100644
|
| --- a/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
|
| +++ b/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
|
| @@ -9,19 +9,20 @@ import android.content.Context;
|
| import org.chromium.base.VisibleForTesting;
|
|
|
| /**
|
| - * Factory to create a LocationProvider to allow us to inject
|
| - * a mock for tests.
|
| + * Factory to create a LocationProvider to allow us to inject a mock for tests.
|
| */
|
| public class LocationProviderFactory {
|
| private static LocationProviderFactory.LocationProvider sProviderImpl;
|
| + private static boolean sUseGmsCoreLocationProvider;
|
|
|
| /**
|
| * LocationProviderFactory.create() returns an instance of this interface.
|
| */
|
| public interface LocationProvider {
|
| /**
|
| - * Start listening for location updates.
|
| - * @param enableHighAccuracy Whether or not to enable high accuracy location providers.
|
| + * Start listening for location updates. Calling several times before stop() is interpreted
|
| + * as restart.
|
| + * @param enableHighAccuracy Whether or not to enable high accuracy location.
|
| */
|
| public void start(boolean enableHighAccuracy);
|
|
|
| @@ -40,12 +41,20 @@ public class LocationProviderFactory {
|
|
|
| @VisibleForTesting
|
| public static void setLocationProviderImpl(LocationProviderFactory.LocationProvider provider) {
|
| - assert sProviderImpl == null;
|
| sProviderImpl = provider;
|
| }
|
|
|
| + public static void useGmsCoreLocationProvider() {
|
| + sUseGmsCoreLocationProvider = true;
|
| + }
|
| +
|
| public static LocationProvider create(Context context) {
|
| - if (sProviderImpl == null) {
|
| + if (sProviderImpl != null) return sProviderImpl;
|
| +
|
| + if (sUseGmsCoreLocationProvider
|
| + && LocationProviderGmsCore.isGooglePlayServicesAvailable(context)) {
|
| + sProviderImpl = new LocationProviderGmsCore(context);
|
| + } else {
|
| sProviderImpl = new LocationProviderAndroid(context);
|
| }
|
| return sProviderImpl;
|
|
|