mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2024-11-19 02:29:25 +01:00
Add ApiException and use it in EN client impl
This commit is contained in:
parent
bd20634bd9
commit
832ee232ea
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@ import android.os.ParcelFileDescriptor;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.gms.common.api.Api;
|
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.GoogleApi;
|
||||||
import com.google.android.gms.common.api.Status;
|
import com.google.android.gms.common.api.Status;
|
||||||
import com.google.android.gms.common.api.internal.ApiKey;
|
import com.google.android.gms.common.api.internal.ApiKey;
|
||||||
@ -58,7 +59,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(null);
|
completionSource.setResult(null);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -79,7 +80,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(null);
|
completionSource.setResult(null);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -100,7 +101,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(result);
|
completionSource.setResult(result);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -121,7 +122,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(result);
|
completionSource.setResult(result);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -161,7 +162,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(null);
|
completionSource.setResult(null);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, fds, configuration, token);
|
}, fds, configuration, token);
|
||||||
@ -182,7 +183,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(result);
|
completionSource.setResult(result);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, token);
|
}, token);
|
||||||
@ -203,7 +204,7 @@ public class ExposureNotificationClientImpl extends GoogleApi<Api.ApiOptions.NoO
|
|||||||
if (status == Status.SUCCESS) {
|
if (status == Status.SUCCESS) {
|
||||||
completionSource.setResult(result);
|
completionSource.setResult(result);
|
||||||
} else {
|
} else {
|
||||||
completionSource.setException(new RuntimeException("Status: " + status));
|
completionSource.setException(new ApiException(status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, token);
|
}, token);
|
||||||
|
Loading…
Reference in New Issue
Block a user