Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: services/shape_detection/android/java/src/org/chromium/shape_detection/FaceDetectionProviderImpl.java

Issue 2868883003: Shape Detection: use Google Play services Face detection where available (Closed)
Patch Set: reillyg@ nit and filling faceArray[i].landmarks in FaceDetectionImpl.java Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698