| Index: chrome/android/java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java
|
| index d1a18e6dc98e32699174337c3027a3bf5be89458..e1a78dca9cbde27ed03536075b517b2d14405945 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/externalauth/ExternalAuthUtils.java
|
| @@ -194,23 +194,35 @@ public class ExternalAuthUtils {
|
| */
|
| public boolean canUseGooglePlayServices(
|
| final Context context, final UserRecoverableErrorHandler errorHandler) {
|
| + return canUseGooglePlayServicesResultCode(context, errorHandler)
|
| + == ConnectionResult.SUCCESS;
|
| + }
|
| +
|
| + /**
|
| + * Same as {@link #canUseGooglePlayServices(Context, UserRecoverableErrorHandler)}.
|
| + * @param context The current context.
|
| + * @param errorHandler How to handle user-recoverable errors; must be non-null.
|
| + * @return the result code specifying Google Play Services availability.
|
| + */
|
| + public int canUseGooglePlayServicesResultCode(
|
| + final Context context, final UserRecoverableErrorHandler errorHandler) {
|
| final int resultCode = checkGooglePlayServicesAvailable(context);
|
| recordConnectionResult(resultCode);
|
| - if (resultCode == ConnectionResult.SUCCESS) {
|
| - return true; // Hooray!
|
| - }
|
| - // resultCode is some kind of error.
|
| - Log.v(TAG, "Unable to use Google Play Services: %s", describeError(resultCode));
|
| - if (isUserRecoverableError(resultCode)) {
|
| - Runnable errorHandlerTask = new Runnable() {
|
| - @Override
|
| - public void run() {
|
| - errorHandler.handleError(context, resultCode);
|
| - }
|
| - };
|
| - ThreadUtils.runOnUiThread(errorHandlerTask);
|
| + if (resultCode != ConnectionResult.SUCCESS) {
|
| + // resultCode is some kind of error.
|
| + Log.v(TAG, "Unable to use Google Play Services: %s", describeError(resultCode));
|
| +
|
| + if (isUserRecoverableError(resultCode)) {
|
| + Runnable errorHandlerTask = new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + errorHandler.handleError(context, resultCode);
|
| + }
|
| + };
|
| + ThreadUtils.runOnUiThread(errorHandlerTask);
|
| + }
|
| }
|
| - return false;
|
| + return resultCode;
|
| }
|
|
|
| /**
|
| @@ -268,6 +280,18 @@ public class ExternalAuthUtils {
|
| }
|
|
|
| /**
|
| + * @param errorCode returned by {@link #checkGooglePlayServicesAvailable(Context)}.
|
| + * @return true if the error code indicates that an invalid version of Google Play Services is
|
| + * installed.
|
| + */
|
| + public boolean isGooglePlayServicesUpdateRequiredError(int errorCode) {
|
| + return errorCode == ConnectionResult.SERVICE_UPDATING
|
| + || errorCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED
|
| + || errorCode == ConnectionResult.SERVICE_DISABLED
|
| + || errorCode == ConnectionResult.SERVICE_MISSING;
|
| + }
|
| +
|
| + /**
|
| * Invokes whatever external code is necessary to check if the specified error code produced
|
| * by {@link #checkGooglePlayServicesAvailable(Context)} represents a user-recoverable error.
|
| * Subclasses can override to filter error codes as desired.
|
|
|