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

Commit c7619632 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Report multiple FillContext-s onSave

To make life easier the reponseId is not part of the FillResponse.

Test: CtsAutofillServiceTestCases (added test for multiple Contexts)
Change-Id: If09e00b7267d293e4234a7a9837ad88d73af1b24
Fixes: 36481649
parent f879357c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -47,8 +47,13 @@ public final class FillCallback {
    public void onSuccess(@Nullable FillResponse response) {
        assertNotCalled();
        mCalled = true;

        if (response != null) {
            response.setRequestId(mRequestId);
        }

        try {
            mCallback.onSuccess(response, mRequestId);
            mCallback.onSuccess(response);
        } catch (RemoteException e) {
            e.rethrowAsRuntimeException();
        }
+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.service.autofill;

import static android.view.autofill.Helper.DEBUG;

import android.annotation.NonNull;
import android.app.assist.AssistStructure;
import android.os.Bundle;
@@ -70,6 +72,15 @@ public final class FillContext implements Parcelable {
        return mStructure;
    }

    @Override
    public String toString() {
        if (!DEBUG) {
            return super.toString();
        } else {
            return "FillContext [mRequestId=" + mRequestId + "]";
        }
    }

    @Override
    public int describeContents() {
        return 0;
+3 −0
Original line number Diff line number Diff line
@@ -44,6 +44,9 @@ public final class FillRequest implements Parcelable {
     */
    public static final int FLAG_MANUAL_REQUEST = 0x1;

    /** @hide */
    public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;

    /** @hide */
    @IntDef(
        flag = true,
+30 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.service.autofill;

import static android.service.autofill.FillRequest.INVALID_REQUEST_ID;
import static android.view.autofill.Helper.DEBUG;

import android.annotation.NonNull;
@@ -138,6 +139,7 @@ public final class FillResponse implements Parcelable {
    private final @Nullable IntentSender mAuthentication;
    private final @Nullable AutofillId[] mAuthenticationIds;
    private final @Nullable AutofillId[] mIgnoredIds;
    private int mRequestId;

    private FillResponse(@NonNull Builder builder) {
        mDatasets = builder.mDatasets;
@@ -147,6 +149,7 @@ public final class FillResponse implements Parcelable {
        mAuthentication = builder.mAuthentication;
        mAuthenticationIds = builder.mAuthenticationIds;
        mIgnoredIds = builder.mIgnoredIds;
        mRequestId = INVALID_REQUEST_ID;
    }

    /** @hide */
@@ -184,6 +187,24 @@ public final class FillResponse implements Parcelable {
        return mIgnoredIds;
    }

    /**
     * Associates a {@link FillResponse} to a request.
     *
     * <p>Set inside of the {@link FillCallback} code, not the {@link AutofillService}.
     *
     * @param requestId The id of the request to associate the response to.
     *
     * @hide
     */
    public void setRequestId(int requestId) {
        mRequestId = requestId;
    }

    /** @hide */
    public int getRequestId() {
        return mRequestId;
    }

    /**
     * Builder for {@link FillResponse} objects. You must to provide at least
     * one dataset or set an authentication intent with a presentation view.
@@ -376,7 +397,8 @@ public final class FillResponse implements Parcelable {
        if (!DEBUG) return super.toString();

        return new StringBuilder(
                "FillResponse: [datasets=").append(mDatasets)
                "FillResponse : [mRequestId=" + mRequestId)
                .append(", datasets=").append(mDatasets)
                .append(", saveInfo=").append(mSaveInfo)
                .append(", clientState=").append(mClientState != null)
                .append(", hasPresentation=").append(mPresentation != null)
@@ -385,6 +407,7 @@ public final class FillResponse implements Parcelable {
                        ? mAuthenticationIds.length : "N/A")
                .append(", ignoredIdsSize=").append(mIgnoredIds != null
                    ? mIgnoredIds.length : "N/A")
                .append("]")
                .toString();
    }

@@ -406,6 +429,7 @@ public final class FillResponse implements Parcelable {
        parcel.writeParcelable(mAuthentication, flags);
        parcel.writeParcelable(mPresentation, flags);
        parcel.writeParcelableArray(mIgnoredIds, flags);
        parcel.writeInt(mRequestId);
    }

    public static final Parcelable.Creator<FillResponse> CREATOR =
@@ -426,7 +450,11 @@ public final class FillResponse implements Parcelable {
            builder.setAuthentication(parcel.readParcelableArray(null, AutofillId.class),
                    parcel.readParcelable(null), parcel.readParcelable(null));
            builder.setIgnoredIds(parcel.readParcelableArray(null, AutofillId.class));
            return builder.build();
            final FillResponse response = builder.build();

            response.setRequestId(parcel.readInt());

            return response;
        }

        @Override
+1 −1
Original line number Diff line number Diff line
@@ -27,6 +27,6 @@ import android.service.autofill.FillResponse;
 */
interface IFillCallback {
    void onCancellable(in ICancellationSignal cancellation);
    void onSuccess(in FillResponse response, int requestId);
    void onSuccess(in FillResponse response);
    void onFailure(CharSequence message);
}
Loading