diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 8bf32324dd5a6..ef76ce36ec0f8 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -142,7 +142,6 @@ import android.view.accessibility.AccessibilityWindowInfo; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.Transformation; -import android.view.autofill.AutofillFeatureFlags; import android.view.autofill.AutofillId; import android.view.autofill.AutofillManager; import android.view.autofill.AutofillValue; @@ -10363,15 +10362,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private boolean isAutofillable() { if (getAutofillType() == AUTOFILL_TYPE_NONE) return false; + final AutofillManager afm = getAutofillManager(); + if (afm == null) { + return false; + } + // Disable triggering autofill if the view is integrated with CredentialManager. - if (AutofillFeatureFlags.shouldIgnoreCredentialViews() - && isCredential()) return false; + if (afm.shouldIgnoreCredentialViews() && isCredential()) { + return false; + } if (!isImportantForAutofill()) { // If view matches heuristics and is not denied, it will be treated same as view that's // important for autofill - if (isMatchingAutofillableHeuristics() - && !isActivityDeniedForAutofillForUnimportantView()) { + if (afm.isMatchingAutofillableHeuristics(this) + && !afm.isActivityDeniedForAutofillForUnimportantView()) { return getAutofillViewId() > LAST_APP_AUTOFILL_ID; } // View is not important for "regular" autofill, so we must check if Augmented Autofill @@ -10380,8 +10385,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (options == null || !options.isAugmentedAutofillEnabled(mContext)) { return false; } - final AutofillManager afm = getAutofillManager(); - if (afm == null) return false; + afm.notifyViewEnteredForAugmentedAutofill(this); } diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index ab9f492694f57..14c781bb5560e 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -691,6 +691,9 @@ public final class AutofillManager { // 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 @@ -838,6 +841,7 @@ public final class AutofillManager { mIsFillDialogEnabled = AutofillFeatureFlags.isFillDialogEnabled(); mFillDialogEnabledHints = AutofillFeatureFlags.getFillDialogEnabledHints(); + mShouldIgnoreCredentialViews = AutofillFeatureFlags.shouldIgnoreCredentialViews(); if (sDebug) { Log.d(TAG, "Fill dialog is enabled:" + mIsFillDialogEnabled + ", hints=" + Arrays.toString(mFillDialogEnabledHints)); @@ -2080,6 +2084,11 @@ public final class AutofillManager { return client != null && client.autofillClientIsFillUiShowing(); } + /** @hide */ + public boolean shouldIgnoreCredentialViews() { + return mShouldIgnoreCredentialViews; + } + /** @hide */ public void onAuthenticationResult(int authenticationId, Intent data, View focusView) { if (!hasAutofillFeature()) {