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

Commit 760a44b5 authored by Haoran Zhang's avatar Haoran Zhang Committed by Android (Google) Code Review
Browse files

Merge "[Webview-FillDialog Support] Fix autofill framework issue found when...

Merge "[Webview-FillDialog Support] Fix autofill framework issue found when testing webView prorotype" into udc-qpr-dev
parents db9f9d76 4aed12b9
Loading
Loading
Loading
Loading
+26 −13
Original line number Diff line number Diff line
@@ -1436,7 +1436,7 @@ public final class AutofillManager {
        }
        for (int i = 0; i < infos.size(); i++) {
            final VirtualViewFillInfo info = infos.valueAt(i);
            final int virtualId = infos.indexOfKey(i);
            final int virtualId = infos.keyAt(i);
            notifyViewReadyInner(getAutofillId(view, virtualId),
                    (info == null) ? null : info.getAutofillHints());
        }
@@ -1450,9 +1450,6 @@ public final class AutofillManager {
     * @hide
     */
    public void notifyViewEnteredForFillDialog(View v) {
        if (sDebug) {
            Log.d(TAG, "notifyViewEnteredForFillDialog:" + v.getAutofillId());
        }
        if (v.isCredential()
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            if (sDebug) {
@@ -1465,11 +1462,14 @@ public final class AutofillManager {
        notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
    }

    private void notifyViewReadyInner(AutofillId id, String[] autofillHints) {
    private void notifyViewReadyInner(AutofillId id, @Nullable String[] autofillHints) {
        if (sDebug) {
            Log.d(TAG, "notifyViewReadyInner:" + id);
        }

        if (!hasAutofillFeature()) {
            return;
        }

        synchronized (mLock) {
            if (mAllTrackedViews.contains(id)) {
                // The id is tracked and will not trigger pre-fill request again.
@@ -1511,20 +1511,32 @@ public final class AutofillManager {
                            Log.v(TAG, "not starting session: no service client");
                        }
                    }

                }
            }
        }

        if (mIsFillDialogEnabled
                || ArrayUtils.containsAny(autofillHints, mFillDialogEnabledHints)) {
        // Check if framework should send pre-fill request for fill dialog
        boolean shouldSendPreFillRequestForFillDialog = false;
        if (mIsFillDialogEnabled) {
            shouldSendPreFillRequestForFillDialog = true;
        } else if (autofillHints != null) {
            // check if supported autofill hint is present
            for (String autofillHint : autofillHints) {
                for (String filldialogEnabledHint : mFillDialogEnabledHints) {
                    if (filldialogEnabledHint.equalsIgnoreCase(autofillHint)) {
                        shouldSendPreFillRequestForFillDialog = true;
                        break;
                    }
                }
                if (shouldSendPreFillRequestForFillDialog) break;
            }
        }
        if (shouldSendPreFillRequestForFillDialog) {
            if (sDebug) {
                Log.d(TAG, "Triggering pre-emptive request for fill dialog.");
            }

            int flags = FLAG_SUPPORTS_FILL_DIALOG;
            flags |= FLAG_VIEW_NOT_FOCUSED;

            synchronized (mLock) {
                // To match the id of the IME served view, used AutofillId.NO_AUTOFILL_ID on prefill
                // request, because IME will reset the id of IME served view to 0 when activity
@@ -1535,6 +1547,7 @@ public final class AutofillManager {
                    /* bounds= */ null,  /* value= */ null, flags);
            }
        }
        return;
    }

    private boolean hasFillDialogUiFeature() {