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

Commit 920aebb8 authored by Helen Qin's avatar Helen Qin
Browse files

Rewrite the UI interface in prepare for SystemAPI exposure

Test: build & atest CtsCredentialManagerTestCases
Bug: 322065508
Bug: 322065247
Change-Id: Ifa7ddf854073f49160e59a922c66b97254cf5882
parent 684fbcb5
Loading
Loading
Loading
Loading
+37 −20
Original line number Diff line number Diff line
@@ -34,15 +34,24 @@ import java.lang.annotation.RetentionPolicy;
/**
 * An authentication entry.
 *
 * Applicable only for credential retrieval flow, authentication entries are a special type of
 * entries that require the user to unlock the given provider before its credential options can
 * be fully rendered.
 *
 * @hide
 */
@TestApi
public final class AuthenticationEntry implements Parcelable {
    @NonNull private final String mKey;
    @NonNull private final String mSubkey;
    @NonNull private final @Status int mStatus;
    @Nullable private Intent mFrameworkExtrasIntent;
    @NonNull private final Slice mSlice;
    @NonNull
    private final String mKey;
    @NonNull
    private final String mSubkey;
    @NonNull
    private final @Status int mStatus;
    @Nullable
    private Intent mFrameworkExtrasIntent;
    @NonNull
    private final Slice mSlice;

