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

Commit 9e3565b6 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Split credential manager get flow to two phases, similar to the create flow

Test: Built & deployed locally
Bug: 253155222
CTS-Coverage-Bug: 247549381

Change-Id: Idd75df44683727dc920471116a89719103ae3795
parent e8ad05e4
Loading
Loading
Loading
Loading
+49 −25
Original line number Diff line number Diff line
@@ -39472,6 +39472,40 @@ package android.service.credentials {
    method @NonNull public android.service.credentials.BeginCreateCredentialResponse.Builder setRemoteCreateEntry(@Nullable android.service.credentials.CreateEntry);
  }
  public final class BeginGetCredentialOption implements android.os.Parcelable {
    ctor public BeginGetCredentialOption(@NonNull String, @NonNull android.os.Bundle);
    method public int describeContents();
    method @NonNull public android.os.Bundle getCandidateQueryData();
    method @NonNull public String getType();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.BeginGetCredentialOption> CREATOR;
  }
  public final class BeginGetCredentialsRequest implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.List<android.service.credentials.BeginGetCredentialOption> getBeginGetCredentialOptions();
    method @NonNull public String getCallingPackage();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.BeginGetCredentialsRequest> CREATOR;
  }
  public static final class BeginGetCredentialsRequest.Builder {
    ctor public BeginGetCredentialsRequest.Builder(@NonNull String);
    method @NonNull public android.service.credentials.BeginGetCredentialsRequest.Builder addBeginGetCredentialOption(@NonNull android.service.credentials.BeginGetCredentialOption);
    method @NonNull public android.service.credentials.BeginGetCredentialsRequest build();
    method @NonNull public android.service.credentials.BeginGetCredentialsRequest.Builder setBeginGetCredentialOptions(@NonNull java.util.List<android.service.credentials.BeginGetCredentialOption>);
  }
  public final class BeginGetCredentialsResponse implements android.os.Parcelable {
    method @NonNull public static android.service.credentials.BeginGetCredentialsResponse createWithAuthentication(@NonNull android.service.credentials.Action);
    method @NonNull public static android.service.credentials.BeginGetCredentialsResponse createWithResponseContent(@NonNull android.service.credentials.CredentialsResponseContent);
    method public int describeContents();
    method @Nullable public android.service.credentials.Action getAuthenticationAction();
    method @Nullable public android.service.credentials.CredentialsResponseContent getCredentialsResponseContent();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.BeginGetCredentialsResponse> CREATOR;
  }
  public final class CreateCredentialRequest implements android.os.Parcelable {
    ctor public CreateCredentialRequest(@NonNull String, @NonNull String, @NonNull android.os.Bundle);
    method public int describeContents();
@@ -39493,8 +39527,7 @@ package android.service.credentials {
  public final class CredentialEntry implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.credentials.Credential getCredential();
    method @Nullable public android.app.PendingIntent getPendingIntent();
    method @NonNull public android.app.PendingIntent getPendingIntent();
    method @NonNull public android.app.slice.Slice getSlice();
    method @NonNull public String getType();
    method public boolean isAutoSelectAllowed();
@@ -39504,7 +39537,6 @@ package android.service.credentials {
  public static final class CredentialEntry.Builder {
    ctor public CredentialEntry.Builder(@NonNull String, @NonNull android.app.slice.Slice, @NonNull android.app.PendingIntent);
    ctor public CredentialEntry.Builder(@NonNull String, @NonNull android.app.slice.Slice, @NonNull android.credentials.Credential);
    method @NonNull public android.service.credentials.CredentialEntry build();
    method @NonNull public android.service.credentials.CredentialEntry.Builder setAutoSelectAllowed(@NonNull boolean);
  }
@@ -39521,14 +39553,16 @@ package android.service.credentials {
  public abstract class CredentialProviderService extends android.app.Service {
    ctor public CredentialProviderService();
    method public abstract void onBeginCreateCredential(@NonNull android.service.credentials.BeginCreateCredentialRequest, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.service.credentials.BeginCreateCredentialResponse,android.service.credentials.CredentialProviderException>);
    method public abstract void onBeginGetCredentials(@NonNull android.service.credentials.BeginGetCredentialsRequest, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.service.credentials.BeginGetCredentialsResponse,android.service.credentials.CredentialProviderException>);
    method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method public abstract void onGetCredentials(@NonNull android.service.credentials.GetCredentialsRequest, @NonNull android.os.CancellationSignal, @NonNull android.os.OutcomeReceiver<android.service.credentials.GetCredentialsResponse,android.service.credentials.CredentialProviderException>);
    field public static final String CAPABILITY_META_DATA_KEY = "android.credentials.capabilities";
    field public static final String EXTRA_CREATE_CREDENTIAL_EXCEPTION = "android.service.credentials.extra.CREATE_CREDENTIAL_EXCEPTION";
    field public static final String EXTRA_CREATE_CREDENTIAL_REQUEST = "android.service.credentials.extra.CREATE_CREDENTIAL_REQUEST";
    field public static final String EXTRA_CREATE_CREDENTIAL_RESULT = "android.service.credentials.extra.CREATE_CREDENTIAL_RESULT";
    field public static final String EXTRA_CREDENTIAL_RESULT = "android.service.credentials.extra.CREDENTIAL_RESULT";
    field public static final String EXTRA_ERROR = "android.service.credentials.extra.ERROR";
    field public static final String EXTRA_GET_CREDENTIALS_CONTENT_RESULT = "android.service.credentials.extra.GET_CREDENTIALS_CONTENT_RESULT";
    field public static final String EXTRA_CREATE_CREDENTIAL_RESPONSE = "android.service.credentials.extra.CREATE_CREDENTIAL_RESPONSE";
    field public static final String EXTRA_CREDENTIALS_RESPONSE_CONTENT = "android.service.credentials.extra.CREDENTIALS_RESPONSE_CONTENT";
    field public static final String EXTRA_GET_CREDENTIAL_EXCEPTION = "android.service.credentials.extra.GET_CREDENTIAL_EXCEPTION";
    field public static final String EXTRA_GET_CREDENTIAL_REQUEST = "android.service.credentials.extra.GET_CREDENTIAL_REQUEST";
    field public static final String EXTRA_GET_CREDENTIAL_RESPONSE = "android.service.credentials.extra.GET_CREDENTIAL_RESPONSE";
    field public static final String SERVICE_INTERFACE = "android.service.credentials.CredentialProviderService";
  }
@@ -39551,29 +39585,19 @@ package android.service.credentials {
    method @NonNull public android.service.credentials.CredentialsResponseContent.Builder setRemoteCredentialEntry(@Nullable android.service.credentials.CredentialEntry);
  }
  public final class GetCredentialsRequest implements android.os.Parcelable {
  public final class GetCredentialRequest implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public String getCallingPackage();
    method @NonNull public java.util.List<android.credentials.GetCredentialOption> getGetCredentialOptions();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.GetCredentialsRequest> CREATOR;
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.GetCredentialRequest> CREATOR;
  }
  public static final class GetCredentialsRequest.Builder {
    ctor public GetCredentialsRequest.Builder(@NonNull String);
    method @NonNull public android.service.credentials.GetCredentialsRequest.Builder addGetCredentialOption(@NonNull android.credentials.GetCredentialOption);
    method @NonNull public android.service.credentials.GetCredentialsRequest build();
    method @NonNull public android.service.credentials.GetCredentialsRequest.Builder setGetCredentialOptions(@NonNull java.util.List<android.credentials.GetCredentialOption>);
  }
  public final class GetCredentialsResponse implements android.os.Parcelable {
    method @NonNull public static android.service.credentials.GetCredentialsResponse createWithAuthentication(@NonNull android.service.credentials.Action);
    method @NonNull public static android.service.credentials.GetCredentialsResponse createWithResponseContent(@NonNull android.service.credentials.CredentialsResponseContent);
    method public int describeContents();
    method @Nullable public android.service.credentials.Action getAuthenticationAction();
    method @Nullable public android.service.credentials.CredentialsResponseContent getCredentialsResponseContent();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.service.credentials.GetCredentialsResponse> CREATOR;
  public static final class GetCredentialRequest.Builder {
    ctor public GetCredentialRequest.Builder(@NonNull String);
    method @NonNull public android.service.credentials.GetCredentialRequest.Builder addGetCredentialOption(@NonNull android.credentials.GetCredentialOption);
    method @NonNull public android.service.credentials.GetCredentialRequest build();
    method @NonNull public android.service.credentials.GetCredentialRequest.Builder setGetCredentialOptions(@NonNull java.util.List<android.credentials.GetCredentialOption>);
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ public final class Action implements Parcelable {
     * level authentication before displaying any content etc.
     *
     * <p> See details on usage of {@code Action} for various actionable entries in
     * {@link BeginCreateCredentialResponse} and {@link GetCredentialsResponse}.
     * {@link BeginCreateCredentialResponse} and {@link BeginGetCredentialsResponse}.
     *
     * @param slice the display content to be displayed on the UI, along with this action
     * @param pendingIntent the intent to be invoked when the user selects this action
+1 −1
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ public final class BeginCreateCredentialResponse implements Parcelable {
         *
         * <p> Once the remote credential flow is complete, the {@link android.app.Activity}
         * result should be set to {@link android.app.Activity#RESULT_OK} and an extra with the
         * {@link CredentialProviderService#EXTRA_CREATE_CREDENTIAL_RESULT} key should be populated
         * {@link CredentialProviderService#EXTRA_CREATE_CREDENTIAL_RESPONSE} key should be populated
         * with a {@link android.credentials.CreateCredentialResponse} object.
         */
        public @NonNull Builder setRemoteCreateEntry(@Nullable CreateEntry remoteCreateEntry) {
+129 −0
Original line number Diff line number Diff line
/*
 * 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.service.credentials;

import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.AnnotationValidations;
import com.android.internal.util.Preconditions;

/**
 * A specific type of credential request to be sent to the provider during the query phase of
 * a get flow. This request contains limited parameters needed to populate a list of
 * {@link CredentialEntry} on the {@link BeginGetCredentialsResponse}.
 */
public final class BeginGetCredentialOption implements Parcelable {

    /**
     * The requested credential type.
     */
    @NonNull
    private final String mType;

    /**
     * The request candidateQueryData.
     */
    @NonNull
    private final Bundle mCandidateQueryData;

    /**
     * Returns the requested credential type.
     */
    @NonNull
    public String getType() {
        return mType;
    }

    /**
     * Returns the request candidate query data, denoting a set of parameters
     * that can be used to populate a candidate list of credentials, as
     * {@link CredentialEntry} on {@link BeginGetCredentialsResponse}. This list
     * of entries is then presented to the user on a selector.
     *
     * <p>This data does not contain any sensitive parameters, and will be sent
     * to all eligible providers.
     * The complete set of parameters will only be set on the {@link android.app.PendingIntent}
     * set on the {@link CredentialEntry} that is selected by the user.
     */
    @NonNull
    public Bundle getCandidateQueryData() {
        return mCandidateQueryData;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString8(mType);
        dest.writeBundle(mCandidateQueryData);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public String toString() {
        return "GetCredentialOption {"
                + "type=" + mType
                + ", candidateQueryData=" + mCandidateQueryData
                + "}";
    }

    /**
     * Constructs a {@link BeginGetCredentialOption}.
     *
     * @param type the requested credential type
     * @param candidateQueryData the request candidateQueryData
     *
     * @throws IllegalArgumentException If type is empty.
     */
    public BeginGetCredentialOption(
            @NonNull String type,
            @NonNull Bundle candidateQueryData) {
        mType = Preconditions.checkStringNotEmpty(type, "type must not be empty");
        mCandidateQueryData = requireNonNull(
                candidateQueryData, "candidateQueryData must not be null");
    }

    private BeginGetCredentialOption(@NonNull Parcel in) {
        String type = in.readString8();
        Bundle candidateQueryData = in.readBundle();

        mType = type;
        AnnotationValidations.validate(NonNull.class, null, mType);
        mCandidateQueryData = candidateQueryData;
        AnnotationValidations.validate(NonNull.class, null, mCandidateQueryData);
    }

    public static final @NonNull Creator<BeginGetCredentialOption> CREATOR =
            new Creator<BeginGetCredentialOption>() {
                @Override
                public BeginGetCredentialOption[] newArray(int size) {
                    return new BeginGetCredentialOption[size];
                }

                @Override
                public BeginGetCredentialOption createFromParcel(@NonNull Parcel in) {
                    return new BeginGetCredentialOption(in);
                }
            };
}
+1 −1
Original line number Diff line number Diff line
package android.service.credentials;

parcelable GetCredentialsRequest;
 No newline at end of file
parcelable BeginGetCredentialsRequest;
 No newline at end of file
Loading