Boost the anim thread priority when doing a bounds animation.

Bug: 36371375
Bug: 36631902
Test: Start PIP, ensure anim thread priority is boosted for entire
      transition

Change-Id: Id60ce7a2b7791de2786d683dbe148483d0ad0f04
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index 7d13889..cff2fad 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -206,6 +206,10 @@
             mTmpRect.set(mFrom.left, mFrom.top, mFrom.left + mFrozenTaskWidth,
                     mFrom.top + mFrozenTaskHeight);
 
+            // Boost the thread priority of the animation thread while the bounds animation is
+            // running
+            updateBooster();
+
             // Ensure that we have prepared the target for animation before
             // we trigger any size changes, so it can swap surfaces
             // in to appropriate modes, or do as it wishes otherwise.
@@ -316,6 +320,9 @@
             removeListener(this);
             removeUpdateListener(this);
             mRunningAnimations.remove(mTarget);
+
+            // Reset the thread priority of the animation thread after the bounds animation is done
+            updateBooster();
         }
 
         @Override
@@ -446,4 +453,9 @@
             b.resume();
         }
     }
+
+    private void updateBooster() {
+        WindowManagerService.sThreadPriorityBooster.setBoundsAnimationRunning(
+                !mRunningAnimations.isEmpty());
+    }
 }