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

Commit b00abb87 authored by Reema Bajwa's avatar Reema Bajwa
Browse files

Consolidate inline dropdown and callback conversion

android.autofillservice.cts (7 Tests)
[1/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_selectCredentialThenNonCredential: PASSED (4.575s)
[2/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#getCredentialProviderServices_returnsAllProviders: PASSED (1.083s)
[3/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_startAndEndWithNonCredential: PASSED (3.669s)
[4/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_startAndEndWithCredential: PASSED (3.542s)
[5/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_selectNonCredentialThenCredential: PASSED (3.166s)
[6/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_selectNonCredentialView: PASSED (2.211s)
[7/7] android.autofillservice.cts.inline.InlineLoginMixedCredentialActivityTest#testAutofill_selectCredentialView: PASSED (2.288s)

Summary (Test executed with 1 devices.)
-------
arm64-v8a CtsAutoFillServiceTestCases: Passed: 7, Failed: 0, Ignored: 0, Assumption Failed: 0

All tests passed!
Test Logs have been saved in /tmp/atest_result_reemabajwa/20240206_083457_jtja6t6d/log
Run 'atest --history' to review test result history.

To access logs, press "ctrl" and click on
file:///tmp/atest_result_reemabajwa/20240206_083457_jtja6t6d/log/test_logs.html

Test: Built & deployed locally
Bug: 302000646

Change-Id: I9c6ced4fa85cecf34fe4c20d1580013bfade96bf
parent b416a714
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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;

/**
 * Constants for credential manager service that doesn't fit into other structures
 *
 * @hide
 */
public class Constants {
    /**
     * The request is success and user selected an entry
     */
    public static final int SUCCESS_CREDMAN_SELECTOR = 0;
    /**
     * The error code for ui getting cancelled by user
     */
    public static final int FAILURE_CREDMAN_SELECTOR = -1;
}
+0 −15
Original line number Diff line number Diff line
@@ -41,8 +41,6 @@ public final class GetCandidateCredentialsResponse implements Parcelable {

    private final PendingIntent mPendingIntent;

    private final GetCredentialResponse mGetCredentialResponse;

    /**
     * @hide
     */
@@ -52,7 +50,6 @@ public final class GetCandidateCredentialsResponse implements Parcelable {
    ) {
        mCandidateProviderDataList = null;
        mPendingIntent = null;
        mGetCredentialResponse = getCredentialResponse;
    }

    /**
@@ -68,7 +65,6 @@ public final class GetCandidateCredentialsResponse implements Parcelable {
                /*valueName=*/ "candidateProviderDataList");
        mCandidateProviderDataList = new ArrayList<>(candidateProviderDataList);
        mPendingIntent = pendingIntent;
        mGetCredentialResponse = null;
    }

    /**
@@ -80,15 +76,6 @@ public final class GetCandidateCredentialsResponse implements Parcelable {
        return mCandidateProviderDataList;
    }

    /**
     * Returns candidate provider data list.
     *
     * @hide
     */
    public GetCredentialResponse getGetCredentialResponse() {
        return mGetCredentialResponse;
    }

    /**
     * Returns candidate provider data list.
     *
@@ -106,14 +93,12 @@ public final class GetCandidateCredentialsResponse implements Parcelable {
        AnnotationValidations.validate(NonNull.class, null, mCandidateProviderDataList);

        mPendingIntent = in.readTypedObject(PendingIntent.CREATOR);
        mGetCredentialResponse = in.readTypedObject(GetCredentialResponse.CREATOR);
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeTypedList(mCandidateProviderDataList);
        dest.writeTypedObject(mPendingIntent, flags);
        dest.writeTypedObject(mGetCredentialResponse, flags);
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -36,5 +36,11 @@ public class Constants {
    public static final String EXTRA_REQ_FOR_ALL_OPTIONS =
            "android.credentials.selection.extra.REQ_FOR_ALL_OPTIONS";

    /**
     * The intent extra key for the final result receiver object
     */
    public static final String EXTRA_FINAL_RESPONSE_RECEIVER =
            "android.credentials.selection.extra.FINAL_RESPONSE_RECEIVER";

    private Constants() {}
}
+20 −14
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.content.ClipData;
import android.content.Intent;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.ArrayMap;
@@ -190,7 +190,7 @@ public final class Dataset implements Parcelable {
    @Nullable private final InlinePresentation mInlineTooltipPresentation;
    private final IntentSender mAuthentication;

    @Nullable private final Bundle mAuthenticationExtras;
    @Nullable private Intent mCredentialFillInIntent;

    @Nullable String mId;

@@ -229,7 +229,7 @@ public final class Dataset implements Parcelable {
        mInlinePresentation = inlinePresentation;
        mInlineTooltipPresentation = inlineTooltipPresentation;
        mAuthentication = authentication;
        mAuthenticationExtras = null;
        mCredentialFillInIntent = null;
        mId = id;
    }

@@ -252,7 +252,7 @@ public final class Dataset implements Parcelable {
        mInlinePresentation = dataset.mInlinePresentation;
        mInlineTooltipPresentation = dataset.mInlineTooltipPresentation;
        mAuthentication = dataset.mAuthentication;
        mAuthenticationExtras = dataset.mAuthenticationExtras;
        mCredentialFillInIntent = dataset.mCredentialFillInIntent;
        mId = dataset.mId;
        mAutofillDatatypes = dataset.mAutofillDatatypes;
    }
@@ -271,7 +271,7 @@ public final class Dataset implements Parcelable {
        mInlinePresentation = builder.mInlinePresentation;
        mInlineTooltipPresentation = builder.mInlineTooltipPresentation;
        mAuthentication = builder.mAuthentication;
        mAuthenticationExtras = builder.mAuthenticationExtras;
        mCredentialFillInIntent = builder.mCredentialFillInIntent;
        mId = builder.mId;
        mAutofillDatatypes = builder.mAutofillDatatypes;
    }
@@ -354,8 +354,14 @@ public final class Dataset implements Parcelable {

    /** @hide */
    @Hide
    public @Nullable Bundle getAuthenticationExtras() {
        return mAuthenticationExtras;
    public @Nullable Intent getCredentialFillInIntent() {
        return mCredentialFillInIntent;
    }

    /** @hide */
    @Hide
    public void setCredentialFillInIntent(Intent intent) {
        mCredentialFillInIntent = intent;
    }

    /** @hide */
@@ -415,7 +421,7 @@ public final class Dataset implements Parcelable {
        if (mAuthentication != null) {
            builder.append(", hasAuthentication");
        }
        if (mAuthenticationExtras != null) {
        if (mCredentialFillInIntent != null) {
            builder.append(", hasAuthenticationExtras");
        }
        if (mAutofillDatatypes != null) {
@@ -472,7 +478,7 @@ public final class Dataset implements Parcelable {
        @Nullable private InlinePresentation mInlineTooltipPresentation;
        private IntentSender mAuthentication;

        private Bundle mAuthenticationExtras;
        private Intent mCredentialFillInIntent;
        private boolean mDestroyed;
        @Nullable private String mId;

@@ -655,9 +661,9 @@ public final class Dataset implements Parcelable {
         * @hide
         */
        @Hide
        public @NonNull Builder setAuthenticationExtras(@Nullable Bundle authenticationExtra) {
        public @NonNull Builder setCredentialFillInIntent(@Nullable Intent credentialFillInIntent) {
            throwIfDestroyed();
            mAuthenticationExtras = authenticationExtra;
            mCredentialFillInIntent = credentialFillInIntent;
            return this;
        }

@@ -1401,7 +1407,7 @@ public final class Dataset implements Parcelable {
        parcel.writeParcelable(mAuthentication, flags);
        parcel.writeString(mId);
        parcel.writeInt(mEligibleReason);
        parcel.writeTypedObject(mAuthenticationExtras, flags);
        parcel.writeTypedObject(mCredentialFillInIntent, flags);
    }

    public static final @NonNull Creator<Dataset> CREATOR = new Creator<Dataset>() {
@@ -1437,7 +1443,7 @@ public final class Dataset implements Parcelable {
                    android.content.IntentSender.class);
            final String datasetId = parcel.readString();
            final int eligibleReason = parcel.readInt();
            final Bundle authenticationExtras = parcel.readTypedObject(Bundle.CREATOR);
            final Intent credentialFillInIntent = parcel.readTypedObject(Intent.CREATOR);

            // Always go through the builder to ensure the data ingested by
            // the system obeys the contract of the builder to avoid attacks
@@ -1482,7 +1488,7 @@ public final class Dataset implements Parcelable {
                        fieldDialogPresentation);
            }
            builder.setAuthentication(authentication);
            builder.setAuthenticationExtras(authenticationExtras);
            builder.setCredentialFillInIntent(credentialFillInIntent);
            builder.setId(datasetId);
            Dataset dataset = builder.build();
            dataset.mEligibleReason = eligibleReason;
+11 −2
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import java.util.Set;
 * <p>See the main {@link AutofillService} documentation for more details and examples.
 */
public final class FillResponse implements Parcelable {
    // common_typos_disable

    /**
     * Flag used to generate {@link FillEventHistory.Event events} of type
@@ -82,11 +83,17 @@ public final class FillResponse implements Parcelable {
     */
    public static final int FLAG_DELAY_FILL = 0x4;

    /**
     * @hide
     */
    public static final int FLAG_CREDENTIAL_MANAGER_RESPONSE = 0x8;

    /** @hide */
    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
            FLAG_TRACK_CONTEXT_COMMITED,
            FLAG_DISABLE_ACTIVITY_ONLY,
            FLAG_DELAY_FILL
            FLAG_DELAY_FILL,
            FLAG_CREDENTIAL_MANAGER_RESPONSE
    })
    @Retention(RetentionPolicy.SOURCE)
    @interface FillResponseFlags {}
@@ -834,7 +841,9 @@ public final class FillResponse implements Parcelable {
        public Builder setFlags(@FillResponseFlags int flags) {
            throwIfDestroyed();
            mFlags = Preconditions.checkFlagsArgument(flags,
                    FLAG_TRACK_CONTEXT_COMMITED | FLAG_DISABLE_ACTIVITY_ONLY | FLAG_DELAY_FILL);
                    FLAG_TRACK_CONTEXT_COMMITED
                            | FLAG_DISABLE_ACTIVITY_ONLY | FLAG_DELAY_FILL
                            | FLAG_CREDENTIAL_MANAGER_RESPONSE);
            return this;
        }

Loading