Close IME when attaching dock stack
So we don't end up with animation weirdness.
Bug: 28905720
Change-Id: I04124995dd99fa26d2e9be467c5976d7b20810a7
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 1b31d07c..77b3bdb 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -45,9 +45,11 @@
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;
+import android.view.inputmethod.InputMethodManagerInternal;
import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DockedDividerUtils;
+import com.android.server.LocalServices;
import com.android.server.wm.DimLayer.DimLayerUser;
import com.android.server.wm.WindowManagerService.H;
@@ -131,6 +133,7 @@
private float mLastAnimationProgress;
private float mLastDividerProgress;
private final DividerSnapAlgorithm[] mSnapAlgorithmForRotation = new DividerSnapAlgorithm[4];
+ private boolean mImeHideRequested;
DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) {
mService = service;
@@ -375,11 +378,39 @@
}
}
mDockedStackListeners.finishBroadcast();
- if (!exists) {
+ if (exists) {
+ InputMethodManagerInternal inputMethodManagerInternal =
+ LocalServices.getService(InputMethodManagerInternal.class);
+ if (inputMethodManagerInternal != null) {
+
+ // Hide the current IME to avoid problems with animations from IME adjustment when
+ // attaching the docked stack.
+ inputMethodManagerInternal.hideCurrentInputMethod();
+ mImeHideRequested = true;
+ }
+ } else {
setMinimizedDockedStack(false);
}
}
+ /**
+ * Resets the state that IME hide has been requested. See {@link #isImeHideRequested}.
+ */
+ void resetImeHideRequested() {
+ mImeHideRequested = false;
+ }
+
+ /**
+ * The docked stack divider controller makes sure the IME gets hidden when attaching the docked
+ * stack, to avoid animation problems. This flag indicates whether the request to hide the IME
+ * has been sent in an asynchronous manner, and the IME should be treated as hidden already.
+ *
+ * @return whether IME hide request has been sent
+ */
+ boolean isImeHideRequested() {
+ return mImeHideRequested;
+ }
+
void notifyDockedStackMinimizedChanged(boolean minimizedDock, long animDuration) {
mService.mH.removeMessages(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED);
mService.mH.obtainMessage(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED,