Fix ordering of check minimized state callback

- We previously notified the docked stack minimized changed asynchronously
  (ag/6130053) but now this is a direct call, which causes the notify to
  trigger a cancel of the recents animation, which triggers another
  notifyDockedStackMinimizedChanged() call with the new state, which leads
  to an inversion of delivered states to sysui.  Instead, always notify
  the remote listeners prior to synchronously updating the internal state.

Bug: 133243292
Test: Show the IME in split screen and try to swipe up (this should just
      dismiss the IME and not leave the user in a broken split screen
      minimized state)

Change-Id: I181e039d5823b635e36657a795d05c9e30366364
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 1d76a71..b1bc2197 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -569,7 +569,6 @@
             mMaximizeMeetFraction = getClipRevealMeetFraction(stack);
             animDuration = (long) (mAnimationDuration * mMaximizeMeetFraction);
         }
-        mService.mAtmInternal.notifyDockedStackMinimizedChanged(minimizedDock);
         final int size = mDockedStackListeners.beginBroadcast();
         for (int i = 0; i < size; ++i) {
             final IDockedStackListener listener = mDockedStackListeners.getBroadcastItem(i);
@@ -581,6 +580,9 @@
             }
         }
         mDockedStackListeners.finishBroadcast();
+        // Only notify ATM after we update the remote listeners, otherwise it may trigger another
+        // minimize change, which would lead to an inversion of states send to the listeners
+        mService.mAtmInternal.notifyDockedStackMinimizedChanged(minimizedDock);
     }
 
     void notifyDockSideChanged(int newDockSide) {