From 808621ca54d0d72c5e291c290bc13e3d3f3c0140 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Fri, 29 Jul 2016 13:09:40 -0700 Subject: Some fixes for transition animation selection - Request wallpaper adjust after we clear mDestroying or mAnimatingExit flags, as these could affect wallpaper target selection result. - Adjust wallpaper before we check lower/upper target. As there could be pending operations that requested a wall- paper update. Lower/upper target is needed to correctly decide if the opening or closing apps had wallpaper. - Make sure lower/upper targets are set even when current target is clientHidden, in which case we should set wallpaper target to old target but the lower/upper still needs to be set up. Bug: 30790402 Bug: 30255354 Change-Id: Ie2c94439142cbb91660c5aa4164cc660831486d5 (cherry picked from commit ec8299ca4575cb5afe96bb60082d50cb8a01c74b) --- .../java/com/android/server/wm/AppWindowToken.java | 6 +++++ .../com/android/server/wm/WallpaperController.java | 23 +++++++++-------- .../com/android/server/wm/WindowSurfacePlacer.java | 29 ++++++++++++++++------ 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index a9624cfaba95..d55226f24c6c 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -17,7 +17,9 @@ package com.android.server.wm; import static android.app.ActivityManager.StackId; +import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; +import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_APP_TRANSITIONS; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE; @@ -359,6 +361,7 @@ class AppWindowToken extends WindowToken { win.mWinAnimator.mAnimating = false; } } + requestUpdateWallpaperIfNeeded(); } void destroySurfaces() { @@ -406,6 +409,9 @@ class AppWindowToken extends WindowToken { if (displayContent != null && !displayList.contains(displayContent)) { displayList.add(displayContent); } + if (cleanupOnResume) { + win.requestUpdateWallpaperIfNeeded(); + } win.mDestroying = false; } for (int i = 0; i < displayList.size(); i++) { diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index a976b3649554..e53452514ddb 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -590,18 +590,9 @@ class WallpaperController { "Animating wallpapers: old#" + oldI + "=" + oldW + "; new#" + wallpaperTargetIndex + "=" + wallpaperTarget); - // Set the new target correctly. - if (wallpaperTarget.mAppToken != null - && wallpaperTarget.mAppToken.hiddenRequested) { - if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, - "Old wallpaper still the target."); - mWallpaperTarget = oldW; - wallpaperTarget = oldW; - wallpaperTargetIndex = oldI; - } - // Now set the upper and lower wallpaper targets correctly, + // Set the upper and lower wallpaper targets correctly, // and make sure that we are positioning the wallpaper below the lower. - else if (wallpaperTargetIndex > oldI) { + if (wallpaperTargetIndex > oldI) { // The new target is on top of the old one. if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "Found target above old target."); @@ -616,6 +607,16 @@ class WallpaperController { mUpperWallpaperTarget = oldW; mLowerWallpaperTarget = wallpaperTarget; } + + // If the new target is going hidden, set it back to the old target. + if (wallpaperTarget.mAppToken != null + && wallpaperTarget.mAppToken.hiddenRequested) { + if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, + "Old wallpaper still the target."); + mWallpaperTarget = oldW; + wallpaperTarget = oldW; + wallpaperTargetIndex = oldI; + } } } } diff --git a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java index db345f7cf21a..b743b33f046c 100644 --- a/services/core/java/com/android/server/wm/WindowSurfacePlacer.java +++ b/services/core/java/com/android/server/wm/WindowSurfacePlacer.java @@ -1097,6 +1097,26 @@ class WindowSurfacePlacer { boolean fullscreenAnim = false; boolean voiceInteraction = false; + int i; + for (i = 0; i < appsCount; i++) { + final AppWindowToken wtoken = mService.mOpeningApps.valueAt(i); + // Clearing the mAnimatingExit flag before entering animation. It's set to + // true if app window is removed, or window relayout to invisible. + // This also affects window visibility. We need to clear it *before* + // maybeUpdateTransitToWallpaper() as the transition selection depends on + // wallpaper target visibility. + wtoken.clearAnimatingFlags(); + + } + // Adjust wallpaper before we pull the lower/upper target, since pending changes + // (like the clearAnimatingFlags() above) might affect wallpaper target result. + final DisplayContent displayContent = mService.getDefaultDisplayContentLocked(); + if ((displayContent.pendingLayoutChanges & FINISH_LAYOUT_REDO_WALLPAPER) != 0 && + mWallpaperControllerLocked.adjustWallpaperWindows()) { + mService.mLayersController.assignLayersLocked(windows); + displayContent.layoutNeeded = true; + } + final WindowState lowerWallpaperTarget = mWallpaperControllerLocked.getLowerWallpaperTarget(); final WindowState upperWallpaperTarget = @@ -1113,7 +1133,6 @@ class WindowSurfacePlacer { upperWallpaperAppToken = upperWallpaperTarget.mAppToken; } - int i; // Do a first pass through the tokens for two // things: // (1) Determine if both the closing and opening @@ -1138,12 +1157,6 @@ class WindowSurfacePlacer { if (wtoken == lowerWallpaperAppToken || wtoken == upperWallpaperAppToken) { openingAppHasWallpaper = true; } - // Clearing the mAnimatingExit flag before entering animation. It's set to - // true if app window is removed, or window relayout to invisible. - // This also affects window visibility. We need to clear it *before* - // maybeUpdateTransitToWallpaper() as the transition selection depends on - // wallpaper target visibility. - wtoken.clearAnimatingFlags(); } voiceInteraction |= wtoken.voiceInteraction; @@ -1206,7 +1219,7 @@ class WindowSurfacePlacer { // This has changed the visibility of windows, so perform // a new layout to get them all up-to-date. - mService.getDefaultDisplayContentLocked().layoutNeeded = true; + displayContent.layoutNeeded = true; // TODO(multidisplay): IMEs are only supported on the default display. if (windows == mService.getDefaultWindowListLocked() -- cgit v1.2.3-59-g8ed1b