@@ -2730,10 +2730,10 @@ void removeWindowLocked(WindowState win) {
27302730 wasVisible = win.isWinVisibleLw();
27312731 if (wasVisible) {
27322732
2733- int transit = WindowManagerPolicy.TRANSIT_EXIT;
2734- if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
2735- transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
2736- }
2733+ final int transit = (!startingWindow)
2734+ ? WindowManagerPolicy.TRANSIT_EXIT
2735+ : WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
2736+
27372737 // Try starting an animation.
27382738 if (win.mWinAnimator.applyAnimationLocked(transit, false)) {
27392739 win.mExiting = true;
@@ -2745,12 +2745,13 @@ void removeWindowLocked(WindowState win) {
27452745 }
27462746 }
27472747 final AppWindowToken appToken = win.mAppToken;
2748+ final boolean isAnimating = win.mWinAnimator.isAnimating();
27482749 // The starting window is the last window in this app token and it isn't animating.
27492750 // Allow it to be removed now as there is no additional window or animation that will
27502751 // trigger its removal.
27512752 final boolean lastWinStartingNotAnimating = startingWindow && appToken!= null
2752- && appToken.allAppWindows.size() == 1 && !win.mWinAnimator. isAnimating() ;
2753- if (!lastWinStartingNotAnimating && (win.mExiting || win.mWinAnimator. isAnimating() )) {
2753+ && appToken.allAppWindows.size() == 1 && !isAnimating;
2754+ if (!lastWinStartingNotAnimating && (win.mExiting || isAnimating)) {
27542755 // The exit animation is running... wait for it!
27552756 win.mExiting = true;
27562757 win.mRemoveOnExit = true;
@@ -4527,7 +4528,10 @@ boolean setTokenVisibilityLocked(AppWindowToken wtoken, WindowManager.LayoutPara
45274528 }
45284529
45294530 wtoken.willBeHidden = false;
4530- if (wtoken.hidden == visible) {
4531+ // Allow for state changes and animation to be applied if token is transitioning
4532+ // visibility state or the token was marked as hidden and is exiting before we had a chance
4533+ // to play the transition animation.
4534+ if (wtoken.hidden == visible || (wtoken.hidden && wtoken.mIsExiting)) {
45314535 boolean changed = false;
45324536 if (DEBUG_APP_TRANSITIONS) Slog.v(
45334537 TAG, "Changing app " + wtoken + " hidden=" + wtoken.hidden
0 commit comments