| Index: services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java
|
| diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java
|
| index 232102abdb941e4799272bfde4e725c21b2f6cb5..1826a34b5bf90481a33eb8eada4ea1d7c6d1eb37 100644
|
| --- a/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java
|
| +++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java
|
| @@ -6,6 +6,9 @@ package org.chromium.shape_detection;
|
|
|
| import android.content.Context;
|
|
|
| +import com.google.android.gms.common.ConnectionResult;
|
| +import com.google.android.gms.common.GoogleApiAvailability;
|
| +
|
| import org.chromium.mojo.bindings.InterfaceRequest;
|
| import org.chromium.mojo.system.MojoException;
|
| import org.chromium.services.service_manager.InterfaceFactory;
|
| @@ -17,10 +20,24 @@ import org.chromium.shape_detection.mojom.FaceDetectorOptions;
|
| * Service provider to create FaceDetection services
|
| */
|
| public class FaceDetectionProviderImpl implements FaceDetectionProvider {
|
| + private final Context mContext;
|
| +
|
| + public FaceDetectionProviderImpl(Context context) {
|
| + mContext = context;
|
| + }
|
| +
|
| @Override
|
| public void createFaceDetection(
|
| InterfaceRequest<FaceDetection> request, FaceDetectorOptions options) {
|
| - FaceDetection.MANAGER.bind(new FaceDetectionImpl(options), request);
|
| + final boolean isGmsCoreSupported =
|
| + GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mContext)
|
| + == ConnectionResult.SUCCESS;
|
| +
|
| + if (isGmsCoreSupported) {
|
| + FaceDetection.MANAGER.bind(new FaceDetectionImplGmsCore(mContext, options), request);
|
| + } else {
|
| + FaceDetection.MANAGER.bind(new FaceDetectionImpl(options), request);
|
| + }
|
| }
|
|
|
| @Override
|
| @@ -33,11 +50,15 @@ public class FaceDetectionProviderImpl implements FaceDetectionProvider {
|
| * A factory class to register FaceDetectionProvider interface.
|
| */
|
| public static class Factory implements InterfaceFactory<FaceDetectionProvider> {
|
| - public Factory(Context context) {}
|
| + private final Context mContext;
|
| +
|
| + public Factory(Context context) {
|
| + mContext = context;
|
| + }
|
|
|
| @Override
|
| public FaceDetectionProvider createImpl() {
|
| - return new FaceDetectionProviderImpl();
|
| + return new FaceDetectionProviderImpl(mContext);
|
| }
|
| }
|
| }
|
|
|