Ensure we leave the orientation changing state.

During the screen rotation animation, we cover the screen in a static
snapshot. Since failing to exit this state is somewhat catastrophic
we have a timeout which is intended to be a catch call. The timeout
works by clearing the mOrientationChanging state of all windows
and then triggering a layout pass. Recently however we made changes
allowing the orientation changing state to persist past the mOrientationChanging
variable. In the bug, we see many notices of timed out draw reporting, but
somehow we still haven't left the orientation changing state
and the screenshot is still visible. I have to admit...this is sort of a guess
I don't understand why we never reported the configuration to the client...though
it seems probably some intracicies of visibility could be at play.

Bug: 64127238
Test: go/wm-smoke
Change-Id: I5dea9bad29e7cdb43aa5e8c9ece5b0a86a1c8a09
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index 4d77d40..5bc4a6b 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -2681,7 +2681,7 @@
             if (!w.getOrientationChanging()) {
                 return;
             }
-            w.setOrientationChanging(false);
+            w.orientationChangeTimedOut();
             w.mLastFreezeDuration = (int)(SystemClock.elapsedRealtime()
                     - mService.mDisplayFreezeTime);
             Slog.w(TAG_WM, "Force clearing orientation change: " + w);
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index c968653..c6b9c52 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -444,6 +444,17 @@
     private boolean mOrientationChanging;
 
     /**
+     * Sometimes in addition to the mOrientationChanging
+     * flag we report that the orientation is changing
+     * due to a mismatch in current and reported configuration.
+     *
+     * In the case of timeout we still need to make sure we
+     * leave the orientation changing state though, so we
+     * use this as a special time out escape hatch.
+     */
+    private boolean mOrientationChangeTimedOut;
+
+    /**
      * The orientation during the last visible call to relayout. If our
      * current orientation is different, the window can't be ready
      * to be shown.
@@ -1221,11 +1232,17 @@
         //                   better indicator consistent with the client.
         return (mOrientationChanging || (isVisible()
                 && getConfiguration().orientation != mLastReportedConfiguration.orientation))
-                && !mSeamlesslyRotated;
+                && !mSeamlesslyRotated
+                && !mOrientationChangeTimedOut;
     }
 
     void setOrientationChanging(boolean changing) {
         mOrientationChanging = changing;
+        mOrientationChangeTimedOut = false;
+    }
+
+    void orientationChangeTimedOut() {
+        mOrientationChangeTimedOut = true;
     }
 
     DisplayContent getDisplayContent() {