Stop to show fill dialog if IME is showing

Because the request to show the fill dialog and the IME is asynchronous.
To reduce the fill dialog appearing on the IME, check to see if the IME
shows it before showing the fill dialog.

This change does not fully resolve the IME and fill dialog showing
at the same time but can mitigate the problem. More details see the bug.

When supported fill dialog flag is appended, the view of parameter
will be null. So remove to check the view is not null when appending
the reset fill dialog flag.

Bug: 236436818
Test: atest CtsAutoFillServiceTestCases
Change-Id: I4dbfaa1ae398ec067652418f7dd66ced305ea5f7
This commit is contained in:
TYM Tsai
2023-05-01 00:23:53 +00:00
parent f1c8054ec6
commit fa4839d23e
4 changed files with 23 additions and 1 deletions

View File

@@ -1744,7 +1744,7 @@ public final class AutofillManager {
mForAugmentedAutofillOnly = false;
}
if ((flags & FLAG_SUPPORTS_FILL_DIALOG) != 0 && view != null) {
if ((flags & FLAG_SUPPORTS_FILL_DIALOG) != 0) {
flags |= FLAG_RESET_FILL_DIALOG_STATE;
}

View File

@@ -206,4 +206,11 @@ final class AutofillInlineSessionController {
}
return false;
}
boolean isImeShowing() {
if (mSession != null) {
return mSession.isImeShowing();
}
return false;
}
}

View File

@@ -106,6 +106,8 @@ final class AutofillInlineSuggestionsRequestSession {
@GuardedBy("mLock")
private boolean mImeSessionInvalidated = false;
private boolean mImeShowing = false;
AutofillInlineSuggestionsRequestSession(
@NonNull InputMethodManagerInternal inputMethodManagerInternal, int userId,
@NonNull ComponentName componentName, @NonNull Handler handler, @NonNull Object lock,
@@ -320,6 +322,7 @@ final class AutofillInlineSuggestionsRequestSession {
if (mDestroyed) {
return;
}
mImeShowing = imeInputViewStarted;
if (mImeCurrentFieldId != null) {
boolean imeInputStartedChanged = (mImeInputStarted != imeInputStarted);
boolean imeInputViewStartedChanged = (mImeInputViewStarted != imeInputViewStarted);
@@ -364,6 +367,12 @@ final class AutofillInlineSuggestionsRequestSession {
}
}
boolean isImeShowing() {
synchronized (mLock) {
return !mDestroyed && mImeShowing;
}
}
/**
* Internal implementation of {@link IInlineSuggestionsRequestCallback}.
*/

View File

@@ -4281,6 +4281,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return false;
}
if (mInlineSessionController.isImeShowing()) {
// IME is showing, fallback to normal suggestions UI
// Note: only work when inline suggestions supported
return false;
}
synchronized (mLock) {
if (mLastFillDialogTriggerIds == null
|| !ArrayUtils.contains(mLastFillDialogTriggerIds, filledId)) {