From 8aee9bc74a1ca2485fe5ce006dfa147bb3dff012 Mon Sep 17 00:00:00 2001 From: Feng Cao Date: Tue, 3 Mar 2020 13:25:40 -0800 Subject: [PATCH] Fix augmented autofill to not send multiple request on the same field * Don't send multiple request when focused view doesn't change * The difference is *when to return*. In the old code, we are returning only when all four conditions are met, otherwise we will go to the next lines requestNewFillResponseOnViewEnteredIfNecessaryLocked() which will indeed trigger a new augmented autofill request. In the new code, we will return if the three conditions are met, or if the other three conditions are met... Test: manual verification Test: atest android.autofillservice.cts.inline Test: atest android.autofillservice.cts.augmented Bug: 145949573 Change-Id: I9ff3873e3aec8c1366d4aa16c9ef7662cfde45e2 --- .../com/android/server/autofill/Session.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 6fb65cae24829..7678e7794dcf9 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -2458,18 +2458,24 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState return; } - if (!isSameViewEntered - && (flags & FLAG_MANUAL_REQUEST) == 0 - && mAugmentedAutofillableIds != null - && mAugmentedAutofillableIds.contains(id)) { - // View was already reported when server could not handle a response, but it - // triggered augmented autofill - - if (sDebug) Slog.d(TAG, "updateLocked(" + id + "): augmented-autofillable"); - - // ...then trigger the augmented autofill UI - triggerAugmentedAutofillLocked(); - return; + if ((flags & FLAG_MANUAL_REQUEST) == 0) { + // Not a manual request + if (mAugmentedAutofillableIds != null && mAugmentedAutofillableIds.contains( + id)) { + // Regular autofill handled the view and returned null response, but it + // triggered augmented autofill + if (!isSameViewEntered) { + if (sDebug) Slog.d(TAG, "trigger augmented autofill."); + triggerAugmentedAutofillLocked(); + } else { + if (sDebug) Slog.d(TAG, "skip augmented autofill for same view."); + } + return; + } else if (mForAugmentedAutofillOnly && isSameViewEntered) { + // Regular autofill is disabled. + if (sDebug) Slog.d(TAG, "skip augmented autofill for same view."); + return; + } } if (requestNewFillResponseOnViewEnteredIfNecessaryLocked(id, viewState, flags)) {