Merge "Update the Exception data structures."
This commit is contained in:
@@ -13044,6 +13044,14 @@ package android.content.res.loader {
|
||||
|
||||
package android.credentials {
|
||||
|
||||
public class ClearCredentialStateException extends java.lang.Exception {
|
||||
ctor public ClearCredentialStateException(@NonNull String, @Nullable String);
|
||||
ctor public ClearCredentialStateException(@NonNull String, @Nullable String, @Nullable Throwable);
|
||||
ctor public ClearCredentialStateException(@NonNull String, @Nullable Throwable);
|
||||
ctor public ClearCredentialStateException(@NonNull String);
|
||||
field @NonNull public final String errorType;
|
||||
}
|
||||
|
||||
public final class ClearCredentialStateRequest implements android.os.Parcelable {
|
||||
ctor public ClearCredentialStateRequest(@NonNull android.os.Bundle);
|
||||
method public int describeContents();
|
||||
@@ -13052,6 +13060,14 @@ package android.credentials {
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.credentials.ClearCredentialStateRequest> CREATOR;
|
||||
}
|
||||
|
||||
public class CreateCredentialException extends java.lang.Exception {
|
||||
ctor public CreateCredentialException(@NonNull String, @Nullable String);
|
||||
ctor public CreateCredentialException(@NonNull String, @Nullable String, @Nullable Throwable);
|
||||
ctor public CreateCredentialException(@NonNull String, @Nullable Throwable);
|
||||
ctor public CreateCredentialException(@NonNull String);
|
||||
field @NonNull public final String errorType;
|
||||
}
|
||||
|
||||
public final class CreateCredentialRequest implements android.os.Parcelable {
|
||||
ctor public CreateCredentialRequest(@NonNull String, @NonNull android.os.Bundle, @NonNull android.os.Bundle, boolean);
|
||||
method public int describeContents();
|
||||
@@ -13081,18 +13097,17 @@ package android.credentials {
|
||||
}
|
||||
|
||||
public final class CredentialManager {
|
||||
method public void clearCredentialState(@NonNull android.credentials.ClearCredentialStateRequest, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.credentials.CredentialManagerException>);
|
||||
method public void executeCreateCredential(@NonNull android.credentials.CreateCredentialRequest, @NonNull android.app.Activity, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.credentials.CreateCredentialResponse,android.credentials.CredentialManagerException>);
|
||||
method public void executeGetCredential(@NonNull android.credentials.GetCredentialRequest, @NonNull android.app.Activity, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.credentials.GetCredentialResponse,android.credentials.CredentialManagerException>);
|
||||
method public void clearCredentialState(@NonNull android.credentials.ClearCredentialStateRequest, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<java.lang.Void,android.credentials.ClearCredentialStateException>);
|
||||
method public void executeCreateCredential(@NonNull android.credentials.CreateCredentialRequest, @NonNull android.app.Activity, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.credentials.CreateCredentialResponse,android.credentials.CreateCredentialException>);
|
||||
method public void executeGetCredential(@NonNull android.credentials.GetCredentialRequest, @NonNull android.app.Activity, @Nullable android.os.CancellationSignal, @NonNull java.util.concurrent.Executor, @NonNull android.os.OutcomeReceiver<android.credentials.GetCredentialResponse,android.credentials.GetCredentialException>);
|
||||
}
|
||||
|
||||
public class CredentialManagerException extends java.lang.Exception {
|
||||
ctor public CredentialManagerException(int, @Nullable String);
|
||||
ctor public CredentialManagerException(int, @Nullable String, @Nullable Throwable);
|
||||
ctor public CredentialManagerException(int, @Nullable Throwable);
|
||||
ctor public CredentialManagerException(int);
|
||||
field public static final int ERROR_UNKNOWN = 0; // 0x0
|
||||
field public final int errorCode;
|
||||
public class GetCredentialException extends java.lang.Exception {
|
||||
ctor public GetCredentialException(@NonNull String, @Nullable String);
|
||||
ctor public GetCredentialException(@NonNull String, @Nullable String, @Nullable Throwable);
|
||||
ctor public GetCredentialException(@NonNull String, @Nullable Throwable);
|
||||
ctor public GetCredentialException(@NonNull String);
|
||||
field @NonNull public final String errorType;
|
||||
}
|
||||
|
||||
public final class GetCredentialOption implements android.os.Parcelable {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.credentials;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.OutcomeReceiver;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Represents an error encountered during the
|
||||
* {@link CredentialManager#clearCredentialState(ClearCredentialStateRequest,
|
||||
* CancellationSignal, Executor, OutcomeReceiver)} operation.
|
||||
*/
|
||||
public class ClearCredentialStateException extends Exception {
|
||||
|
||||
@NonNull
|
||||
public final String errorType;
|
||||
|
||||
/**
|
||||
* Constructs a {@link ClearCredentialStateException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public ClearCredentialStateException(@NonNull String errorType, @Nullable String message) {
|
||||
this(errorType, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ClearCredentialStateException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public ClearCredentialStateException(
|
||||
@NonNull String errorType, @Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.errorType = Preconditions.checkStringNotEmpty(errorType,
|
||||
"errorType must not be empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ClearCredentialStateException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public ClearCredentialStateException(@NonNull String errorType, @Nullable Throwable cause) {
|
||||
this(errorType, null, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link ClearCredentialStateException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public ClearCredentialStateException(@NonNull String errorType) {
|
||||
this(errorType, null, null);
|
||||
}
|
||||
}
|
||||
77
core/java/android/credentials/CreateCredentialException.java
Normal file
77
core/java/android/credentials/CreateCredentialException.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.credentials;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.OutcomeReceiver;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Represents an error encountered during the
|
||||
* {@link CredentialManager#executeCreateCredential(CreateCredentialRequest,
|
||||
* Activity, CancellationSignal, Executor, OutcomeReceiver)} operation.
|
||||
*/
|
||||
public class CreateCredentialException extends Exception {
|
||||
|
||||
@NonNull
|
||||
public final String errorType;
|
||||
|
||||
/**
|
||||
* Constructs a {@link CreateCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public CreateCredentialException(@NonNull String errorType, @Nullable String message) {
|
||||
this(errorType, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link CreateCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public CreateCredentialException(
|
||||
@NonNull String errorType, @Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.errorType = Preconditions.checkStringNotEmpty(errorType,
|
||||
"errorType must not be empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link CreateCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public CreateCredentialException(@NonNull String errorType, @Nullable Throwable cause) {
|
||||
this(errorType, null, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link CreateCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public CreateCredentialException(@NonNull String errorType) {
|
||||
this(errorType, null, null);
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public final class CredentialManager {
|
||||
@Nullable CancellationSignal cancellationSignal,
|
||||
@CallbackExecutor @NonNull Executor executor,
|
||||
@NonNull OutcomeReceiver<
|
||||
GetCredentialResponse, CredentialManagerException> callback) {
|
||||
GetCredentialResponse, GetCredentialException> callback) {
|
||||
requireNonNull(request, "request must not be null");
|
||||
requireNonNull(activity, "activity must not be null");
|
||||
requireNonNull(executor, "executor must not be null");
|
||||
@@ -121,7 +121,7 @@ public final class CredentialManager {
|
||||
@Nullable CancellationSignal cancellationSignal,
|
||||
@CallbackExecutor @NonNull Executor executor,
|
||||
@NonNull OutcomeReceiver<
|
||||
CreateCredentialResponse, CredentialManagerException> callback) {
|
||||
CreateCredentialResponse, CreateCredentialException> callback) {
|
||||
requireNonNull(request, "request must not be null");
|
||||
requireNonNull(activity, "activity must not be null");
|
||||
requireNonNull(executor, "executor must not be null");
|
||||
@@ -167,7 +167,7 @@ public final class CredentialManager {
|
||||
@NonNull ClearCredentialStateRequest request,
|
||||
@Nullable CancellationSignal cancellationSignal,
|
||||
@CallbackExecutor @NonNull Executor executor,
|
||||
@NonNull OutcomeReceiver<Void, CredentialManagerException> callback) {
|
||||
@NonNull OutcomeReceiver<Void, ClearCredentialStateException> callback) {
|
||||
requireNonNull(executor, "executor must not be null");
|
||||
requireNonNull(callback, "callback must not be null");
|
||||
|
||||
@@ -196,10 +196,10 @@ public final class CredentialManager {
|
||||
private final Activity mActivity;
|
||||
private final Executor mExecutor;
|
||||
private final OutcomeReceiver<
|
||||
GetCredentialResponse, CredentialManagerException> mCallback;
|
||||
GetCredentialResponse, GetCredentialException> mCallback;
|
||||
|
||||
private GetCredentialTransport(Activity activity, Executor executor,
|
||||
OutcomeReceiver<GetCredentialResponse, CredentialManagerException> callback) {
|
||||
OutcomeReceiver<GetCredentialResponse, GetCredentialException> callback) {
|
||||
mActivity = activity;
|
||||
mExecutor = executor;
|
||||
mCallback = callback;
|
||||
@@ -222,9 +222,9 @@ public final class CredentialManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String message) {
|
||||
public void onError(String errorType, String message) {
|
||||
mExecutor.execute(
|
||||
() -> mCallback.onError(new CredentialManagerException(errorCode, message)));
|
||||
() -> mCallback.onError(new GetCredentialException(errorType, message)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,10 +234,10 @@ public final class CredentialManager {
|
||||
private final Activity mActivity;
|
||||
private final Executor mExecutor;
|
||||
private final OutcomeReceiver<
|
||||
CreateCredentialResponse, CredentialManagerException> mCallback;
|
||||
CreateCredentialResponse, CreateCredentialException> mCallback;
|
||||
|
||||
private CreateCredentialTransport(Activity activity, Executor executor,
|
||||
OutcomeReceiver<CreateCredentialResponse, CredentialManagerException> callback) {
|
||||
OutcomeReceiver<CreateCredentialResponse, CreateCredentialException> callback) {
|
||||
mActivity = activity;
|
||||
mExecutor = executor;
|
||||
mCallback = callback;
|
||||
@@ -260,9 +260,9 @@ public final class CredentialManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String message) {
|
||||
public void onError(String errorType, String message) {
|
||||
mExecutor.execute(
|
||||
() -> mCallback.onError(new CredentialManagerException(errorCode, message)));
|
||||
() -> mCallback.onError(new CreateCredentialException(errorType, message)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,10 +271,10 @@ public final class CredentialManager {
|
||||
// TODO: listen for cancellation to release callback.
|
||||
|
||||
private final Executor mExecutor;
|
||||
private final OutcomeReceiver<Void, CredentialManagerException> mCallback;
|
||||
private final OutcomeReceiver<Void, ClearCredentialStateException> mCallback;
|
||||
|
||||
private ClearCredentialStateTransport(Executor executor,
|
||||
OutcomeReceiver<Void, CredentialManagerException> callback) {
|
||||
OutcomeReceiver<Void, ClearCredentialStateException> callback) {
|
||||
mExecutor = executor;
|
||||
mCallback = callback;
|
||||
}
|
||||
@@ -285,9 +285,9 @@ public final class CredentialManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int errorCode, String message) {
|
||||
public void onError(String errorType, String message) {
|
||||
mExecutor.execute(
|
||||
() -> mCallback.onError(new CredentialManagerException(errorCode, message)));
|
||||
() -> mCallback.onError(new ClearCredentialStateException(errorType, message)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.credentials;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
|
||||
/** Exception class for CredentialManager operations. */
|
||||
public class CredentialManagerException extends Exception {
|
||||
/** Indicates that an unknown error was encountered. */
|
||||
public static final int ERROR_UNKNOWN = 0;
|
||||
|
||||
/**
|
||||
* The given CredentialManager operation is cancelled by the user.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int ERROR_USER_CANCELLED = 1;
|
||||
|
||||
/**
|
||||
* No appropriate provider is found to support the target credential type(s).
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int ERROR_PROVIDER_NOT_FOUND = 2;
|
||||
|
||||
public final int errorCode;
|
||||
|
||||
public CredentialManagerException(int errorCode, @Nullable String message) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public CredentialManagerException(
|
||||
int errorCode, @Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public CredentialManagerException(int errorCode, @Nullable Throwable cause) {
|
||||
super(cause);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public CredentialManagerException(int errorCode) {
|
||||
super();
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
77
core/java/android/credentials/GetCredentialException.java
Normal file
77
core/java/android/credentials/GetCredentialException.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.credentials;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.OutcomeReceiver;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* Represents an error encountered during the
|
||||
* {@link CredentialManager#executeGetCredential(GetCredentialRequest,
|
||||
* Activity, CancellationSignal, Executor, OutcomeReceiver)} operation.
|
||||
*/
|
||||
public class GetCredentialException extends Exception {
|
||||
|
||||
@NonNull
|
||||
public final String errorType;
|
||||
|
||||
/**
|
||||
* Constructs a {@link GetCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public GetCredentialException(@NonNull String errorType, @Nullable String message) {
|
||||
this(errorType, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link GetCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public GetCredentialException(
|
||||
@NonNull String errorType, @Nullable String message, @Nullable Throwable cause) {
|
||||
super(message, cause);
|
||||
this.errorType = Preconditions.checkStringNotEmpty(errorType,
|
||||
"errorType must not be empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link GetCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public GetCredentialException(@NonNull String errorType, @Nullable Throwable cause) {
|
||||
this(errorType, null, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link GetCredentialException}.
|
||||
*
|
||||
* @throws IllegalArgumentException If errorType is empty.
|
||||
*/
|
||||
public GetCredentialException(@NonNull String errorType) {
|
||||
this(errorType, null, null);
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,5 @@ package android.credentials;
|
||||
*/
|
||||
interface IClearCredentialStateCallback {
|
||||
oneway void onSuccess();
|
||||
oneway void onError(int errorCode, String message);
|
||||
oneway void onError(String errorType, String message);
|
||||
}
|
||||
@@ -27,5 +27,5 @@ import android.credentials.CreateCredentialResponse;
|
||||
interface ICreateCredentialCallback {
|
||||
oneway void onPendingIntent(in PendingIntent pendingIntent);
|
||||
oneway void onResponse(in CreateCredentialResponse response);
|
||||
oneway void onError(int errorCode, String message);
|
||||
oneway void onError(String errorType, String message);
|
||||
}
|
||||
@@ -27,5 +27,5 @@ import android.credentials.GetCredentialResponse;
|
||||
interface IGetCredentialCallback {
|
||||
oneway void onPendingIntent(in PendingIntent pendingIntent);
|
||||
oneway void onResponse(in GetCredentialResponse response);
|
||||
oneway void onError(int errorCode, String message);
|
||||
oneway void onError(String errorType, String message);
|
||||
}
|
||||
Reference in New Issue
Block a user