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

Commit f19d8217 authored by Haoran Zhang's avatar Haoran Zhang
Browse files

[DO NOT MERGE] Suppress fill and save dialog for activities that have credman field.

This change has conflict with master branch. I'll create seperate cherry
pick CL for git-master.

Bug:261048555
Test: atest CtsAutoFillServiceTestCases

Change-Id: I18587ef3697a071f690a0f1662f8d5c12aeb58b5
parent 756f4231
Loading
Loading
Loading
Loading
+28 −7
Original line number Original line Diff line number Diff line
@@ -121,6 +121,12 @@ public final class FillRequest implements Parcelable {
     */
     */
    public static final @RequestFlags int FLAG_PCC_DETECTION = 0x200;
    public static final @RequestFlags int FLAG_PCC_DETECTION = 0x200;


    /**
     * Indicate whether the screen has credman field
     * @hide
     */
    public static final @RequestFlags int FLAG_SCREEN_HAS_CREDMAN_FIELD = 0x400;

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


@@ -234,7 +240,8 @@ public final class FillRequest implements Parcelable {
        FLAG_SUPPORTS_FILL_DIALOG,
        FLAG_SUPPORTS_FILL_DIALOG,
        FLAG_IME_SHOWING,
        FLAG_IME_SHOWING,
        FLAG_RESET_FILL_DIALOG_STATE,
        FLAG_RESET_FILL_DIALOG_STATE,
        FLAG_PCC_DETECTION
        FLAG_PCC_DETECTION,
        FLAG_SCREEN_HAS_CREDMAN_FIELD
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @DataClass.Generated.Member
    @DataClass.Generated.Member
@@ -266,6 +273,8 @@ public final class FillRequest implements Parcelable {
                    return "FLAG_RESET_FILL_DIALOG_STATE";
                    return "FLAG_RESET_FILL_DIALOG_STATE";
            case FLAG_PCC_DETECTION:
            case FLAG_PCC_DETECTION:
                    return "FLAG_PCC_DETECTION";
                    return "FLAG_PCC_DETECTION";
            case FLAG_SCREEN_HAS_CREDMAN_FIELD:
                    return "FLAG_SCREEN_HAS_CREDMAN_FIELD";
            default: return Integer.toHexString(value);
            default: return Integer.toHexString(value);
        }
        }
    }
    }
@@ -282,10 +291,15 @@ public final class FillRequest implements Parcelable {
     *   include contexts from requests whose {@link SaveInfo} had the
     *   include contexts from requests whose {@link SaveInfo} had the
     *   {@link SaveInfo#FLAG_DELAY_SAVE} flag.
     *   {@link SaveInfo#FLAG_DELAY_SAVE} flag.
     * @param hints
     * @param hints
     *   Autofill Provider should return data for the autofill hints requested here,
     *   Sends a list of datatypes for the Autofill Provider.
     *
     *   If this is populated, Autofill Provider should return data
     *   for the autofill hints requested here,
     *   even though the Autofill Provider may not have detected these types.
     *   even though the Autofill Provider may not have detected these types.
     *   The hints would be part of HintConstants:
     *   The hints would be part of HintConstants:
     *   https://developer.android.com/reference/androidx/autofill/HintConstants
     *   https://developer.android.com/reference/androidx/autofill/HintConstants
     *
     *   This is populated if the platform's field detection is enabled.
     * @param clientState
     * @param clientState
     *   Gets the latest client state bundle set by the service in a
     *   Gets the latest client state bundle set by the service in a
     *   {@link FillResponse.Builder#setClientState(Bundle) fill response}.
     *   {@link FillResponse.Builder#setClientState(Bundle) fill response}.
@@ -353,7 +367,8 @@ public final class FillRequest implements Parcelable {
                        | FLAG_SUPPORTS_FILL_DIALOG
                        | FLAG_SUPPORTS_FILL_DIALOG
                        | FLAG_IME_SHOWING
                        | FLAG_IME_SHOWING
                        | FLAG_RESET_FILL_DIALOG_STATE
                        | FLAG_RESET_FILL_DIALOG_STATE
                        | FLAG_PCC_DETECTION);
                        | FLAG_PCC_DETECTION
                        | FLAG_SCREEN_HAS_CREDMAN_FIELD);
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
        this.mDelayedFillIntentSender = delayedFillIntentSender;
        this.mDelayedFillIntentSender = delayedFillIntentSender;


@@ -381,10 +396,15 @@ public final class FillRequest implements Parcelable {
    }
    }


    /**
    /**
     * Autofill Provider should return data for the autofill hints requested here,
     * Sends a list of datatypes for the Autofill Provider.
     *
     * If this is populated, Autofill Provider should return data
     * for the autofill hints requested here,
     * even though the Autofill Provider may not have detected these types.
     * even though the Autofill Provider may not have detected these types.
     * The hints would be part of HintConstants:
     * The hints would be part of HintConstants:
     * https://developer.android.com/reference/androidx/autofill/HintConstants
     * https://developer.android.com/reference/androidx/autofill/HintConstants
     *
     * This is populated if the platform's field detection is enabled.
     */
     */
    @DataClass.Generated.Member
    @DataClass.Generated.Member
    public @NonNull List<String> getHints() {
    public @NonNull List<String> getHints() {
@@ -534,7 +554,8 @@ public final class FillRequest implements Parcelable {
                        | FLAG_SUPPORTS_FILL_DIALOG
                        | FLAG_SUPPORTS_FILL_DIALOG
                        | FLAG_IME_SHOWING
                        | FLAG_IME_SHOWING
                        | FLAG_RESET_FILL_DIALOG_STATE
                        | FLAG_RESET_FILL_DIALOG_STATE
                        | FLAG_PCC_DETECTION);
                        | FLAG_PCC_DETECTION
                        | FLAG_SCREEN_HAS_CREDMAN_FIELD);
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
        this.mDelayedFillIntentSender = delayedFillIntentSender;
        this.mDelayedFillIntentSender = delayedFillIntentSender;


@@ -556,10 +577,10 @@ public final class FillRequest implements Parcelable {
    };
    };


    @DataClass.Generated(
    @DataClass.Generated(
            time = 1675711417112L,
            time = 1682097266850L,
            codegenVersion = "1.0.23",
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
            sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
            inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SUPPORTS_FILL_DIALOG\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_IME_SHOWING\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_RESET_FILL_DIALOG_STATE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PCC_DETECTION\npublic static final  int INVALID_REQUEST_ID\nprivate final  int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.NonNull java.util.List<java.lang.String> mHints\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate  void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
            inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SUPPORTS_FILL_DIALOG\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_IME_SHOWING\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_RESET_FILL_DIALOG_STATE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PCC_DETECTION\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_SCREEN_HAS_CREDMAN_FIELD\npublic static final  int INVALID_REQUEST_ID\nprivate final  int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.NonNull java.util.List<java.lang.String> mHints\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate final @android.annotation.Nullable android.content.IntentSender mDelayedFillIntentSender\nprivate  void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
    @Deprecated
    @Deprecated
    private void __metadata() {}
    private void __metadata() {}


+0 −5
Original line number Original line Diff line number Diff line
@@ -10380,11 +10380,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            return false;
            return false;
        }
        }
        // Disable triggering autofill if the view is integrated with CredentialManager.
        if (afm.shouldIgnoreCredentialViews() && isCredential()) {
            return false;
        }
        // Check whether view is not part of an activity. If it's not, return false.
        // Check whether view is not part of an activity. If it's not, return false.
        if (getAutofillViewId() <= LAST_APP_AUTOFILL_ID) {
        if (getAutofillViewId() <= LAST_APP_AUTOFILL_ID) {
            return false;
            return false;
+19 −52
Original line number Original line Diff line number Diff line
@@ -99,39 +99,34 @@ public class AutofillFeatureFlags {
            "autofill_dialog_hints";
            "autofill_dialog_hints";


    // START CREDENTIAL MANAGER FLAGS //
    // START CREDENTIAL MANAGER FLAGS //

    /**
    /**
     * Indicates whether credential manager tagged views should be ignored from autofill structures.
     * (deprecated) Indicates whether credential manager tagged views should be ignored from
     * This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
     * autofill structures.This flag is further gated by
     * {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
     *
     * TODO(b/280661772): Remove this flag once API change is allowed
     */
     */
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS =
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS =
            "autofill_credential_manager_ignore_views";
            "autofill_credential_manager_ignore_views";


    /**
    /**
     * Indicates CredentialManager feature enabled or not.
     * (deprecated) Indicates CredentialManager feature enabled or not.
     * This is the overall feature flag. Individual behavior of credential manager may be controlled
     * This is the overall feature flag. Individual behavior of credential manager may be controlled
     * via a different flag, but gated by this flag.
     * via a different flag, but gated by this flag.
     *
     * TODO(b/280661772): Remove this flag once API change is allowed
     */
     */
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED =
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED =
            "autofill_credential_manager_enabled";
            "autofill_credential_manager_enabled";


    /**
    /**
     * Indicates whether credential manager tagged views should suppress fill dialog.
     * Indicates whether credential manager tagged views should suppress fill and save dialog.
     * This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
     * This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
     *
     *
     * @hide
     * @hide
     */
     */
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG =
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG =
            "autofill_credential_manager_suppress_fill_dialog";
            "autofill_credential_manager_suppress_fill_and_save_dialog";

    /**
     * Indicates whether credential manager tagged views should suppress save dialog.
     * This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
     *
     * @hide
     */
    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_SAVE_DIALOG =
            "autofill_credential_manager_suppress_save_dialog";
    // END CREDENTIAL MANAGER FLAGS //
    // END CREDENTIAL MANAGER FLAGS //


    // START AUTOFILL FOR ALL APPS FLAGS //
    // START AUTOFILL FOR ALL APPS FLAGS //
@@ -270,11 +265,7 @@ public class AutofillFeatureFlags {




    // CREDENTIAL MANAGER DEFAULTS
    // CREDENTIAL MANAGER DEFAULTS
    // Credential manager is enabled by default so as to allow testing by app developers
    private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG = true;
    private static final boolean DEFAULT_CREDENTIAL_MANAGER_ENABLED = true;
    private static final boolean DEFAULT_CREDENTIAL_MANAGER_IGNORE_VIEWS = true;
    private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG = false;
    private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_SAVE_DIALOG = false;
    // END CREDENTIAL MANAGER DEFAULTS
    // END CREDENTIAL MANAGER DEFAULTS




@@ -317,43 +308,19 @@ public class AutofillFeatureFlags {
                (str) -> !TextUtils.isEmpty(str));
                (str) -> !TextUtils.isEmpty(str));
    }
    }


    /**
    /* starts credman flag getter function */
     * Whether the Credential Manager feature is enabled or not
     *
     * @hide
     */
    public static boolean isCredentialManagerEnabled() {
        return DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_AUTOFILL,
                DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED,
                DEFAULT_CREDENTIAL_MANAGER_ENABLED);
    }

    /**
     * Whether credential manager tagged views should be ignored for autofill structure.
     *
     * @hide
     */
    public static boolean shouldIgnoreCredentialViews() {
        return isCredentialManagerEnabled()
                && DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_AUTOFILL,
                DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS,
                DEFAULT_CREDENTIAL_MANAGER_IGNORE_VIEWS);
    }

    /**
    /**
     * Whether credential manager tagged views should not trigger fill dialog requests.
     * Whether credential manager tagged views should not trigger fill dialog requests.
     *
     *
     * @hide
     * @hide
     */
     */
    public static boolean isFillDialogDisabledForCredentialManager() {
    public static boolean isFillAndSaveDialogDisabledForCredentialManager() {
        return isCredentialManagerEnabled()
        return DeviceConfig.getBoolean(
                && DeviceConfig.getBoolean(
                    DeviceConfig.NAMESPACE_AUTOFILL,
                    DeviceConfig.NAMESPACE_AUTOFILL,
                DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG,
                    DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG,
                DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG);
                    DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG);
    }
    }
    /* ends credman flag getter function */


    /**
    /**
     * Whether triggering fill request on unimportant view is enabled.
     * Whether triggering fill request on unimportant view is enabled.
+28 −18
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
import static android.service.autofill.FillRequest.FLAG_PCC_DETECTION;
import static android.service.autofill.FillRequest.FLAG_PCC_DETECTION;
import static android.service.autofill.FillRequest.FLAG_RESET_FILL_DIALOG_STATE;
import static android.service.autofill.FillRequest.FLAG_RESET_FILL_DIALOG_STATE;
import static android.service.autofill.FillRequest.FLAG_SCREEN_HAS_CREDMAN_FIELD;
import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG;
import static android.service.autofill.FillRequest.FLAG_SUPPORTS_FILL_DIALOG;
import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
import static android.service.autofill.FillRequest.FLAG_VIEW_NOT_FOCUSED;
import static android.view.ContentInfo.SOURCE_AUTOFILL;
import static android.view.ContentInfo.SOURCE_AUTOFILL;
@@ -33,7 +34,6 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.annotation.RequiresFeature;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.annotation.TestApi;
@@ -109,7 +109,6 @@ import java.util.Collections;
import java.util.List;
import java.util.List;
import java.util.Objects;
import java.util.Objects;
import java.util.Set;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicBoolean;


import sun.misc.Cleaner;
import sun.misc.Cleaner;
@@ -638,6 +637,8 @@ public final class AutofillManager {
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private boolean mEnabledForAugmentedAutofillOnly;
    private boolean mEnabledForAugmentedAutofillOnly;


    private boolean mHasCredentialField;

    /**
    /**
     * Indicates whether there is already a field to do a fill request after
     * Indicates whether there is already a field to do a fill request after
     * the activity started.
     * the activity started.
@@ -653,6 +654,8 @@ public final class AutofillManager {


    private final boolean mIsFillDialogEnabled;
    private final boolean mIsFillDialogEnabled;


    private final boolean mIsFillAndSaveDialogDisabledForCredentialManager;

    // Indicate whether trigger fill request on unimportant views is enabled
    // Indicate whether trigger fill request on unimportant views is enabled
    private boolean mIsTriggerFillRequestOnUnimportantViewEnabled = false;
    private boolean mIsTriggerFillRequestOnUnimportantViewEnabled = false;


@@ -699,9 +702,6 @@ public final class AutofillManager {
    // Indicates whether called the showAutofillDialog() method.
    // Indicates whether called the showAutofillDialog() method.
    private boolean mShowAutofillDialogCalled = false;
    private boolean mShowAutofillDialogCalled = false;


    // Cached autofill feature flag
    private boolean mShouldIgnoreCredentialViews = false;

    private final String[] mFillDialogEnabledHints;
    private final String[] mFillDialogEnabledHints;


    // Tracked all views that have appeared, including views that there are no
    // Tracked all views that have appeared, including views that there are no
@@ -849,7 +849,10 @@ public final class AutofillManager {


        mIsFillDialogEnabled = AutofillFeatureFlags.isFillDialogEnabled();
        mIsFillDialogEnabled = AutofillFeatureFlags.isFillDialogEnabled();
        mFillDialogEnabledHints = AutofillFeatureFlags.getFillDialogEnabledHints();
        mFillDialogEnabledHints = AutofillFeatureFlags.getFillDialogEnabledHints();
        mShouldIgnoreCredentialViews = AutofillFeatureFlags.shouldIgnoreCredentialViews();

        mIsFillAndSaveDialogDisabledForCredentialManager =
            AutofillFeatureFlags.isFillAndSaveDialogDisabledForCredentialManager();

        if (sDebug) {
        if (sDebug) {
            Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled
            Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled
                    + ", hints=" + Arrays.toString(mFillDialogEnabledHints));
                    + ", hints=" + Arrays.toString(mFillDialogEnabledHints));
@@ -1415,12 +1418,12 @@ public final class AutofillManager {
        if (infos.size() == 0) {
        if (infos.size() == 0) {
            throw new IllegalArgumentException("No VirtualViewInfo found");
            throw new IllegalArgumentException("No VirtualViewInfo found");
        }
        }
        if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
        if (view.isCredential() && mIsFillAndSaveDialogDisabledForCredentialManager) {
                && view.isCredential()) {
            if (sDebug) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                        + view.getAutofillId().toString());
                        + view.getAutofillId().toString());
            }
            }
            mHasCredentialField = true;
            return;
            return;
        }
        }
        for (int i = 0; i < infos.size(); i++) {
        for (int i = 0; i < infos.size(); i++) {
@@ -1442,12 +1445,13 @@ public final class AutofillManager {
        if (sDebug) {
        if (sDebug) {
            Log.d(TAG, "notifyViewEnteredForFillDialog:" + v.getAutofillId());
            Log.d(TAG, "notifyViewEnteredForFillDialog:" + v.getAutofillId());
        }
        }
        if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
        if (v.isCredential()
                && v.isCredential()) {
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
            if (sDebug) {
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                        + v.getAutofillId().toString());
                        + v.getAutofillId());
            }
            }
            mHasCredentialField = true;
            return;
            return;
        }
        }
        notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
        notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
@@ -1492,7 +1496,7 @@ public final class AutofillManager {
        if (mIsFillDialogEnabled
        if (mIsFillDialogEnabled
                || ArrayUtils.containsAny(autofillHints, mFillDialogEnabledHints)) {
                || ArrayUtils.containsAny(autofillHints, mFillDialogEnabledHints)) {
            if (sDebug) {
            if (sDebug) {
                Log.d(TAG, "Trigger fill request when the view is ready.");
                Log.d(TAG, "Triggering pre-emptive request for fill dialog.");
            }
            }


            int flags = FLAG_SUPPORTS_FILL_DIALOG;
            int flags = FLAG_SUPPORTS_FILL_DIALOG;
@@ -1729,6 +1733,15 @@ public final class AutofillManager {
                flags |= FLAG_PASSWORD_INPUT_TYPE;
                flags |= FLAG_PASSWORD_INPUT_TYPE;
            }
            }


            // Update session when screen has credman field
            if (AutofillFeatureFlags.isFillAndSaveDialogDisabledForCredentialManager()
                    && mHasCredentialField) {
                flags |= FLAG_SCREEN_HAS_CREDMAN_FIELD;
                if (sVerbose) {
                    Log.v(TAG, "updating session with flag screen has credman view");
                }
            }

            flags |= getImeStateFlag(view);
            flags |= getImeStateFlag(view);


            if (!isActiveLocked()) {
            if (!isActiveLocked()) {
@@ -2231,11 +2244,6 @@ public final class AutofillManager {
        return client != null && client.autofillClientIsFillUiShowing();
        return client != null && client.autofillClientIsFillUiShowing();
    }
    }


    /** @hide */
    public boolean shouldIgnoreCredentialViews() {
        return mShouldIgnoreCredentialViews;
    }

    /** @hide */
    /** @hide */
    public void onAuthenticationResult(int authenticationId, Intent data, View focusView) {
    public void onAuthenticationResult(int authenticationId, Intent data, View focusView) {
        if (!hasAutofillFeature()) {
        if (!hasAutofillFeature()) {
@@ -2441,6 +2449,7 @@ public final class AutofillManager {
        mIsFillRequested.set(false);
        mIsFillRequested.set(false);
        mShowAutofillDialogCalled = false;
        mShowAutofillDialogCalled = false;
        mFillDialogTriggerIds = null;
        mFillDialogTriggerIds = null;
        mHasCredentialField = false;
        mAllTrackedViews.clear();
        mAllTrackedViews.clear();
        if (resetEnteredIds) {
        if (resetEnteredIds) {
            mEnteredIds = null;
            mEnteredIds = null;
@@ -3532,7 +3541,8 @@ public final class AutofillManager {
    private boolean shouldShowAutofillDialog(View view, AutofillId id) {
    private boolean shouldShowAutofillDialog(View view, AutofillId id) {
        if (!hasFillDialogUiFeature()
        if (!hasFillDialogUiFeature()
                || mShowAutofillDialogCalled
                || mShowAutofillDialogCalled
                || mFillDialogTriggerIds == null) {
                || mFillDialogTriggerIds == null
                || mHasCredentialField) {
            return false;
            return false;
        }
        }


+0 −30
Original line number Original line Diff line number Diff line
@@ -51,42 +51,12 @@ public class AutofillFeatureFlagsTest {
        assertThat(fillDialogHints[1]).isEqualTo("creditCardNumber");
        assertThat(fillDialogHints[1]).isEqualTo("creditCardNumber");
    }
    }


    @Test
    public void testIsCredentialManagerEnabled() {
        setCredentialManagerEnabled(false);
        assertThat(AutofillFeatureFlags.isCredentialManagerEnabled()).isFalse();
        setCredentialManagerEnabled(true);
        assertThat(AutofillFeatureFlags.isCredentialManagerEnabled()).isTrue();
    }

    @Test
    public void testShouldIgnoreCredentialManagerViews() {
        setCredentialManagerEnabled(false);
        setIgnoreCredentialManagerViews(true);
        // Overall feature is disabled, so we shouldn't ignore views.
        assertThat(AutofillFeatureFlags.shouldIgnoreCredentialViews()).isFalse();
        setCredentialManagerEnabled(true);
        assertThat(AutofillFeatureFlags.shouldIgnoreCredentialViews()).isTrue();
    }

    private static void setFillDialogHints(String value) {
    private static void setFillDialogHints(String value) {
        setDeviceConfig(
        setDeviceConfig(
                AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS,
                AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS,
                value);
                value);
    }
    }


    private static void setCredentialManagerEnabled(boolean value) {
        setDeviceConfig(
                AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED,
                String.valueOf(value));
    }

    private static void setIgnoreCredentialManagerViews(boolean value) {
        setDeviceConfig(
                AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_IGNORE_VIEWS,
                String.valueOf(value));
    }

    private static void setDeviceConfig(String key, String value) {
    private static void setDeviceConfig(String key, String value) {
        DeviceConfig.setProperty(
        DeviceConfig.setProperty(
                DeviceConfig.NAMESPACE_AUTOFILL, key, value, /* makeDefault */ false);
                DeviceConfig.NAMESPACE_AUTOFILL, key, value, /* makeDefault */ false);
Loading