From 7c70647f0fe0bdeff0255c5fa827e206a245330b Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Fri, 5 May 2017 17:12:18 -0700 Subject: [PATCH] Update the app window's thumbnail layer after starting window is removed This fixes the case when bottom app is resuming in portrait mode on a tablet where the thumbnail's title bar appears over the docked app (from the top) only when device slows down (or slow down the animation). This is caused by the StartingWindow removing itself from the display and not updating the thumbnail that is still animating while all the other windows updated their z-ordering. When the apps update their z-order, they lower the dock stack's z-order because the starting window (which was behind the dock stack) is gone. However the thumbnail still has the same z-order meaning that the thumbnail will sit on top of the docked app. So when the starting window disappears, the z-order for the thumbnail will also update to fit behind the docked app. Also simplified the thumbnail layer code. Fixes: 35860227 Bug: 62029108 Test: manual, dock an app in top and bottom, go to recents, slow down device animations by 5-10x, resume any bottom task Change-Id: I79bc92b79e50a7b646b7b6c22802e55e04cc1799 --- .../android/server/wm/AppWindowAnimator.java | 3 +++ .../server/wm/WindowLayersController.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowAnimator.java b/services/core/java/com/android/server/wm/AppWindowAnimator.java index 65e3ec015bc6d..f76926113ef82 100644 --- a/services/core/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/core/java/com/android/server/wm/AppWindowAnimator.java @@ -78,6 +78,9 @@ public class AppWindowAnimator { // requires that the duration of the two animations are the same. SurfaceControl thumbnail; int thumbnailTransactionSeq; + // TODO(b/62029108): combine both members into a private one. Create a member function to set + // the thumbnail layer to +1 to the highest layer position and replace all setter instances + // with this function. Remove all unnecessary calls to both variables in other classes. int thumbnailLayer; int thumbnailForceAboveLayer; Animation thumbnailAnimation; diff --git a/services/core/java/com/android/server/wm/WindowLayersController.java b/services/core/java/com/android/server/wm/WindowLayersController.java index 172ec4871b481..01a3143a7b226 100644 --- a/services/core/java/com/android/server/wm/WindowLayersController.java +++ b/services/core/java/com/android/server/wm/WindowLayersController.java @@ -257,9 +257,20 @@ class WindowLayersController { w.mLayer = layer; w.mWinAnimator.mAnimLayer = w.getAnimLayerAdjustment() + w.getSpecialWindowAnimLayerAdjustment(); - if (w.mAppToken != null && w.mAppToken.mAppAnimator.thumbnailForceAboveLayer > 0 - && w.mWinAnimator.mAnimLayer > w.mAppToken.mAppAnimator.thumbnailForceAboveLayer) { - w.mAppToken.mAppAnimator.thumbnailForceAboveLayer = w.mWinAnimator.mAnimLayer; + if (w.mAppToken != null && w.mAppToken.mAppAnimator.thumbnailForceAboveLayer > 0) { + if (w.mWinAnimator.mAnimLayer > w.mAppToken.mAppAnimator.thumbnailForceAboveLayer) { + w.mAppToken.mAppAnimator.thumbnailForceAboveLayer = w.mWinAnimator.mAnimLayer; + } + // TODO(b/62029108): the entire contents of the if statement should call the refactored + // function to set the thumbnail layer for w.AppToken + int highestLayer = w.mAppToken.getHighestAnimLayer(); + if (highestLayer > 0) { + if (w.mAppToken.mAppAnimator.thumbnail != null + && w.mAppToken.mAppAnimator.thumbnailForceAboveLayer != highestLayer) { + w.mAppToken.mAppAnimator.thumbnailForceAboveLayer = highestLayer; + w.mAppToken.mAppAnimator.thumbnail.setLayer(highestLayer + 1); + } + } } } }