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

Commit 68eecb37 authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Removed deprecated setAuthentication() method that didn't take ids." into oc-dev

am: 136a48e3

Change-Id: Ia81cd576c5acdaf0008c21fbea9fb5a16c3c89bf
parents 6405b602 136a48e3
Loading
Loading
Loading
Loading
+20 −18
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.view.autofill.AutofillManager;
import android.widget.RemoteViews;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * Response for a {@link
@@ -258,12 +259,17 @@ public final class FillResponse implements Parcelable {
         * @param ids id of Views that when focused will display the authentication UI affordance.
         *
         * @return This builder.
         * @throw {@link IllegalArgumentException} if {@code ids} is {@code null} or empty, or if
         * neither {@code authentication} nor {@code presentation} is non-{@code null}.
         *
         * @see android.app.PendingIntent#getIntentSender()
         */
        public @NonNull Builder setAuthentication(@NonNull AutofillId[] ids,
                @Nullable IntentSender authentication, @Nullable RemoteViews presentation) {
            throwIfDestroyed();
            // TODO(b/37424539): assert ids is not null nor empty once old version is removed
            if (ids == null || ids.length == 0) {
                throw new IllegalArgumentException("ids cannot be null or empry");
            }
            if (authentication == null ^ presentation == null) {
                throw new IllegalArgumentException("authentication and presentation"
                        + " must be both non-null or null");
@@ -274,17 +280,6 @@ public final class FillResponse implements Parcelable {
            return this;
        }

        /**
         * TODO(b/37424539): will be removed once clients use the version that takes ids
         * @hide
         * @deprecated
         */
        @Deprecated
        public @NonNull Builder setAuthentication(@Nullable IntentSender authentication,
                @Nullable RemoteViews presentation) {
            return setAuthentication(null, authentication, presentation);
        }

        /**
         * Specifies views that should not trigger new
         * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal,
@@ -396,6 +391,7 @@ public final class FillResponse implements Parcelable {
    public String toString() {
        if (!sDebug) return super.toString();

        // TODO: create a dump() method instead
        return new StringBuilder(
                "FillResponse : [mRequestId=" + mRequestId)
                .append(", datasets=").append(mDatasets)
@@ -403,10 +399,8 @@ public final class FillResponse implements Parcelable {
                .append(", clientState=").append(mClientState != null)
                .append(", hasPresentation=").append(mPresentation != null)
                .append(", hasAuthentication=").append(mAuthentication != null)
                .append(", authenticationSize=").append(mAuthenticationIds != null
                        ? mAuthenticationIds.length : "N/A")
                .append(", ignoredIdsSize=").append(mIgnoredIds != null
                    ? mIgnoredIds.length : "N/A")
                .append(", authenticationIds=").append(Arrays.toString(mAuthenticationIds))
                .append(", ignoredIds=").append(Arrays.toString(mIgnoredIds))
                .append("]")
                .toString();
    }
@@ -447,8 +441,16 @@ public final class FillResponse implements Parcelable {
            }
            builder.setSaveInfo(parcel.readParcelable(null));
            builder.setClientState(parcel.readParcelable(null));
            builder.setAuthentication(parcel.readParcelableArray(null, AutofillId.class),
                    parcel.readParcelable(null), parcel.readParcelable(null));

            // Sets authentication state.
            final AutofillId[] authenticationIds = parcel.readParcelableArray(null,
                    AutofillId.class);
            final IntentSender authentication = parcel.readParcelable(null);
            final RemoteViews presentation = parcel.readParcelable(null);
            if (authenticationIds != null) {
                builder.setAuthentication(authenticationIds, authentication, presentation);
            }

            builder.setIgnoredIds(parcel.readParcelableArray(null, AutofillId.class));
            final FillResponse response = builder.build();

+1 −5
Original line number Diff line number Diff line
@@ -603,15 +603,12 @@ public final class AutofillManagerService extends SystemService {
            if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

            boolean oldDebug = sDebug;
            boolean oldVerbose = sVerbose;
            try {
                synchronized (mLock) {
                    oldDebug = sDebug;
                    oldVerbose = sVerbose;
                    setDebugLocked(true);
                    setVerboseLocked(true);
                    pw.print("Debug mode: "); pw.println(oldDebug);
                    pw.print("Verbose mode: "); pw.println(oldVerbose);
                    pw.print("Verbose mode: "); pw.println(sVerbose);
                    pw.print("Disabled users: "); pw.println(mDisabledUsers);
                    final int size = mServicesCache.size();
                    pw.print("Cached services: ");
@@ -631,7 +628,6 @@ public final class AutofillManagerService extends SystemService {
                mRequestsHistory.reverseDump(fd, pw, args);
            } finally {
                setDebugLocked(oldDebug);
                setVerboseLocked(oldVerbose);
            }
        }

+37 −14
Original line number Diff line number Diff line
@@ -922,6 +922,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    }
                }
            }

            if (ArrayUtils.contains(response.getAuthenticationIds(), id)) {
                return false;
            }
        }

        return true;
@@ -943,8 +947,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    Slog.v(TAG,
                            "Creating viewState for " + id + " on " + getActionAsString(action));
                }
                viewState = new ViewState(this, id, value, this, ViewState.STATE_INITIAL);
                boolean isIgnored = isIgnoredLocked(id);
                viewState = new ViewState(this, id, value, this,
                        isIgnored ? ViewState.STATE_IGNORED : ViewState.STATE_INITIAL);
                mViewStates.put(id, viewState);
                if (isIgnored) {
                    if (sDebug) Slog.d(TAG, "updateLocked(): ignoring view " + id);
                    return;
                }
            } else {
                if (sVerbose) Slog.v(TAG, "Ignored " + getActionAsString(action) + " for " + id);
                return;
@@ -983,17 +993,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                break;
            case ACTION_VIEW_ENTERED:
                if (shouldStartNewPartitionLocked(id)) {
                    // TODO(b/37424539): proper implementation
                    if (mResponseWaitingAuth != null) {
                        viewState.setState(ViewState.STATE_WAITING_RESPONSE_AUTH);
                    } else {
                    if (sDebug) {
                        Slog.d(TAG, "Starting partition for view id " + viewState.id);
                    }
                    viewState.setState(ViewState.STATE_STARTED_PARTITION);
                    requestNewFillResponseLocked(flags);
                }
                }

                // Remove the UI if the ViewState has changed.
                if (mCurrentViewId != viewState.id) {
@@ -1015,6 +1020,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }
    }

    /**
     * Checks whether a view should be ignored.
     */
    private boolean isIgnoredLocked(AutofillId id) {
        if (mResponses == null || mResponses.size() == 0) {
            return false;
        }
        // Always check the latest response only
        final FillResponse response = mResponses.valueAt(mResponses.size() - 1);
        return ArrayUtils.contains(response.getIgnoredIds(), id);
    }

    @Override
    public void onFillReady(FillResponse response, AutofillId filledId,
            @Nullable AutofillValue value) {
@@ -1149,18 +1166,24 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        final SaveInfo saveInfo = response.getSaveInfo();
        if (saveInfo != null) {
            final AutofillId[] requiredIds = saveInfo.getRequiredIds();
            for (int i = 0; i < requiredIds.length; i++) {
                final AutofillId id = requiredIds[i];
            for (AutofillId id : requiredIds) {
                createOrUpdateViewStateLocked(id, state, null);
            }
            final AutofillId[] optionalIds = saveInfo.getOptionalIds();
            if (optionalIds != null) {
                for (int i = 0; i < optionalIds.length; i++) {
                    final AutofillId id = optionalIds[i];
                for (AutofillId id : optionalIds) {
                    createOrUpdateViewStateLocked(id, state, null);
                }
            }
        }

        final AutofillId[] authIds = response.getAuthenticationIds();
        if (authIds != null) {
            for (AutofillId id : authIds) {
                createOrUpdateViewStateLocked(id, state, null);
            }
        }

    }

    /**
+13 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.autofill;

import static com.android.server.autofill.Helper.sDebug;
import static com.android.server.autofill.Helper.sVerbose;

import android.annotation.Nullable;
import android.graphics.Rect;
@@ -61,8 +62,8 @@ final class ViewState {
    public static final int STATE_STARTED_PARTITION = 0x20;
    /** User select a dataset in this view, but service must authenticate first. */
    public static final int STATE_WAITING_DATASET_AUTH = 0x40;
    // TODO(b/37424539): temporary workaround until partitioning supports auth
    public static final int STATE_WAITING_RESPONSE_AUTH = 0x80;
    /** Service does not care about this view. */
    public static final int STATE_IGNORED = 0x80;

    public final AutofillId id;

@@ -199,7 +200,16 @@ final class ViewState {
    void dump(String prefix, PrintWriter pw) {
        pw.print(prefix); pw.print("id:" ); pw.println(this.id);
        pw.print(prefix); pw.print("state:" ); pw.println(getStateAsString());
        pw.print(prefix); pw.print("has response:" ); pw.println(mResponse != null);
        pw.print(prefix); pw.print("response:");
        if (mResponse == null) {
            pw.println("N/A");
        } else {
            if (sVerbose) {
                pw.println(mResponse);
            } else {
                pw.println(mResponse.getRequestId());
            }
        }
        pw.print(prefix); pw.print("initialValue:" ); pw.println(mInitialValue);
        pw.print(prefix); pw.print("currentValue:" ); pw.println(mCurrentValue);
        pw.print(prefix); pw.print("autofilledValue:" ); pw.println(mAutofilledValue);