diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/api/ResolvableApiException.java b/play-services-basement/src/main/java/com/google/android/gms/common/api/ResolvableApiException.java new file mode 100644 index 00000000..22dc6ed0 --- /dev/null +++ b/play-services-basement/src/main/java/com/google/android/gms/common/api/ResolvableApiException.java @@ -0,0 +1,46 @@ +package com.google.android.gms.common.api; + +import android.app.Activity; +import android.app.PendingIntent; +import android.content.Intent; +import android.content.IntentSender; + +import org.microg.gms.common.PublicApi; + +/** + * Exception to be returned by a Task when a call to Google Play services has failed with a + * possible resolution. + */ +@PublicApi +public class ResolvableApiException extends ApiException { + @PublicApi + public ResolvableApiException(Status status) { + super(status); + } + + /** + * A pending intent to resolve the failure. This intent can be started with + * {@link android.app.Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int)} + * to present UI to solve the issue. + * @return The pending intent to resolve the failure. + */ + @PublicApi + public PendingIntent getResolution() { + return mStatus.getResolution(); + } + + /** + * Resolves an error by starting any intents requiring user interaction. + * See {@link com.google.android.gms.common.api.CommonStatusCodes#SIGN_IN_REQUIRED}, and + * {@link com.google.android.gms.common.api.CommonStatusCodes#RESOLUTION_REQUIRED}. + * @param activity An Activity context to use to resolve the issue. The activity's + * onActivityResult method will be invoked after the user is done. + * If the resultCode is {@link android.app.Activity#RESULT_OK}, + * the application should try to connect again. + * @param requestCode The request code to pass to onActivityResult. + */ + @PublicApi + public void startResolutionForResult(Activity activity, int requestCode) throws IntentSender.SendIntentException { + mStatus.startResolutionForResult(activity, requestCode); + } +}