Merge "[DO NOT MERGE] Suppress fill and save dialog for activities that have credman field." into udc-dev
diff --git a/core/java/android/service/autofill/FillRequest.java b/core/java/android/service/autofill/FillRequest.java
index 8afae74..7ec1483 100644
--- a/core/java/android/service/autofill/FillRequest.java
+++ b/core/java/android/service/autofill/FillRequest.java
@@ -121,6 +121,12 @@
      */
     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 */
     public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;
 
@@ -234,7 +240,8 @@
         FLAG_SUPPORTS_FILL_DIALOG,
         FLAG_IME_SHOWING,
         FLAG_RESET_FILL_DIALOG_STATE,
-        FLAG_PCC_DETECTION
+        FLAG_PCC_DETECTION,
+        FLAG_SCREEN_HAS_CREDMAN_FIELD
     })
     @Retention(RetentionPolicy.SOURCE)
     @DataClass.Generated.Member
@@ -266,6 +273,8 @@
                     return "FLAG_RESET_FILL_DIALOG_STATE";
             case FLAG_PCC_DETECTION:
                     return "FLAG_PCC_DETECTION";
+            case FLAG_SCREEN_HAS_CREDMAN_FIELD:
+                    return "FLAG_SCREEN_HAS_CREDMAN_FIELD";
             default: return Integer.toHexString(value);
         }
     }
@@ -282,10 +291,15 @@
      *   include contexts from requests whose {@link SaveInfo} had the
      *   {@link SaveInfo#FLAG_DELAY_SAVE} flag.
      * @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.
      *   The hints would be part of HintConstants:
      *   https://developer.android.com/reference/androidx/autofill/HintConstants
+     *
+     *   This is populated if the platform's field detection is enabled.
      * @param clientState
      *   Gets the latest client state bundle set by the service in a
      *   {@link FillResponse.Builder#setClientState(Bundle) fill response}.
@@ -353,7 +367,8 @@
                         | FLAG_SUPPORTS_FILL_DIALOG
                         | FLAG_IME_SHOWING
                         | FLAG_RESET_FILL_DIALOG_STATE
-                        | FLAG_PCC_DETECTION);
+                        | FLAG_PCC_DETECTION
+                        | FLAG_SCREEN_HAS_CREDMAN_FIELD);
         this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
         this.mDelayedFillIntentSender = delayedFillIntentSender;
 
@@ -381,10 +396,15 @@
     }
 
     /**
-     * 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.
      * The hints would be part of HintConstants:
      * https://developer.android.com/reference/androidx/autofill/HintConstants
+     *
+     * This is populated if the platform's field detection is enabled.
      */
     @DataClass.Generated.Member
     public @NonNull List<String> getHints() {
@@ -534,7 +554,8 @@
                         | FLAG_SUPPORTS_FILL_DIALOG
                         | FLAG_IME_SHOWING
                         | FLAG_RESET_FILL_DIALOG_STATE
-                        | FLAG_PCC_DETECTION);
+                        | FLAG_PCC_DETECTION
+                        | FLAG_SCREEN_HAS_CREDMAN_FIELD);
         this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
         this.mDelayedFillIntentSender = delayedFillIntentSender;
 
@@ -556,10 +577,10 @@
     };
 
     @DataClass.Generated(
-            time = 1675711417112L,
+            time = 1682097266850L,
             codegenVersion = "1.0.23",
             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
     private void __metadata() {}
 
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 003307d..9670735 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10380,11 +10380,6 @@
             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.
         if (getAutofillViewId() <= LAST_APP_AUTOFILL_ID) {
             return false;
diff --git a/core/java/android/view/autofill/AutofillFeatureFlags.java b/core/java/android/view/autofill/AutofillFeatureFlags.java
index 951eecc..b67969e 100644
--- a/core/java/android/view/autofill/AutofillFeatureFlags.java
+++ b/core/java/android/view/autofill/AutofillFeatureFlags.java
@@ -99,39 +99,34 @@
             "autofill_dialog_hints";
 
     // START CREDENTIAL MANAGER FLAGS //
-
     /**
-     * Indicates whether credential manager tagged views should be ignored from autofill structures.
-     * This flag is further gated by {@link #DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_ENABLED}
+     * (deprecated) Indicates whether credential manager tagged views should be ignored from
+     * 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 =
             "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
      * 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 =
             "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}
      *
      * @hide
      */
-    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG =
-            "autofill_credential_manager_suppress_fill_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";
+    public static final String DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG =
+            "autofill_credential_manager_suppress_fill_and_save_dialog";
     // END CREDENTIAL MANAGER FLAGS //
 
     // START AUTOFILL FOR ALL APPS FLAGS //
@@ -270,11 +265,7 @@
 
 
     // CREDENTIAL MANAGER DEFAULTS
-    // Credential manager is enabled by default so as to allow testing by app developers
-    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;
+    private static final boolean DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG = true;
     // END CREDENTIAL MANAGER DEFAULTS
 
 
@@ -317,43 +308,19 @@
                 (str) -> !TextUtils.isEmpty(str));
     }
 