    /** @hide **/
    @IntDef(prefix = {"STATUS_"}, value = {
@@ -51,15 +60,21 @@ public final class AuthenticationEntry implements Parcelable {
            STATUS_UNLOCKED_BUT_EMPTY_MOST_RECENT,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Status {}
    public @interface Status {
    }

    /** This entry is still locked, as initially supplied by the provider. */
    public static final int STATUS_LOCKED = 0;
    /** This entry was unlocked but didn't contain any credential. Meanwhile, "less recent" means
     *  there is another such entry that was unlocked more recently. */
    /**
     * This entry was unlocked but didn't contain any credential. Meanwhile, "less recent" means
     * there is another such entry that was unlocked more recently.
     */
    public static final int STATUS_UNLOCKED_BUT_EMPTY_LESS_RECENT = 1;
    /** This is the most recent entry that was unlocked but didn't contain any credential.
     *  There should be at most one authentication entry with this status. */
    /**
     * This is the most recent entry that was unlocked but didn't contain any credential.
     *
     * There will be at most one authentication entry with this status.
     */
    public static final int STATUS_UNLOCKED_BUT_EMPTY_MOST_RECENT = 2;

    private AuthenticationEntry(@NonNull Parcel in) {
@@ -74,9 +89,11 @@ public final class AuthenticationEntry implements Parcelable {
        AnnotationValidations.validate(NonNull.class, null, mSlice);
    }

    /** Constructor to be used for an entry that does not require further activities
    /**
     * Constructor to be used for an entry that does not require further activities
     * to be invoked when selected.
     */
    // TODO(b/322065508): remove this constructor.
    public AuthenticationEntry(@NonNull String key, @NonNull String subkey, @NonNull Slice slice,
            @Status int status) {
        mKey = key;
@@ -95,8 +112,8 @@ public final class AuthenticationEntry implements Parcelable {
    }

    /**
    * Returns the identifier of this entry that's unique within the context of the CredentialManager
    * request.
     * Returns the identifier of this entry that's unique within the context of the
     * CredentialManager request.
     */
    @NonNull
    public String getKey() {
@@ -111,23 +128,23 @@ public final class AuthenticationEntry implements Parcelable {
        return mSubkey;
    }

    /**
    * Returns the Slice to be rendered.
    */
    /** Returns the Slice to be rendered. */
    @NonNull
    public Slice getSlice() {
        return mSlice;
    }

    /**
     * Returns the entry status.
     */
    /** Returns the entry status, depending on which the entry will be rendered differently. */
    @NonNull
    @Status
    public int getStatus() {
        return mStatus;
    }

    /**
     * Returns the framework intent to be filled in when launching this entry's provider
     * PendingIntent.
     */
    @Nullable
    @SuppressLint("IntentBuilderName") // Not building a new intent.
    public Intent getFrameworkExtrasIntent() {
+17 −16
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@ import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.util.AnnotationValidations;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@@ -66,13 +64,14 @@ public class BaseDialogResult implements Parcelable {
            RESULT_CODE_DATA_PARSING_FAILURE,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ResultCode {}
    public @interface ResultCode {
    }

    /** User intentionally canceled the dialog. */
    public static final int RESULT_CODE_DIALOG_USER_CANCELED = 0;
    /**
     * The user has consented to switching to a new default provider. The provider info is in the
     * {@code resultData}.
     * The UI was stopped since the user has chosen to navigate to the Settings UI to reconfigure
     * their providers.
     */
    public static final int RESULT_CODE_CANCELED_AND_LAUNCHED_SETTINGS = 1;
    /**
@@ -86,6 +85,7 @@ public class BaseDialogResult implements Parcelable {
    public static final int RESULT_CODE_DATA_PARSING_FAILURE = 3;

    @Nullable
    @Deprecated
    private final IBinder mRequestToken;

    public BaseDialogResult(@Nullable IBinder requestToken) {
@@ -94,6 +94,7 @@ public class BaseDialogResult implements Parcelable {

    /** Returns the unique identifier for the request that launched the operation. */
    @Nullable
    @Deprecated
    public IBinder getRequestToken() {
        return mRequestToken;
    }
+13 −4
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.os.Parcelable;
import com.android.internal.util.AnnotationValidations;

/**
 * A request to cancel any ongoing UI matching this request.
 * A request to cancel the ongoing UI matching the identifier token in this request.
 *
 * @hide
 */
@@ -33,9 +33,12 @@ public final class CancelUiRequest implements Parcelable {
    /**
     * The intent extra key for the {@code CancelUiRequest} object when launching the UX
     * activities.
     *
     * @hide
     */
    @NonNull public static final String EXTRA_CANCEL_UI_REQUEST =
            "android.credentials.ui.extra.EXTRA_CANCEL_UI_REQUEST";
    @NonNull
    public static final String EXTRA_CANCEL_UI_REQUEST =
            "android.credentials.ui.extra.CANCEL_UI_REQUEST";

    @NonNull
    private final IBinder mToken;
@@ -51,6 +54,10 @@ public final class CancelUiRequest implements Parcelable {
        return mToken;
    }

    /**
     * Returns the app package name invoking this request, that can be used to derive display
     * metadata (e.g. "Cancelled by `App Name`").
     */
    @NonNull
    public String getAppPackageName() {
        return mAppPackageName;
@@ -64,6 +71,7 @@ public final class CancelUiRequest implements Parcelable {
        return mShouldShowCancellationUi;
    }

    /** Constructs a {@link CancelUiRequest}. */
    public CancelUiRequest(@NonNull IBinder token, boolean shouldShowCancellationUi,
            @NonNull String appPackageName) {
        mToken = token;
@@ -91,7 +99,8 @@ public final class CancelUiRequest implements Parcelable {
        return 0;
    }

    @NonNull public static final Creator<CancelUiRequest> CREATOR = new Creator<>() {
    @NonNull
    public static final Creator<CancelUiRequest> CREATOR = new Creator<>() {
        @Override
        public CancelUiRequest createFromParcel(@NonNull Parcel in) {
            return new CancelUiRequest(in);
+1 −3
Original line number Diff line number Diff line
@@ -36,7 +36,5 @@ public class Constants {
    public static final String EXTRA_REQ_FOR_ALL_OPTIONS =
            "android.credentials.ui.extra.REQ_FOR_ALL_OPTIONS";

    /** The intent action for when the enabled Credential Manager providers has been updated. */
    public static final String CREDMAN_ENABLED_PROVIDERS_UPDATED =
            "android.credentials.ui.action.CREDMAN_ENABLED_PROVIDERS_UPDATED";
    private Constants() {}
}
+11 −0
Original line number Diff line number Diff line
@@ -47,6 +47,17 @@ public final class CreateCredentialProviderData extends ProviderData implements
        mRemoteEntry = remoteEntry;
    }

    /**
     * Converts the instance to a {@link CreateCredentialProviderInfo}.
     *
     * @hide
     */
    @NonNull
    public CreateCredentialProviderInfo toCreateCredentialProviderInfo() {
        return new CreateCredentialProviderInfo(
                getProviderFlattenedComponentName(), mSaveEntries, mRemoteEntry);
    }

    @NonNull
    public List<Entry> getSaveEntries() {
        return mSaveEntries;
Loading