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

Commit 6fb222fa authored by Alex Salo's avatar Alex Salo Committed by Android (Google) Code Review
Browse files

Merge "Make WebViews eligible for Autofill For All Apps (AFAA)" into main

parents 4f69320b 2bcd489a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.view.inspector.InspectableProperty.EnumEntry;
import android.view.translation.TranslationCapability;
import android.view.translation.TranslationSpec.DataFormat;
import android.view.translation.ViewTranslationRequest;
import android.webkit.WebView;
import android.window.OnBackInvokedDispatcher;

import com.android.internal.R;
@@ -3725,6 +3726,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return afm.shouldIncludeAllChildrenViewInAssistStructure();
    }

    private boolean shouldAlwaysIncludeWebview(AutofillManager afm) {
        if (afm == null) return false;
        return afm.shouldAlwaysIncludeWebviewInAssistStructure();
    }

    /** @hide */
    private void populateChildrenForAutofill(ArrayList<View> list, @AutofillFlags int flags) {
        final int childrenCount = mChildrenCount;
@@ -3741,6 +3747,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
                    ? mChildren[childIndex] : preorderedList.get(childIndex);
            if ((flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0
                    || child.isImportantForAutofill()
                    || (child instanceof WebView && shouldAlwaysIncludeWebview(afm))
                    || (child.isMatchingAutofillableHeuristics()
                        && !child.isActivityDeniedForAutofillForUnimportantView())
                    || (shouldIncludeAllChildrenViewWithAutofillTypeNotNone(afm)
+18 −0
Original line number Diff line number Diff line
@@ -209,6 +209,17 @@ public class AutofillFeatureFlags {
        DEVICE_CONFIG_INCLUDE_ALL_VIEWS_IN_ASSIST_STRUCTURE =
            "include_all_views_in_assist_structure";

    /**
     * Whether to always include WebView in assist structure. WebView is a container view that
     * providers "virtual" views. We want to always include such a container view since it can
     * contain arbitrary views in it, some of which could be fillable.
     *
     * @hide
     */
    public static final String
            DEVICE_CONFIG_ALWAYS_INCLUDE_WEBVIEW_IN_ASSIST_STRUCTURE =
            "always_include_webview_in_assist_structure";

    // END AUTOFILL FOR ALL APPS FLAGS //


@@ -441,6 +452,13 @@ public class AutofillFeatureFlags {
            DEVICE_CONFIG_INCLUDE_ALL_VIEWS_IN_ASSIST_STRUCTURE, false);
    }

    /** @hide */
    public static boolean shouldAlwaysIncludeWebviewInAssistStructure() {
        return DeviceConfig.getBoolean(
            DeviceConfig.NAMESPACE_AUTOFILL,
                DEVICE_CONFIG_ALWAYS_INCLUDE_WEBVIEW_IN_ASSIST_STRUCTURE, true);
    }


    /**
     * Whether should enable multi-line filter
+13 −0
Original line number Diff line number Diff line
@@ -728,6 +728,9 @@ public final class AutofillManager {
    // Indicate whether should include all view in assist structure
    private boolean mShouldIncludeAllChildrenViewInAssistStructure;

    // Indicate whether WebView should always be included in the assist structure
    private boolean mShouldAlwaysIncludeWebviewInAssistStructure;

    // Indicates whether called the showAutofillDialog() method.
    private boolean mShowAutofillDialogCalled = false;

@@ -946,6 +949,9 @@ public final class AutofillManager {

        mShouldIncludeAllChildrenViewInAssistStructure
            = AutofillFeatureFlags.shouldIncludeAllChildrenViewInAssistStructure();

        mShouldAlwaysIncludeWebviewInAssistStructure =
                AutofillFeatureFlags.shouldAlwaysIncludeWebviewInAssistStructure();
    }

    /**
@@ -1023,6 +1029,13 @@ public final class AutofillManager {
        return mShouldIncludeAllChildrenViewInAssistStructure;
    }

    /**
     * @hide
     */
    public boolean shouldAlwaysIncludeWebviewInAssistStructure() {
        return mShouldAlwaysIncludeWebviewInAssistStructure;
    }

    /**
     * Get the denied or allowed activitiy names under specified package from the list string and
     * set it in fields accordingly