summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/ImeFocusController.java12
-rw-r--r--core/java/android/view/InsetsController.java3
2 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/view/ImeFocusController.java b/core/java/android/view/ImeFocusController.java
index 97148969e17f..2d2f79d76008 100644
--- a/core/java/android/view/ImeFocusController.java
+++ b/core/java/android/view/ImeFocusController.java
@@ -23,6 +23,7 @@ import android.annotation.NonNull;
import android.annotation.UiThread;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
+import android.view.inputmethod.Flags;
import android.view.inputmethod.InputMethodManager;
import com.android.internal.inputmethod.InputMethodDebug;
@@ -150,6 +151,17 @@ public final class ImeFocusController {
if (!mHasImeFocus || isInLocalFocusMode(windowAttribute)) {
return InputMethodManager.DISPATCH_NOT_HANDLED;
}
+ if (Flags.refactorInsetsController() && event instanceof KeyEvent keyEvent
+ && keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK) {
+ final var insetsController = mViewRootImpl.getInsetsController();
+ if (insetsController.getAnimationType(WindowInsets.Type.ime())
+ == InsetsController.ANIMATION_TYPE_HIDE
+ || insetsController.isPredictiveBackImeHideAnimInProgress()) {
+ // if there is an ongoing hide animation, the back event should not be dispatched
+ // to the IME.
+ return InputMethodManager.DISPATCH_NOT_HANDLED;
+ }
+ }
final InputMethodManager imm =
mViewRootImpl.mContext.getSystemService(InputMethodManager.class);
if (imm == null) {
diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java
index 26ca813a9caa..b0813f3a98f6 100644
--- a/core/java/android/view/InsetsController.java
+++ b/core/java/android/view/InsetsController.java
@@ -1910,7 +1910,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
mImeSourceConsumer.onWindowFocusLost();
}
- @VisibleForTesting
+ /** Returns the current {@link AnimationType} of an {@link InsetsType}. */
+ @VisibleForTesting(visibility = PACKAGE)
public @AnimationType int getAnimationType(@InsetsType int type) {
for (int i = mRunningAnimations.size() - 1; i >= 0; i--) {
InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner;