diff options
| author | 2023-05-01 00:23:53 +0000 | |
|---|---|---|
| committer | 2023-05-09 04:01:14 +0000 | |
| commit | fa4839d23eeb5b3a07d9ee75470d56b3df654c32 (patch) | |
| tree | 6d226e76a9797990a17fcc1aa1d06449c5c8d6e3 | |
| parent | f1c8054ec6798ae1bfb8dce7049a0dbdbd531b80 (diff) | |
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
4 files changed, 23 insertions, 1 deletions
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java index e39b3a182b28..bee4d1ffc0cb 100644 --- a/core/java/android/view/autofill/AutofillManager.java +++ b/core/java/android/view/autofill/AutofillManager.java @@ -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; } diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java index dd5e58a94d15..cac3c20ec3e0 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java +++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSessionController.java @@ -206,4 +206,11 @@ final class AutofillInlineSessionController { } return false; } + + boolean isImeShowing() { + if (mSession != null) { + return mSession.isImeShowing(); + } + return false; + } } diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java index a089f3ddcb86..468b9ab5710e 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java +++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java @@ -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}. */ diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 3736262e0673..f6a380aba4e2 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -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)) { |