| Index: services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
| diff --git a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
| index 343502de865a8f22ee8937e1f7e8435af3b6ab0c..6f02069ab7c22b25421a4ebf02676f905b1bfe4a 100644
|
| --- a/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
| +++ b/services/shape_detection/android/java/src/org/chromium/shape_detection/BarcodeDetectionImpl.java
|
| @@ -4,7 +4,6 @@
|
|
|
| package org.chromium.shape_detection;
|
|
|
| -import android.content.Context;
|
| import android.graphics.Point;
|
| import android.graphics.Rect;
|
| import android.util.SparseArray;
|
| @@ -15,6 +14,7 @@ import com.google.android.gms.vision.Frame;
|
| import com.google.android.gms.vision.barcode.Barcode;
|
| import com.google.android.gms.vision.barcode.BarcodeDetector;
|
|
|
| +import org.chromium.base.ContextUtils;
|
| import org.chromium.base.Log;
|
| import org.chromium.gfx.mojom.PointF;
|
| import org.chromium.gfx.mojom.RectF;
|
| @@ -30,18 +30,18 @@ import org.chromium.shape_detection.mojom.BarcodeDetectionResult;
|
| public class BarcodeDetectionImpl implements BarcodeDetection {
|
| private static final String TAG = "BarcodeDetectionImpl";
|
|
|
| - private final Context mContext;
|
| private BarcodeDetector mBarcodeDetector;
|
|
|
| - public BarcodeDetectionImpl(Context context) {
|
| - mContext = context;
|
| - mBarcodeDetector = new BarcodeDetector.Builder(mContext).build();
|
| + public BarcodeDetectionImpl() {
|
| + mBarcodeDetector =
|
| + new BarcodeDetector.Builder(ContextUtils.getApplicationContext()).build();
|
| }
|
|
|
| @Override
|
| public void detect(
|
| SharedBufferHandle frameData, int width, int height, DetectResponse callback) {
|
| - if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mContext)
|
| + if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
|
| + ContextUtils.getApplicationContext())
|
| != ConnectionResult.SUCCESS) {
|
| Log.e(TAG, "Google Play Services not available");
|
| callback.call(new BarcodeDetectionResult[0]);
|
| @@ -102,15 +102,11 @@ public class BarcodeDetectionImpl implements BarcodeDetection {
|
| * A factory class to register BarcodeDetection interface.
|
| */
|
| public static class Factory implements InterfaceFactory<BarcodeDetection> {
|
| - private final Context mContext;
|
| -
|
| - public Factory(Context context) {
|
| - mContext = context;
|
| - }
|
| + public Factory() {}
|
|
|
| @Override
|
| public BarcodeDetection createImpl() {
|
| - return new BarcodeDetectionImpl(mContext);
|
| + return new BarcodeDetectionImpl();
|
| }
|
| }
|
| }
|
|
|