diff options
| author | 2023-09-22 00:09:44 +0000 | |
|---|---|---|
| committer | 2023-09-22 00:09:44 +0000 | |
| commit | efe4adb3983db16b95197d87fc246f166dc352a3 (patch) | |
| tree | c9c38ceb2320a0cada451698f73085c1c8bd766c | |
| parent | 78cd26c24b40b7fdc9141381546a980402484b98 (diff) | |
| parent | 0e3d309f9b4ee8adfe151ba679498932acd12260 (diff) | |
Merge "[Webview-FillDialog Support] Fix autofill framework issue found when testing webView prorotype" into udc-qpr-dev am: 760a44b5ff am: 0e3d309f9b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24737218
Change-Id: Id7ccc30494f8c8729a97e3e15152d44b3579442e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | core/java/android/view/autofill/AutofillManager.java | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index 432f6e183731..4cb8788ab9f2 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -1474,7 +1474,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()); } @@ -1488,9 +1488,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) { @@ -1503,11 +1500,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. @@ -1543,26 +1543,38 @@ public final class AutofillManager { final boolean clientAdded = tryAddServiceClientIfNeededLocked(); if (clientAdded) { startSessionLocked(/* id= */ AutofillId.NO_AUTOFILL_ID, /* bounds= */ null, - /* value= */ null, /* flags= */ FLAG_PCC_DETECTION); + /* value= */ null, /* flags= */ FLAG_PCC_DETECTION); } else { if (sVerbose) { 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 @@ -1570,9 +1582,10 @@ public final class AutofillManager { // not match the IME served view's, Autofill will be blocking to wait inline // request from the IME. notifyViewEnteredLocked(/* view= */ null, AutofillId.NO_AUTOFILL_ID, - /* bounds= */ null, /* value= */ null, flags); + /* bounds= */ null, /* value= */ null, flags); } } + return; } private boolean hasFillDialogUiFeature() { |