diff options
| -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() { |