-    /**
-     * 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);
-    }
-
+    /* starts credman flag getter function */
     /**
      * Whether credential manager tagged views should not trigger fill dialog requests.
      *
      * @hide
      */
-    public static boolean isFillDialogDisabledForCredentialManager() {
-        return isCredentialManagerEnabled()
-                && DeviceConfig.getBoolean(
-                DeviceConfig.NAMESPACE_AUTOFILL,
-                DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG,
-                DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_DIALOG);
+    public static boolean isFillAndSaveDialogDisabledForCredentialManager() {
+        return DeviceConfig.getBoolean(
+                    DeviceConfig.NAMESPACE_AUTOFILL,
+                    DEVICE_CONFIG_AUTOFILL_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG,
+                    DEFAULT_CREDENTIAL_MANAGER_SUPPRESS_FILL_AND_SAVE_DIALOG);
     }
+    /* ends credman flag getter function */
 
     /**
      * Whether triggering fill request on unimportant view is enabled.
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 6ff4b74..40549de 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -21,6 +21,7 @@
 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_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_VIEW_NOT_FOCUSED;
 import static android.view.ContentInfo.SOURCE_AUTOFILL;
@@ -33,7 +34,6 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.RequiresFeature;
-import android.annotation.RequiresPermission;
 import android.annotation.SystemApi;
 import android.annotation.SystemService;
 import android.annotation.TestApi;
@@ -109,7 +109,6 @@
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
-import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import sun.misc.Cleaner;
@@ -638,6 +637,8 @@
     @GuardedBy("mLock")
     private boolean mEnabledForAugmentedAutofillOnly;
 
+    private boolean mHasCredentialField;
+
     /**
      * Indicates whether there is already a field to do a fill request after
      * the activity started.
@@ -653,6 +654,8 @@
 
     private final boolean mIsFillDialogEnabled;
 
+    private final boolean mIsFillAndSaveDialogDisabledForCredentialManager;
+
     // Indicate whether trigger fill request on unimportant views is enabled
     private boolean mIsTriggerFillRequestOnUnimportantViewEnabled = false;
 
@@ -699,9 +702,6 @@
     // Indicates whether called the showAutofillDialog() method.
     private boolean mShowAutofillDialogCalled = false;
 
-    // Cached autofill feature flag
-    private boolean mShouldIgnoreCredentialViews = false;
-
     private final String[] mFillDialogEnabledHints;
 
     // Tracked all views that have appeared, including views that there are no
@@ -849,7 +849,10 @@
 
         mIsFillDialogEnabled = AutofillFeatureFlags.isFillDialogEnabled();
         mFillDialogEnabledHints = AutofillFeatureFlags.getFillDialogEnabledHints();
-        mShouldIgnoreCredentialViews = AutofillFeatureFlags.shouldIgnoreCredentialViews();
+
+        mIsFillAndSaveDialogDisabledForCredentialManager =
+            AutofillFeatureFlags.isFillAndSaveDialogDisabledForCredentialManager();
+
         if (sDebug) {
             Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled
                     + ", hints=" + Arrays.toString(mFillDialogEnabledHints));
@@ -1415,12 +1418,12 @@
         if (infos.size() == 0) {
             throw new IllegalArgumentException("No VirtualViewInfo found");
         }
-        if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
-                && view.isCredential()) {
+        if (view.isCredential() && mIsFillAndSaveDialogDisabledForCredentialManager) {
             if (sDebug) {
                 Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                         + view.getAutofillId().toString());
             }
+            mHasCredentialField = true;
             return;
         }
         for (int i = 0; i < infos.size(); i++) {
@@ -1442,12 +1445,13 @@
         if (sDebug) {
             Log.d(TAG, "notifyViewEnteredForFillDialog:" + v.getAutofillId());
         }
-        if (AutofillFeatureFlags.isFillDialogDisabledForCredentialManager()
-                && v.isCredential()) {
+        if (v.isCredential()
+                && mIsFillAndSaveDialogDisabledForCredentialManager) {
             if (sDebug) {
                 Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
-                        + v.getAutofillId().toString());
+                        + v.getAutofillId());
             }
+            mHasCredentialField = true;
             return;
         }
         notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
@@ -1500,7 +1504,7 @@
         if (mIsFillDialogEnabled
                 || ArrayUtils.containsAny(autofillHints, mFillDialogEnabledHints)) {
             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;
@@ -1737,6 +1741,15 @@
                 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);
 
             if (!isActiveLocked()) {
@@ -2240,11 +2253,6 @@
     }
 
     /** @hide */
-    public boolean shouldIgnoreCredentialViews() {
-        return mShouldIgnoreCredentialViews;
-    }
-
-    /** @hide */
     public void onAuthenticationResult(int authenticationId, Intent data, View focusView) {
         if (!hasAutofillFeature()) {
             return;
@@ -2449,6 +2457,7 @@
         mIsFillRequested.set(false);
         mShowAutofillDialogCalled = false;
         mFillDialogTriggerIds = null;
+        mHasCredentialField = false;
         mAllTrackedViews.clear();
         if (resetEnteredIds) {
             mEnteredIds = null;
@@ -3540,7 +3549,8 @@
     private boolean shouldShowAutofillDialog(View view, AutofillId id) {
         if (!hasFillDialogUiFeature()
                 || mShowAutofillDialogCalled
-                || mFillDialogTriggerIds == null) {
+                || mFillDialogTriggerIds == null
+                || mHasCredentialField) {
             return false;
         }
 
diff --git a/core/tests/coretests/src/android/view/autofill/AutofillFeatureFlagsTest.java b/core/tests/coretests/src/android/view/autofill/AutofillFeatureFlagsTest.java
index e03b722..f9b3239 100644
--- a/core/tests/coretests/src/android/view/autofill/AutofillFeatureFlagsTest.java
+++ b/core/tests/coretests/src/android/view/autofill/AutofillFeatureFlagsTest.java
@@ -51,42 +51,12 @@
         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) {
         setDeviceConfig(
                 AutofillFeatureFlags.DEVICE_CONFIG_AUTOFILL_DIALOG_HINTS,
                 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) {
         DeviceConfig.setProperty(
                 DeviceConfig.NAMESPACE_AUTOFILL, key, value, /* makeDefault */ false);
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 9e46d73..d290c361 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -27,6 +27,7 @@
 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_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_VIEW_NOT_FOCUSED;
 import static android.service.autofill.FillRequest.INVALID_REQUEST_ID;
@@ -592,6 +593,9 @@
 
         /** Whether the fill dialog UI is disabled. */
         private boolean mFillDialogDisabled;
+
+        /** Whether current screen has credman field. */
+        private boolean mScreenHasCredmanField;
     }
 
     /**
@@ -3088,6 +3092,20 @@
         final SaveInfo saveInfo = response == null ? null : response.getSaveInfo();
 
         /*
+         * Don't show save if the session has credman field
+         *
+         * TODO: add a new enum NO_SAVE_UI_CREDMAN
+         */
+        if (mSessionFlags.mScreenHasCredmanField) {
+            if (sVerbose) {
+                Slog.v(TAG, "Call to Session#showSaveLocked() rejected - "
+                        + "there is credman field in screen");
+            }
+            return new SaveResult(/* logSaveShown= */ false, /* removeSession= */ true,
+                    Event.NO_SAVE_UI_REASON_NONE);
+        }
+
+        /*
          * The Save dialog is only shown if all conditions below are met:
          *
          * - saveInfo is not null.
@@ -3817,6 +3835,10 @@
             return;
         }
 
+        if ((flags & FLAG_SCREEN_HAS_CREDMAN_FIELD) != 0) {
+            mSessionFlags.mScreenHasCredmanField = true;
+        }
+
         switch(action) {
             case ACTION_START_SESSION:
                 // View is triggering autofill.
@@ -4293,7 +4315,7 @@
 
     private boolean isFillDialogUiEnabled() {
         synchronized (mLock) {
-            return !mSessionFlags.mFillDialogDisabled;
+            return !mSessionFlags.mFillDialogDisabled && !mSessionFlags.mScreenHasCredmanField;
         }
     }