Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec9488c1 authored by Evan Rosky's avatar Evan Rosky
Browse files

Fix Restore transition

Don't replace a change transition type. This was happening
because the wallpaper was becoming visible and the transition
system seems to assume it will be the only thing visible and
replaced the transit with WALLPAPER_OPEN.

Also fixed some other exposed bugs:
- Animation was using stack bounds for freeform windows.
- Non-changing windows were using change anim spec.

Bug: 126956505
Test: atest AppWindowTokenTests AppTransitionControllerTest
      manual, restore a maximized window.

Change-Id: I49bc9bb6c4314e8eb5415a1e2aefc8d61fc0476e
parent 33e1e470
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2237,6 +2237,10 @@ public class AppTransition implements Dump {
                || transit == TRANSIT_ACTIVITY_RELAUNCH;
    }

    static boolean isChangeTransit(int transit) {
        return transit == TRANSIT_TASK_CHANGE_WINDOWING_MODE;
    }

    /**
     * @return whether the transition should show the thumbnail being scaled down.
     */
+8 −1
Original line number Diff line number Diff line
@@ -513,8 +513,11 @@ public class AppTransitionController {
        // Given no app transition pass it through instead of a wallpaper transition.
        // Never convert the crashing transition.
        // Never update the transition for the wallpaper if we are just docking from recents
        // Never convert a change transition since the top activity isn't changing and will likely
        // still be above an opening wallpaper.
        if (transit == TRANSIT_NONE || transit == TRANSIT_CRASHING_ACTIVITY_CLOSE
                || transit == TRANSIT_DOCK_TASK_FROM_RECENTS) {
                || transit == TRANSIT_DOCK_TASK_FROM_RECENTS
                || AppTransition.isChangeTransit(transit)) {
            return transit;
        }

@@ -601,6 +604,10 @@ public class AppTransitionController {
     */
    @VisibleForTesting
    int maybeUpdateTransitToTranslucentAnim(int transit) {
        if (AppTransition.isChangeTransit(transit)) {
            // There's no special animation to handle change animations with translucent apps
            return transit;
        }
        final boolean taskOrActivity = AppTransition.isTaskTransit(transit)
                || AppTransition.isActivityTransit(transit);
        boolean allOpeningVisible = true;
+7 −12
Original line number Diff line number Diff line
@@ -1747,7 +1747,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    }

    boolean isInChangeTransition() {
        return mTransitChangeLeash != null || isChangeTransition(mTransit);
        return mTransitChangeLeash != null || AppTransition.isChangeTransit(mTransit);
    }

    @VisibleForTesting
@@ -2458,14 +2458,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        final Task task = getTask();
        if (task != null && task.inFreeformWindowingMode()) {
            task.getRelativeDisplayedPosition(outPosition);
            task.getBounds(outBounds);
        } else if (stack != null) {
            stack.getRelativeDisplayedPosition(outPosition);
        }

        // Always use stack bounds in order to have the ability to animate outside the task region.
        // It also needs to be consistent when {@link #mNeedsAnimationBoundsLayer} is set that crops
            // Use stack bounds in order to have the ability to animate outside the task region.
            // Needs to be consistent when {@link #mNeedsAnimationBoundsLayer} is set that crops
            // according to the bounds.
        if (stack != null) {
            stack.getBounds(outBounds);
        }
        // We have the relative position so the local position can be removed from bounds.
@@ -2484,10 +2482,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        return getBounds();
    }

    private static boolean isChangeTransition(int transit) {
        return transit == TRANSIT_TASK_CHANGE_WINDOWING_MODE;
    }

    boolean applyAnimationLocked(WindowManager.LayoutParams lp, int transit, boolean enter,
            boolean isVoiceInteraction) {

@@ -2509,7 +2503,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            AnimationAdapter thumbnailAdapter = null;
            getAnimationBounds(mTmpPoint, mTmpRect);

            boolean isChanging = isChangeTransition(transit) && enter;
            final boolean isChanging = AppTransition.isChangeTransit(transit) && enter
                    && getDisplayContent().mChangingApps.contains(this);

            // Delaying animation start isn't compatible with remote animations at all.
            if (getDisplayContent().mAppTransition.getRemoteAnimationController() != null
+18 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.TRANSIT_TASK_CHANGE_WINDOWING_MODE;
import static android.view.WindowManager.TRANSIT_TASK_CLOSE;
import static android.view.WindowManager.TRANSIT_TASK_OPEN;

@@ -77,4 +78,21 @@ public class AppTransitionControllerTest extends WindowTestsBase {
                            TRANSIT_TASK_CLOSE));
        }
    }

    @Test
    public void testChangeIsNotOverwritten() {
        synchronized (mWm.mGlobalLock) {
            final AppWindowToken behind = createAppWindowToken(mDisplayContent,
                    WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
            final AppWindowToken translucentOpening = createAppWindowToken(mDisplayContent,
                    WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
            translucentOpening.setFillsParent(false);
            translucentOpening.setHidden(true);
            mDisplayContent.mOpeningApps.add(behind);
            mDisplayContent.mOpeningApps.add(translucentOpening);
            assertEquals(TRANSIT_TASK_CHANGE_WINDOWING_MODE,
                    mAppTransitionController.maybeUpdateTransitToTranslucentAnim(
                            TRANSIT_TASK_CHANGE_WINDOWING_MODE));
        }
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -489,7 +489,9 @@ public class AppWindowTokenTests extends WindowTestsBase {
        mTask.setBounds(taskBounds);

        mTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
        assertTransitionAnimationPositionAndBounds(taskBounds.left, taskBounds.top, stackBounds);
        final Rect taskBoundsSize = new Rect(taskBounds);
        taskBoundsSize.offsetTo(0, 0);
        assertTransitionAnimationPositionAndBounds(taskBounds.left, taskBounds.top, taskBoundsSize);

        mTask.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
        assertTransitionAnimationPositionAndBounds(stackBounds.left, stackBounds.top, stackBounds);