Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c081eeb7 authored by Reema Bajwa's avatar Reema Bajwa Committed by Android (Google) Code Review
Browse files

Merge "Handling all UI event codes and exposing new type constant"

parents 8e9685c4 fe4de436
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -13465,7 +13465,7 @@ package android.credentials {
    ctor public CreateCredentialException(@NonNull String);
    method @NonNull public String getType();
    field @NonNull public static final String TYPE_INTERRUPTED = "android.credentials.CreateCredentialException.TYPE_INTERRUPTED";
    field @NonNull public static final String TYPE_NO_CREDENTIAL = "android.credentials.CreateCredentialException.TYPE_NO_CREDENTIAL";
    field @NonNull public static final String TYPE_NO_CREATE_OPTIONS = "android.credentials.CreateCredentialException.TYPE_NO_CREATE_OPTIONS";
    field @NonNull public static final String TYPE_UNKNOWN = "android.credentials.CreateCredentialException.TYPE_UNKNOWN";
    field @NonNull public static final String TYPE_USER_CANCELED = "android.credentials.CreateCredentialException.TYPE_USER_CANCELED";
  }
@@ -40242,6 +40242,7 @@ package android.service.credentials {
  }
  public final class BeginCreateCredentialResponse implements android.os.Parcelable {
    ctor public BeginCreateCredentialResponse();
    method public int describeContents();
    method @NonNull public java.util.List<android.service.credentials.CreateEntry> getCreateEntries();
    method @Nullable public android.service.credentials.CreateEntry getRemoteCreateEntry();
@@ -40283,6 +40284,7 @@ package android.service.credentials {
  }
  public final class BeginGetCredentialResponse implements android.os.Parcelable {
    ctor public BeginGetCredentialResponse();
    method public int describeContents();
    method @NonNull public java.util.List<android.service.credentials.Action> getActions();
    method @NonNull public java.util.List<android.service.credentials.Action> getAuthenticationActions();
+4 −4
Original line number Diff line number Diff line
@@ -40,13 +40,13 @@ public class CreateCredentialException extends Exception {
            "android.credentials.CreateCredentialException.TYPE_UNKNOWN";

    /**
     * The error type value for when no credential is available for the given {@link
     * CredentialManager#createCredential(CreateCredentialRequest, Activity,
     * The error type value for when no create options are available from any provider(s),
     * for the given {@link CredentialManager#createCredential(CreateCredentialRequest, Activity,
     * CancellationSignal, Executor, OutcomeReceiver)} request.
     */
    @NonNull
    public static final String TYPE_NO_CREDENTIAL =
            "android.credentials.CreateCredentialException.TYPE_NO_CREDENTIAL";
    public static final String TYPE_NO_CREATE_OPTIONS =
            "android.credentials.CreateCredentialException.TYPE_NO_CREATE_OPTIONS";
    /**
     * The error type value for when the user intentionally cancelled the request.
     *
+8 −5
Original line number Diff line number Diff line
@@ -34,6 +34,14 @@ public final class BeginCreateCredentialResponse implements Parcelable {
    private final @NonNull List<CreateEntry> mCreateEntries;
    private final @Nullable CreateEntry mRemoteCreateEntry;

    /**
     * Creates an empty response instance, to be used when there are no {@link CreateEntry}
     * to return.
     */
    public BeginCreateCredentialResponse() {
        this(/*createEntries=*/new ArrayList<>(), /*remoteCreateEntry=*/null);
    }

    private BeginCreateCredentialResponse(@NonNull Parcel in) {
        List<CreateEntry> createEntries = new ArrayList<>();
        in.readTypedList(createEntries, CreateEntry.CREATOR);
@@ -137,13 +145,8 @@ public final class BeginCreateCredentialResponse implements Parcelable {

        /**
         * Builds a new instance of {@link BeginCreateCredentialResponse}.
         *
         * @throws NullPointerException If {@code createEntries} is null.
         * @throws IllegalArgumentException If {@code createEntries} is empty.
         */
        public @NonNull BeginCreateCredentialResponse build() {
            Preconditions.checkCollectionNotEmpty(mCreateEntries, "createEntries must "
                    + "not be null, or empty");
            return new BeginCreateCredentialResponse(mCreateEntries, mRemoteCreateEntry);
        }
    }
+11 −8
Original line number Diff line number Diff line
@@ -44,6 +44,17 @@ public final class BeginGetCredentialResponse implements Parcelable {
    /** Remote credential entry to get the response from a different device. */
    private final @Nullable CredentialEntry mRemoteCredentialEntry;

    /**
     * Creates an empty response instance, to be used when there are no {@link CredentialEntry},
     * or {@link Action} to return.
     */
    public BeginGetCredentialResponse() {
        this(/*credentialEntries=*/new ArrayList<>(),
                /*authenticationActions=*/new ArrayList<>(),
                /*actions=*/new ArrayList<>(),
                /*remoteCredentialEntry=*/null);
    }

    private BeginGetCredentialResponse(@NonNull List<CredentialEntry> credentialEntries,
            @NonNull List<Action> authenticationEntries, @NonNull List<Action> actions,
            @Nullable CredentialEntry remoteCredentialEntry) {
@@ -243,16 +254,8 @@ public final class BeginGetCredentialResponse implements Parcelable {

        /**
         * Builds a {@link BeginGetCredentialResponse} instance.
         *
         * @throws IllegalStateException if {@code credentialEntries}, {@code actions}
         *                               and {@code remoteCredentialEntry} are all null or empty.
         */
        public @NonNull BeginGetCredentialResponse build() {
            if (mCredentialEntries.isEmpty() && mActions.isEmpty()
                    && mRemoteCredentialEntry == null && mAuthenticationEntries.isEmpty()) {
                throw new IllegalStateException("must set either an authentication, "
                        + "credential, action or remote entry");
            }
            return new BeginGetCredentialResponse(mCredentialEntries, mAuthenticationEntries,
                    mActions, mRemoteCredentialEntry);
        }
+9 −3
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
        if (response != null) {
            respondToClientWithResponseAndFinish(response);
        } else {
            respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL,
            respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                    "Invalid response");
        }
    }
@@ -119,6 +119,12 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
        }
    }

    @Override
    public void onUiSelectorInvocationFailure() {
        respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                "No create options available.");
    }

    private void respondToClientWithResponseAndFinish(CreateCredentialResponse response) {
        Log.i(TAG, "respondToClientWithResponseAndFinish");
        if (isSessionCancelled()) {
@@ -166,8 +172,8 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                Log.i(TAG, "in onProviderStatusChanged - isUiInvocationNeeded");
                getProviderDataAndInitiateUi();
            } else {
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREDENTIAL,
                        "No credentials available");
                respondToClientWithErrorAndFinish(CreateCredentialException.TYPE_NO_CREATE_OPTIONS,
                        "No create options available.");
            }
        }
    }
Loading