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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeVersionInfo.java

Issue 2751773002: Add Google Play services info to chrome://version (Closed)
Patch Set: fix indentation Created 3 years, 9 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
« no previous file with comments | « no previous file | chrome/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ }
+ }
}
« no previous file with comments | « no previous file | chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698