| Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java
|
| index a4cbeadbccbf6a4c32281c578340ab449942b116..efe413c03b9f68b907ad03ae08b29eaef4176834 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java
|
| @@ -4,6 +4,18 @@
|
|
|
| package org.chromium.chrome.browser;
|
|
|
| +import android.content.Context;
|
| +import android.content.pm.PackageManager;
|
| +
|
| +import com.google.android.gms.common.GoogleApiAvailability;
|
| +
|
| +import org.chromium.base.ContextUtils;
|
| +import org.chromium.base.annotations.CalledByNative;
|
| +import org.chromium.chrome.browser.externalauth.ExternalAuthUtils;
|
| +import org.chromium.chrome.browser.externalauth.UserRecoverableErrorHandler;
|
| +
|
| +import java.util.Locale;
|
| +
|
| /**
|
| * A utility class for querying information about the current Chrome build.
|
| * Intentionally doesn't depend on native so that the data can be accessed before
|
| @@ -66,4 +78,41 @@ public static String getProductVersion() {
|
| public static int getProductMajorVersion() {
|
| return ChromeVersionConstants.PRODUCT_MAJOR_VERSION;
|
| }
|
| +
|
| + /**
|
| + * Returns info about the Google Play services setup for Chrome and the device.
|
| + *
|
| + * Contains the version number of the SDK Chrome was built with and the one for the installed
|
| + * Play Services app. It also contains whether First Party APIs are available.
|
| + */
|
| + @CalledByNative
|
| + public static String getGmsInfo() {
|
| + Context context = ContextUtils.getApplicationContext();
|
| +
|
| + final long sdkVersion = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
| + final long installedGmsVersion = getPlayServicesApkVersionNumber(context);
|
| +
|
| + final String accessType;
|
| + UserRecoverableErrorHandler handler = new UserRecoverableErrorHandler.Silent();
|
| + if (ExternalAuthUtils.getInstance().canUseFirstPartyGooglePlayServices(context, handler)) {
|
| + accessType = "1p";
|
| + } else if (ExternalAuthUtils.getInstance().canUseGooglePlayServices(context, handler)) {
|
| + accessType = "3p";
|
| + } else {
|
| + accessType = "none";
|
| + }
|
| +
|
| + return String.format(Locale.US,
|
| + "SDK=%s; Installed=%s; Access=%s", sdkVersion, installedGmsVersion, accessType);
|
| + }
|
| +
|
| + private static long getPlayServicesApkVersionNumber(Context context) {
|
| + try {
|
| + return context.getPackageManager()
|
| + .getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0)
|
| + .versionCode;
|
| + } catch (PackageManager.NameNotFoundException e) {
|
| + return 0;
|
| + }
|
| + }
|
| }
|
|
|