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

Commit d2afce38 authored by Tim Yu's avatar Tim Yu Committed by Android (Google) Code Review
Browse files

Merge "[Autofill] Add DeviceConfig flags for Flags.multipleFillHistory" into main

parents aac8e4ed 3161e902
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.service.autofill.Flags.improveFillDialogAconfig;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.provider.DeviceConfig;
import android.service.autofill.Flags;
import android.text.TextUtils;
import android.util.ArraySet;
import android.view.View;
@@ -347,6 +348,14 @@ public class AutofillFeatureFlags {

    // END AUTOFILL REMOVE PRE_TRIGGER FLAGS

    /**
     * Whether per Session FillEventHistory is enabled.
     *
     * @hide
     */
    public static final String DEVICE_CONFIG_SESSION_FILL_EVENT_HISTORY =
            "session_fill_event_history";

    /**
     * Define the max input length for autofill to show suggesiton UI
     *
@@ -408,6 +417,13 @@ public class AutofillFeatureFlags {
    public static final long DEFAULT_FILL_DIALOG_MIN_WAIT_AFTER_IME_ANIMATION_END_MS = 0; // 0 ms
    // END AUTOFILL REMOVE PRE_TRIGGER FLAGS DEFAULTS

    /**
     * Default for whether per Session FillEventHistory is enabled
     *
     * @hide
     */
    public static final boolean DEFAULT_SESSION_FILL_EVENT_HISTORY_ENABLED = false;

    /**
     * @hide
     */
@@ -697,4 +713,20 @@ public class AutofillFeatureFlags {
                DEVICE_CONFIG_FILL_DIALOG_MIN_WAIT_AFTER_IME_ANIMATION_END_MS,
                DEFAULT_FILL_DIALOG_MIN_WAIT_AFTER_IME_ANIMATION_END_MS);
    }

    /**
     * Whether tracking FillEventHistory per Session is enabled
     *
     * @hide
     */
    public static boolean isMultipleFillEventHistoryEnabled() {
        if (!Flags.multipleFillHistory()) {
            return false;
        }

        return DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_AUTOFILL,
                DEVICE_CONFIG_SESSION_FILL_EVENT_HISTORY,
                DEFAULT_SESSION_FILL_EVENT_HISTORY_ENABLED);
    }
}
+7 −5
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.util.LocalLog;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.view.autofill.AutofillFeatureFlags;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
import android.view.autofill.AutofillManager.AutofillCommitReason;
@@ -672,7 +673,7 @@ final class AutofillManagerServiceImpl
                flags, mInputMethodManagerInternal, isPrimaryCredential);
        mSessions.put(newSession.id, newSession);

        if (Flags.multipleFillHistory() && !forAugmentedAutofillOnly) {
        if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled() && !forAugmentedAutofillOnly) {
            mFillHistories.put(newSession.id, new FillEventHistory(sessionId, null));
        }

@@ -772,7 +773,8 @@ final class AutofillManagerServiceImpl

            FillEventHistory history = null;

            if (Flags.multipleFillHistory() && mFillHistories != null) {
            if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()
                        && mFillHistories != null) {
                history = mFillHistories.get(sessionId);
                mFillHistories.delete(sessionId);
            }
@@ -922,7 +924,7 @@ final class AutofillManagerServiceImpl
            }
        }
        mSessions.clear();
        if (Flags.multipleFillHistory()) {
        if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()) {
            mFillHistories.clear();
        }

@@ -991,7 +993,7 @@ final class AutofillManagerServiceImpl
            mEventHistory.addEvent(event);
        }

        if (Flags.multipleFillHistory()) {
        if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()) {
            FillEventHistory history = mFillHistories.get(sessionId);
            if (history != null) {
                history.addEvent(event);
@@ -1180,7 +1182,7 @@ final class AutofillManagerServiceImpl
                logViewEnteredForHistory(sessionId, clientState, mEventHistory, focusedId);
            }

            if (Flags.multipleFillHistory()) {
            if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()) {
                FillEventHistory history = mFillHistories.get(sessionId);
                if (history != null) {
                    logViewEnteredForHistory(sessionId, clientState, history, focusedId);
+26 −3
Original line number Diff line number Diff line
@@ -441,6 +441,9 @@ final class Session
    @GuardedBy("mLock")
    private Bundle mClientState;

    @GuardedBy("mLock")
    private Bundle mClientStateForSecondary;

    @GuardedBy("mLock")
    boolean mDestroyed;

@@ -980,13 +983,19 @@ final class Session
                        mergePreviousSessionLocked(/* forSave= */ false);
                final List<String> hints = getTypeHintsForProvider();

                Bundle sendBackClientState = mClientState;
                if (Flags.multipleFillHistory()
                        && mRequestId.isSecondaryProvider(requestId)) {
                    sendBackClientState = mClientStateForSecondary;
                }

                mDelayedFillPendingIntent = createPendingIntent(requestId);
                request =
                        new FillRequest(
                                requestId,
                                contexts,
                                hints,
                                mClientState,
                                sendBackClientState,
                                flags,
                                /* inlineSuggestionsRequest= */ null,
                                /* delayedFillIntentSender= */ mDelayedFillPendingIntent == null
@@ -3317,7 +3326,7 @@ final class Session
                        AUTHENTICATION_RESULT_SUCCESS);
                if (newClientState != null) {
                    if (sDebug) Slog.d(TAG, "Updating client state from auth dataset");
                    mClientState = newClientState;
                    setClientState(newClientState, requestId);
                }
                Dataset datasetFromResult = getEffectiveDatasetForAuthentication((Dataset) result);
                final Dataset oldDataset = authenticatedResponse.getDatasets().get(datasetIdx);
@@ -6699,6 +6708,18 @@ final class Session
        remoteService.onDestroyAutofillWindowsRequest();
    }

    @GuardedBy("mLock")
    private void setClientState(@Nullable Bundle newClientState, int requestId) {
        if (Flags.multipleFillHistory()
                && mRequestId.isSecondaryProvider(requestId)) {
            // Set the secondary clientstate
            mClientStateForSecondary = newClientState;
        } else {
            // The old way - only set the primary provider clientstate
            mClientState = newClientState;
        }
    }

    @GuardedBy("mLock")
    private void processResponseLocked(
            @NonNull FillResponse newResponse, @Nullable Bundle newClientState, int flags) {
@@ -6734,7 +6755,9 @@ final class Session
            mResponses = new SparseArray<>(2);
        }
        mResponses.put(requestId, newResponse);
        mClientState = newClientState != null ? newClientState : newResponse.getClientState();

        setClientState(newClientState != null ? newClientState : newResponse.getClientState(),
                requestId);

        boolean webviewRequestedCredman =
                newClientState != null