From 832ee232eaa0da367e284cc800ef62e3e6cc4a93 Mon Sep 17 00:00:00 2001 From: Christian Grigis Date: Fri, 11 Sep 2020 17:12:10 +0200 Subject: [PATCH] Add ApiException and use it in EN client impl --- .../android/gms/common/api/ApiException.java | 57 +++++++++++++++++++ .../ExposureNotificationClientImpl.java | 15 ++--- 2 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 play-services-basement/src/main/java/com/google/android/gms/common/api/ApiException.java diff --git a/play-services-basement/src/main/java/com/google/android/gms/common/api/ApiException.java b/play-services-basement/src/main/java/com/google/android/gms/common/api/ApiException.java new file mode 100644 index 00000000..c508b301 --- /dev/null +++ b/play-services-basement/src/main/java/com/google/android/gms/common/api/ApiException.java @@ -0,0 +1,57 @@ +package com.google.android.gms.common.api; + +import com.google.android.gms.common.api.Status; + +import org.microg.gms.common.PublicApi; + +/** + * Exception to be returned by a Task when a call to Google Play services has failed. + */ +@PublicApi +public class ApiException extends Exception { + /** + * @deprecated use {@link #getStatus()} instead + */ + @PublicApi + protected final Status mStatus; + + /** + * Create an ApiException from a {@link com.google.android.gms.common.api.Status}. + * @param status the Status instance containing a message and code. + */ + @PublicApi + public ApiException(Status status) { + mStatus = status; + } + + /** + * Returns the status of the operation. + */ + @PublicApi + public Status getStatus() { + return mStatus; + } + + /** + * Indicates the status of the operation. + * @return Status code resulting from the operation. + * The value is one of the constants in {@link com.google.android.gms.common.api.CommonStatusCodes} or specific to the API in use. + */ + @PublicApi + public int getStatusCode() { + return mStatus.getStatusCode(); + } + + /** + * @deprecated use {@link #getMessage()} for a summary of the cause. + */ + @PublicApi + public String getStatusMessage() { + return getMessage(); + } + + @Override + public String getMessage() { + return mStatus.getStatusMessage(); + } +} diff --git a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java index 5dec37ea..ab89f2ca 100644 --- a/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java +++ b/play-services-nearby/src/main/java/org/microg/gms/nearby/ExposureNotificationClientImpl.java @@ -10,6 +10,7 @@ import android.os.ParcelFileDescriptor; import android.util.Log; import com.google.android.gms.common.api.Api; +import com.google.android.gms.common.api.ApiException; import com.google.android.gms.common.api.GoogleApi; import com.google.android.gms.common.api.Status; import com.google.android.gms.common.api.internal.ApiKey; @@ -58,7 +59,7 @@ public class ExposureNotificationClientImpl extends GoogleApi