From 8837e66a7e25cd9dee463e0afd4a4cd5fce292ca Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Tue, 22 Aug 2023 16:42:56 +0000 Subject: [PATCH] Avoid sending an IME close request if the IME is already closed. Bug: 277738379 Fix: 296986528 Flag: N/A Test: manual Change-Id: I0a3419f17ee569020c9de673b9507337661bd002 --- .../launcher3/views/ActivityContext.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index 84ea87118c..bef1ce93eb 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -273,13 +273,19 @@ public interface ActivityContext { final WindowInsetsController wic = root.getWindowInsetsController(); WindowInsets insets = root.getRootWindowInsets(); boolean isImeShown = insets != null && insets.isVisible(WindowInsets.Type.ime()); - if (wic != null && isImeShown) { - StatsLogManager slm = getStatsLogManager(); - slm.keyboardStateManager().setKeyboardState(HIDE); + if (wic != null) { + // Only hide the keyboard if it is actually showing. + if (isImeShown) { + StatsLogManager slm = getStatsLogManager(); + slm.keyboardStateManager().setKeyboardState(HIDE); - // this method cannot be called cross threads - wic.hide(WindowInsets.Type.ime()); - slm.logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED); + // this method cannot be called cross threads + wic.hide(WindowInsets.Type.ime()); + slm.logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED); + } + + // If the WindowInsetsController is not null, we end here regardless of whether we + // hid the keyboard or not. return; } }