Do not adjust bounds for IME until IME is actually displayed

When the IME window is just relayout to visibe but not drawn yet,
the given insets of the IME window may not be set. Adjusting the docked
stack at the time may cause wrong bounds to be used. So we wait until
the IME window is actually displayed before moving the bottom stack.

Also move the divider together with the bottom stack when adjusting
for the IME window. This makes it look less janky.

We still have issues with the top stack's bounds changed too early,
which has to be fixed separately.

bug: 27779495
Change-Id: Ic53dc261d430a40677154be5b312a992aab49c79
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 36e8bbb..6741aba 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -96,6 +96,7 @@
     private final Interpolator mMinimizedDockInterpolator;
     private float mMaximizeMeetFraction;
     private final Rect mTouchRegion = new Rect();
+    private boolean mAdjustingForIme;
 
     DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) {
         mService = service;
@@ -173,6 +174,14 @@
         return mLastVisibility;
     }
 
+    void setAdjustingForIme(boolean adjusting) {
+        mAdjustingForIme = adjusting;
+    }
+
+    boolean isAdjustingForIme() {
+        return mAdjustingForIme;
+    }
+
     void positionDockedStackedDivider(Rect frame) {
         TaskStack stack = mDisplayContent.getDockedStackLocked();
         if (stack == null) {