Commit 9a2e6e50 authored by Reilly Grant's avatar Reilly Grant Committed by Commit Bot

Disable barcode detection on old versions of Google Play services

Bug: 1020746
Change-Id: I6744bfd35bef56b5edc3c8e0963e3fd8459e7bb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032178
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737364}
parent 9fc39b9b
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
package org.chromium.shape_detection; package org.chromium.shape_detection;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GoogleApiAvailability; import com.google.android.gms.common.GoogleApiAvailability;
...@@ -50,10 +54,22 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider { ...@@ -50,10 +54,22 @@ public class BarcodeDetectionProviderImpl implements BarcodeDetectionProvider {
public void onConnectionError(MojoException e) {} public void onConnectionError(MojoException e) {}
public static BarcodeDetectionProvider create() { public static BarcodeDetectionProvider create() {
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( Context ctx = ContextUtils.getApplicationContext();
ContextUtils.getApplicationContext()) if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(ctx)
!= ConnectionResult.SUCCESS) { != ConnectionResult.SUCCESS) {
Log.e(TAG, "Google Play Services not available"); Log.w(TAG, "Google Play Services not available");
return null;
}
try {
PackageInfo playServicesPackage = ctx.getPackageManager().getPackageInfo(
GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0);
if (playServicesPackage.versionCode < 19742000) {
// https://crbug.com/1020746
Log.w(TAG, "Detection disabled (%s < 19.7.42)", playServicesPackage.versionName);
return null;
}
} catch (NameNotFoundException e) {
Log.w(TAG, "Google Play Services not available");
return null; return null;
} }
return new BarcodeDetectionProviderImpl(); return new BarcodeDetectionProviderImpl();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment