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

Commit cd440a6d authored by Helen Qin's avatar Helen Qin
Browse files

[CredMan UI API] Expose isShowAllOptionsRequested in RequestInfo

Bug: 323934522
Test: cts (atest CtsCredentialManagerTestCases) & e2e tested
Change-Id: Ie66e51aa36dc2dcdd647ef5a84de1a910319f33d
parent 8ae6fefd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4504,6 +4504,7 @@ package android.credentials.selection {
    method @NonNull public android.credentials.selection.RequestToken getRequestToken();
    method @NonNull public String getType();
    method public boolean hasPermissionToOverrideDefault();
    method public boolean isShowAllOptionsRequested();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.credentials.selection.RequestInfo> CREATOR;
    field @NonNull public static final String TYPE_CREATE = "android.credentials.selection.TYPE_CREATE";
+2 −2
Original line number Diff line number Diff line
@@ -1347,8 +1347,8 @@ package android.credentials.selection {
  }

  @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public final class RequestInfo implements android.os.Parcelable {
    method @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") @NonNull public static android.credentials.selection.RequestInfo newCreateRequestInfo(@NonNull android.os.IBinder, @NonNull android.credentials.CreateCredentialRequest, @NonNull String, boolean, @NonNull java.util.List<java.lang.String>);
    method @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") @NonNull public static android.credentials.selection.RequestInfo newGetRequestInfo(@NonNull android.os.IBinder, @NonNull android.credentials.GetCredentialRequest, @NonNull String, boolean);
    method @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") @NonNull public static android.credentials.selection.RequestInfo newCreateRequestInfo(@NonNull android.os.IBinder, @NonNull android.credentials.CreateCredentialRequest, @NonNull String, boolean, @NonNull java.util.List<java.lang.String>, boolean);
    method @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") @NonNull public static android.credentials.selection.RequestInfo newGetRequestInfo(@NonNull android.os.IBinder, @NonNull android.credentials.GetCredentialRequest, @NonNull String, boolean, boolean);
  }

  @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public final class RequestToken {
+30 −5
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ public final class RequestInfo implements Parcelable {

    private final boolean mHasPermissionToOverrideDefault;

    private final boolean mIsShowAllOptionsRequested;

    /**
     * Creates new {@code RequestInfo} for a create-credential flow.
     *
@@ -121,10 +123,10 @@ public final class RequestInfo implements Parcelable {
    public static RequestInfo newCreateRequestInfo(
            @NonNull IBinder token, @NonNull CreateCredentialRequest createCredentialRequest,
            @NonNull String appPackageName, boolean hasPermissionToOverrideDefault,
            @NonNull List<String> defaultProviderIds) {
            @NonNull List<String> defaultProviderIds, boolean isShowAllOptionsRequested) {
        return new RequestInfo(
                token, TYPE_CREATE, appPackageName, createCredentialRequest, null,
                hasPermissionToOverrideDefault, defaultProviderIds);
                hasPermissionToOverrideDefault, defaultProviderIds, isShowAllOptionsRequested);
    }

    /**
@@ -137,11 +139,12 @@ public final class RequestInfo implements Parcelable {
    @NonNull
    public static RequestInfo newGetRequestInfo(
            @NonNull IBinder token, @NonNull GetCredentialRequest getCredentialRequest,
            @NonNull String appPackageName, boolean hasPermissionToOverrideDefault) {
            @NonNull String appPackageName, boolean hasPermissionToOverrideDefault,
            boolean isShowAllOptionsRequested) {
        return new RequestInfo(
                token, TYPE_GET, appPackageName, null, getCredentialRequest,
                hasPermissionToOverrideDefault,
                /*defaultProviderIds=*/ new ArrayList<>());
                /*defaultProviderIds=*/ new ArrayList<>(), isShowAllOptionsRequested);
    }


@@ -218,12 +221,31 @@ public final class RequestInfo implements Parcelable {
        return mGetCredentialRequest;
    }

    /**
     * Returns true if all options should be immediately displayed in the UI, and false otherwise.
     *
     * Normally this bit is set to false, upon which the selection UI should first display a
     * condensed view of popular, deduplicated options that is determined based on signals like
     * last-used timestamps, credential type priorities, and preferred providers configured from the
     * user settings {@link #getDefaultProviderIds()}; at the same time, the UI should offer an
     * option (button) that navigates the user to viewing all options from this condensed view.
     *
     * In some special occasions, e.g. when a request is initiated from the autofill drop-down
     * suggestion, this bit will be set to true to indicate that the selection UI should immediately
     * render the all option UI. This means that the request initiator has collected a user signal
     * to confirm that the user wants to view all the available options at once.
     */
    public boolean isShowAllOptionsRequested() {
        return mIsShowAllOptionsRequested;
    }

    private RequestInfo(@NonNull IBinder token, @NonNull @RequestType String type,
            @NonNull String appPackageName,
            @Nullable CreateCredentialRequest createCredentialRequest,
            @Nullable GetCredentialRequest getCredentialRequest,
            boolean hasPermissionToOverrideDefault,
            @NonNull List<String> defaultProviderIds) {
            @NonNull List<String> defaultProviderIds,
            boolean isShowAllOptionsRequested) {
        mToken = token;
        mType = type;
        mAppPackageName = appPackageName;
@@ -232,6 +254,7 @@ public final class RequestInfo implements Parcelable {
        mHasPermissionToOverrideDefault = hasPermissionToOverrideDefault;
        mDefaultProviderIds = defaultProviderIds == null ? new ArrayList<>() : defaultProviderIds;
        mRegistryProviderIds = new ArrayList<>();
        mIsShowAllOptionsRequested = isShowAllOptionsRequested;
    }

    private RequestInfo(@NonNull Parcel in) {
@@ -254,6 +277,7 @@ public final class RequestInfo implements Parcelable {
        mHasPermissionToOverrideDefault = in.readBoolean();
        mDefaultProviderIds = in.createStringArrayList();
        mRegistryProviderIds = in.createStringArrayList();
        mIsShowAllOptionsRequested = in.readBoolean();
    }

    @Override
@@ -266,6 +290,7 @@ public final class RequestInfo implements Parcelable {
        dest.writeBoolean(mHasPermissionToOverrideDefault);
        dest.writeStringList(mDefaultProviderIds);
        dest.writeStringList(mRegistryProviderIds);
        dest.writeBoolean(mIsShowAllOptionsRequested);
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -108,7 +108,8 @@ class CredentialManagerRepo(
        isReqForAllOptions = intent.getBooleanExtra(
                Constants.EXTRA_REQ_FOR_ALL_OPTIONS,
                /*defaultValue=*/ false
        )
        ) || (requestInfo?.isShowAllOptionsRequested ?: false) // TODO(b/323552850) - Remove
        // usage on Constants.EXTRA_REQ_FOR_ALL_OPTIONS once it is deprecated.

        val cancellationRequest = getCancelUiRequest(intent)
        val cancelUiRequestState = cancellationRequest?.let {
+4 −2
Original line number Diff line number Diff line
@@ -103,14 +103,16 @@ public final class CreateRequestSession extends RequestSession<CreateCredentialR
                flattenedPrimaryProviders.add(cn.flattenToString());
            }

            final boolean isShowAllOptionsRequested = false;
            mPendingIntent = mCredentialManagerUi.createPendingIntent(
                    RequestInfo.newCreateRequestInfo(
                            mRequestId, mClientRequest,
                            mClientAppInfo.getPackageName(),
                            PermissionUtils.hasPermission(mContext, mClientAppInfo.getPackageName(),
                                    Manifest.permission.CREDENTIAL_MANAGER_SET_ALLOWED_PROVIDERS),
                            /*defaultProviderId=*/flattenedPrimaryProviders),
                    providerDataList, /*isRequestForAllOptions=*/ false);
                            /*defaultProviderId=*/flattenedPrimaryProviders,
                            isShowAllOptionsRequested),
                    providerDataList, /*isRequestForAllOptions=*/ isShowAllOptionsRequested);
            mClientCallback.onPendingIntent(mPendingIntent);
        } catch (RemoteException e) {
            mRequestSessionMetric.collectUiReturnedFinalPhase(/*uiReturned=*/ false);
Loading