OSDN Git Service

Assign layer to bounds animation layer
authorJorim Jaggi <jjaggi@google.com>
Wed, 24 Apr 2019 15:41:35 +0000 (17:41 +0200)
committerJorim Jaggi <jjaggi@google.com>
Wed, 24 Apr 2019 15:41:35 +0000 (17:41 +0200)
Test: AppWindowTokenAnimationTests
Fixes: 130139437
Change-Id: Id68eabdacb569bcca292dace00b7e524fef9f0da

services/core/java/com/android/server/wm/AppWindowToken.java
services/tests/wmtests/src/com/android/server/wm/AppWindowTokenAnimationTests.java

index a53f85d..56cfe58 100644 (file)
@@ -144,7 +144,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
     /**
      * Value to increment the z-layer when boosting a layer during animations. BOOST in l33tsp34k.
      */
-    private static final int Z_BOOST_BASE = 800570000;
+    @VisibleForTesting static final int Z_BOOST_BASE = 800570000;
 
     // Non-null only for application tokens.
     final IApplicationToken appToken;
@@ -293,7 +293,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
     private boolean mFreezingScreen;
 
     /** Whether this token should be boosted at the top of all app window tokens. */
-    private boolean mNeedsZBoost;
+    @VisibleForTesting boolean mNeedsZBoost;
     private Letterbox mLetterbox;
 
     private final Point mTmpPoint = new Point();
@@ -2693,7 +2693,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
         if (mNeedsZBoost) {
             layer += Z_BOOST_BASE;
         }
-        leash.setLayer(layer);
+        if (!mNeedsAnimationBoundsLayer) {
+            leash.setLayer(layer);
+        }
 
         final DisplayContent dc = getDisplayContent();
         dc.assignStackOrdering();
@@ -2730,6 +2732,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
 
             // Crop to stack bounds.
             t.setWindowCrop(mAnimationBoundsLayer, mTmpRect);
+            t.setLayer(mAnimationBoundsLayer, layer);
 
             // Reparent leash to animation bounds layer.
             t.reparent(leash, mAnimationBoundsLayer);
index db04f11..623559e 100644 (file)
@@ -25,6 +25,7 @@ import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.intThat;
 
 import android.platform.test.annotations.Presubmit;
 import android.view.SurfaceControl;
@@ -75,6 +76,16 @@ public class AppWindowTokenAnimationTests extends WindowTestsBase {
     }
 
     @Test
+    public void clipAfterAnim_boundsLayerZBoosted() {
+        mToken.mNeedsAnimationBoundsLayer = true;
+        mToken.mNeedsZBoost = true;
+
+        mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */);
+        verify(mTransaction).setLayer(eq(mToken.mAnimationBoundsLayer),
+                intThat(layer -> layer >= AppWindowToken.Z_BOOST_BASE));
+    }
+
+    @Test
     public void clipAfterAnim_boundsLayerIsDestroyed() {
         mToken.mNeedsAnimationBoundsLayer = true;
         mToken.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */);