From 293e3586cf41f44088bde37990b8120d88ac35ed Mon Sep 17 00:00:00 2001 From: tiger_huang Date: Thu, 13 Nov 2014 18:22:44 +0800 Subject: Clear the previous states before setting the new app visibility If setAppVisibility() is called multiple times in a short interval while the screen is turned off between the calls, the visibility of the app would be wrong. For example, the user may see the app under the launcher, not the wallpaper under the launcher. The flow to the issue: 1. Screen is on. 2. AM calls setAppVisibility() token=App A's token, visible=true 3. Screen is turned off. 4. AM calls setAppVisibility() token=App A's token, visible=false Note: a. In 2., WM would put App A into mOpeningApps, and tell it to be visible. b. In 4., because the screen is off now, App A would not be removed from mOpeningApps. App A might be told to be invisible directly through setTokenVisibilityLocked(), but it would be told to be visible again in handleAppTransitionReadyLocked() later. Change-Id: Icf3d69031ea2822245008248ec8f12bd57218880 --- .../core/java/com/android/server/wm/WindowManagerService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 109785c45a59..de7cb33c218a 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -4626,19 +4626,19 @@ public class WindowManagerService extends IWindowManager.Stub wtoken.hiddenRequested, HIDE_STACK_CRAWLS ? null : new RuntimeException("here").fillInStackTrace()); + mOpeningApps.remove(wtoken); + mClosingApps.remove(wtoken); + wtoken.waitingToShow = wtoken.waitingToHide = false; + wtoken.hiddenRequested = !visible; + // If we are preparing an app transition, then delay changing // the visibility of this token until we execute that transition. if (okToDisplay() && mAppTransition.isTransitionSet()) { - wtoken.hiddenRequested = !visible; - if (!wtoken.startingDisplayed) { if (DEBUG_APP_TRANSITIONS) Slog.v( TAG, "Setting dummy animation on: " + wtoken); wtoken.mAppAnimator.setDummyAnimation(); } - mOpeningApps.remove(wtoken); - mClosingApps.remove(wtoken); - wtoken.waitingToShow = wtoken.waitingToHide = false; wtoken.inPendingTransaction = true; if (visible) { mOpeningApps.add(wtoken); -- cgit v1.2.3-59-g8ed1b