diff options
| author | 2023-02-24 18:53:09 -0800 | |
|---|---|---|
| committer | 2023-02-28 16:27:27 +0000 | |
| commit | 3fd0b400ee46089d3a6eb5afafe67d6231f68cf5 (patch) | |
| tree | b07d551914a67b1f79eccc3a907fd8f25086123c | |
| parent | 031692c511c0aace8c1eb1efe0c1a199ffb94db1 (diff) | |
Do not forward & register IME compat back callback in the app process.
IME window's ViewRootImpl registers its compat callback when the first child view is added. If the app dispatches start input and sets a forwarding dispatcher on the IME's WindowOnBackInvokedDispatcher, before IME ViewRootImpl receives its first child, the compat callback would be forwarded to app process and registered on the app window.
We should prevent this from happening because the IME window never has focus and the compat callback will just get stuck and break back nav.
Test: m -j.
Test: for run in {1..500}; do adb shell input tap 164 1950; sleep 1; adb shell input swipe 50 1000 200 1000; sleep 1; done
Bug: 269821450
Change-Id: I9157d8d9c85edc29a5d004709c2cd3e25764b56a
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 4 | ||||
| -rw-r--r-- | core/java/android/window/WindowOnBackInvokedDispatcher.java | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index f430ec300b5b..2ff9ad346a71 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -11382,6 +11382,10 @@ public final class ViewRootImpl implements ViewParent, sendBackKeyEvent(KeyEvent.ACTION_DOWN); sendBackKeyEvent(KeyEvent.ACTION_UP); }; + if (mOnBackInvokedDispatcher.hasImeOnBackInvokedDispatcher()) { + Log.d(TAG, "Skip registering CompatOnBackInvokedCallback on IME dispatcher"); + return; + } mOnBackInvokedDispatcher.registerOnBackInvokedCallback( OnBackInvokedDispatcher.PRIORITY_DEFAULT, mCompatOnBackInvokedCallback); } diff --git a/core/java/android/window/WindowOnBackInvokedDispatcher.java b/core/java/android/window/WindowOnBackInvokedDispatcher.java index a8c2b2f28df4..8066f5085a01 100644 --- a/core/java/android/window/WindowOnBackInvokedDispatcher.java +++ b/core/java/android/window/WindowOnBackInvokedDispatcher.java @@ -357,6 +357,11 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher { mImeDispatcher = imeDispatcher; } + /** Returns true if a non-null {@link ImeOnBackInvokedDispatcher} has been set. **/ + public boolean hasImeOnBackInvokedDispatcher() { + return mImeDispatcher != null; + } + /** * Class used to check whether a callback can be registered or not. This is meant to be * shared with {@link ProxyOnBackInvokedDispatcher} which needs to do the same checks. |