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

Commit fd3be29c authored by Daniel's avatar Daniel
Browse files

Pre-fetch fill request for credman

If by the time autofill manager client is notified of a credential view
with eligible credman request, then start pre-fetching fill response.
When the fill response is returned, the fill dialog will still be
suppressed during the display phase. If the view does not contain an
eligible credman request, then the pre-fetch won't start since it is
vulnerable to race condition.

Bug: 327032807
Test: locally, atest cts

Change-Id: I58c8fe6b71e3e882ed06ad6f5628f42a2a2cb291
parent 97c80095
Loading
Loading
Loading
Loading
+38 −13
Original line number Diff line number Diff line
@@ -1482,20 +1482,29 @@ public final class AutofillManager {
        if (infos.size() == 0) {
            throw new IllegalArgumentException("No VirtualViewInfo found");
        }
        boolean isCredmanRequested = false;
        if (shouldSuppressDialogsForCredman(view)
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            mScreenHasCredmanField = true;
            if (isCredmanRequested(view)) {
                if (sDebug) {
                    Log.d(TAG, "Prefetching fill response for credMan: "
                            + view.getAutofillId().toString());
                }
                isCredmanRequested = true;
            } else {
                if (sDebug) {
                    Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                            + view.getAutofillId().toString());
                }
            mScreenHasCredmanField = true;
                return;
            }
        }
        for (int i = 0; i < infos.size(); i++) {
            final VirtualViewFillInfo info = infos.valueAt(i);
            final int virtualId = infos.keyAt(i);
            notifyViewReadyInner(getAutofillId(view, virtualId),
                    (info == null) ? null : info.getAutofillHints());
                    (info == null) ? null : info.getAutofillHints(), isCredmanRequested);
        }
    }

@@ -1507,19 +1516,29 @@ public final class AutofillManager {
     * @hide
     */
    public void notifyViewEnteredForFillDialog(View v) {
        boolean isCredmanRequested = false;
        if (shouldSuppressDialogsForCredman(v)
                && mIsFillAndSaveDialogDisabledForCredentialManager) {
            mScreenHasCredmanField = true;
            if (isCredmanRequested(v)) {
                if (sDebug) {
                    Log.d(TAG, "Prefetching fill response for credMan: "
                            + v.getAutofillId().toString());
                }
                isCredmanRequested = true;
            } else {
                if (sDebug) {
                    Log.d(TAG, "Ignoring Fill Dialog request since important for credMan:"
                        + v.getAutofillId());
                            + v.getAutofillId().toString());
                }
            mScreenHasCredmanField = true;
                return;
            }
        notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints());
        }
        notifyViewReadyInner(v.getAutofillId(), v.getAutofillHints(), isCredmanRequested);
    }

    private void notifyViewReadyInner(AutofillId id, @Nullable String[] autofillHints) {
    private void notifyViewReadyInner(AutofillId id, @Nullable String[] autofillHints,
            boolean isCredmanRequested) {
        if (sDebug) {
            Log.d(TAG, "notifyViewReadyInner:" + id);
        }
@@ -1594,6 +1613,12 @@ public final class AutofillManager {
            }
            int flags = FLAG_SUPPORTS_FILL_DIALOG;
            flags |= FLAG_VIEW_NOT_FOCUSED;
            if (isCredmanRequested) {
                if (sDebug) {
                    Log.d(TAG, "Pre fill request is triggered for credMan");
                }
                flags |= FLAG_VIEW_REQUESTS_CREDMAN_SERVICE;
            }
            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