diff options
| author | 2024-06-27 14:03:48 +0000 | |
|---|---|---|
| committer | 2024-06-27 14:03:48 +0000 | |
| commit | c478dd15cae174e5b77939dd8f53bce1951d0fda (patch) | |
| tree | 9f409270f1fccb713b67a92eb6ccfbe5d33cb3d7 | |
| parent | e84fdcef8279905f1fe5168645918827dfad4422 (diff) | |
Do not intercept Back Key Event with FLAG_PRE_IME_ONLY in NativePreIme stage
If the Back Key Event has the FLAG_PRE_IME_ONLY set, it should not be intercepted at the NativePreIme stage. Instead, the event is solely intended for the ViewPreImeInputStage to give apps the chance to intercept the back event before the predictive IME back animation commits.
Without this change, we would send back events to the active animation callback in some cases (in `doOnBackKeyEvent`) even though the back key event was just injected by WindowOnBackInvokedDispatcher to give the app the chance to intercept it.
Bug: 341013064
Flag: android.view.inputmethod.predictive_back_ime
Test: Manual, i.e. verifying that no callback methods are called by ViewRootImpl on animation callback during pre-ime handling of injected back key event
Change-Id: Icd8a1ff3117f0acb668e4c05c5e353cd8847047c
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 1494d21e7769..95e02ebb04f2 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -7312,6 +7312,10 @@ public final class ViewRootImpl implements ViewParent, @Override protected int onProcess(QueuedInputEvent q) { + if (q.forPreImeOnly()) { + // this event is intended for the ViewPreImeInputStage only, let's forward + return FORWARD; + } if (q.mEvent instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) q.mEvent; |