Commit 6a6c700a authored by Sam Maier's avatar Sam Maier Committed by Chromium LUCI CQ

GMSCore API availability function for specific versions

Change-Id: Ie431852d225659e8b24bfec9c09d7c043924660f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2595929
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avatarDavid Van Cleve <davidvc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838236}
parent 52bc3e73
...@@ -8,20 +8,20 @@ import android.content.Context; ...@@ -8,20 +8,20 @@ import android.content.Context;
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;
// Refer to go/doubledown-play-services#new-apis for more detail.
public final class ChromiumPlayServicesAvailability { public final class ChromiumPlayServicesAvailability {
/** /**
* The minimum GMS version we're requesting. isGooglePlayServicesAvailable will fail if the * The minimum GMS version we're requesting. isGooglePlayServicesAvailable will fail if the
* found version on the devices is lower than this number. This number should only be updated * found version on the devices is lower than this number. This number should never be updated;
* when using an API introduced in a newer GMS version, and that API usage is gated by this * if you need to check for a higher number, use
* class. To see how this number originated, see * {@link GoogleApiAvailability#isGooglePlayServicesAvailable(Context, int))} instead.
* To see how this number originated, see
* https://bugs.chromium.org/p/chromium/issues/detail?id=1145211#c3. * https://bugs.chromium.org/p/chromium/issues/detail?id=1145211#c3.
*/ */
public static final int GMS_VERSION_NUMBER = 20415000; public static final int DEFAULT_GMS_VERSION_NUMBER = 20415000;
/** /**
* Checks, with an appropriate version number, if Play Services is available in this context. * Checks if Play Services is available in this context.
* This is intended to replace anyone manually calling isGooglePlayServicesAvailable(context),
* as it causes bugs without an appropriate version number (crbug.com/1145211).
* *
* If at all possible, do not use this. From a GMSCore team member: "we would not recommend * If at all possible, do not use this. From a GMSCore team member: "we would not recommend
* checking availability upfront. You should be able to just call the API directly, and it * checking availability upfront. You should be able to just call the API directly, and it
...@@ -29,13 +29,19 @@ public final class ChromiumPlayServicesAvailability { ...@@ -29,13 +29,19 @@ public final class ChromiumPlayServicesAvailability {
* the user to update GMS Core or fail with exception." If in doubt, please consult with your * the user to update GMS Core or fail with exception." If in doubt, please consult with your
* PM/UX. * PM/UX.
*/ */
public static int getGooglePlayServicesConnectionResult(final Context context) { public static boolean isGooglePlayServicesAvailable(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER); context, DEFAULT_GMS_VERSION_NUMBER)
== ConnectionResult.SUCCESS;
} }
/** /**
* Checks if Play Services is available in this context. * Gets Play Services connection result, to be used to see if Play Services are available.
*
* This is intended to replace anyone manually calling
* {@link GoogleApiAvailability#isGooglePlayServicesAvailable(context)},
* as it causes bugs without an appropriate version number (crbug.com/1145211). Use
* isGooglePlayServicesAvailable if you don't explicitly need the connection result.
* *
* If at all possible, do not use this. From a GMSCore team member: "we would not recommend * If at all possible, do not use this. From a GMSCore team member: "we would not recommend
* checking availability upfront. You should be able to just call the API directly, and it * checking availability upfront. You should be able to just call the API directly, and it
...@@ -43,9 +49,8 @@ public final class ChromiumPlayServicesAvailability { ...@@ -43,9 +49,8 @@ public final class ChromiumPlayServicesAvailability {
* the user to update GMS Core or fail with exception." If in doubt, please consult with your * the user to update GMS Core or fail with exception." If in doubt, please consult with your
* PM/UX. * PM/UX.
*/ */
public static boolean isGooglePlayServicesAvailable(final Context context) { public static int getGooglePlayServicesConnectionResult(final Context context) {
return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable( return GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(
context, GMS_VERSION_NUMBER) context, DEFAULT_GMS_VERSION_NUMBER);
== ConnectionResult.SUCCESS;
} }
} }
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