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

Commit 2ab53e3b authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Only link rotation transform of visible activity to wallpaper" into rvc-dev am: 1747c185

Change-Id: I80b1fe3772525a4fd29d01833ac22d6ae73ef21f
parents 5bbcb151 1747c185
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -123,19 +123,20 @@ class WallpaperWindowToken extends WindowToken {
        }
        }


        final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;
        final WallpaperController wallpaperController = mDisplayContent.mWallpaperController;

        if (visible) {
        final WindowState wallpaperTarget = wallpaperController.getWallpaperTarget();
        final WindowState wallpaperTarget = wallpaperController.getWallpaperTarget();

        if (visible && wallpaperTarget != null) {
            final RecentsAnimationController recentsAnimationController =
            final RecentsAnimationController recentsAnimationController =
                    mWmService.getRecentsAnimationController();
                    mWmService.getRecentsAnimationController();
            if (wallpaperTarget != null
            if (recentsAnimationController != null
                    && recentsAnimationController != null
                    && recentsAnimationController.isAnimatingTask(wallpaperTarget.getTask())) {
                    && recentsAnimationController.isAnimatingTask(wallpaperTarget.getTask())) {
                // If the Recents animation is running, and the wallpaper target is the animating
                // If the Recents animation is running, and the wallpaper target is the animating
                // task we want the wallpaper to be rotated in the same orientation as the
                // task we want the wallpaper to be rotated in the same orientation as the
                // RecentsAnimation's target (e.g the launcher)
                // RecentsAnimation's target (e.g the launcher)
                recentsAnimationController.linkFixedRotationTransformIfNeeded(this);
                recentsAnimationController.linkFixedRotationTransformIfNeeded(this);
            } else if (wallpaperTarget != null
            } else if ((wallpaperTarget.mActivityRecord == null
                    // Ignore invisible activity because it may be moving to background.
                    || wallpaperTarget.mActivityRecord.mVisibleRequested)
                    && wallpaperTarget.mToken.hasFixedRotationTransform()) {
                    && wallpaperTarget.mToken.hasFixedRotationTransform()) {
                // If the wallpaper target has a fixed rotation, we want the wallpaper to follow its
                // If the wallpaper target has a fixed rotation, we want the wallpaper to follow its
                // rotation
                // rotation
+23 −0
Original line number Original line Diff line number Diff line
@@ -271,6 +271,29 @@ public class WallpaperControllerTests extends WindowTestsBase {
        assertEquals(WINDOWING_MODE_FULLSCREEN, token.getWindowingMode());
        assertEquals(WINDOWING_MODE_FULLSCREEN, token.getWindowingMode());
    }
    }


    @Test
    public void testFixedRotationRecentsAnimatingTask() {
        final RecentsAnimationController recentsController = mock(RecentsAnimationController.class);
        doReturn(true).when(recentsController).isWallpaperVisible(eq(mAppWindow));
        mWm.setRecentsAnimationController(recentsController);

        mAppWindow.mActivityRecord.applyFixedRotationTransform(mDisplayContent.getDisplayInfo(),
                mDisplayContent.mDisplayFrames, mDisplayContent.getConfiguration());
        mAppWindow.mActivityRecord.mVisibleRequested = true;
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();

        assertEquals(mAppWindow, mDisplayContent.mWallpaperController.getWallpaperTarget());
        // Wallpaper should link the transform of its target.
        assertTrue(mAppWindow.mActivityRecord.hasFixedRotationTransform());

        mAppWindow.mActivityRecord.finishFixedRotationTransform();
        // Invisible requested activity should not share its rotation transform.
        mAppWindow.mActivityRecord.mVisibleRequested = false;
        mDisplayContent.mWallpaperController.adjustWallpaperWindows();

        assertFalse(mAppWindow.mActivityRecord.hasFixedRotationTransform());
    }

    private WindowState createWallpaperTargetWindow(DisplayContent dc) {
    private WindowState createWallpaperTargetWindow(DisplayContent dc) {
        final ActivityRecord homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
        final ActivityRecord homeActivity = new ActivityTestsBase.ActivityBuilder(mWm.mAtmService)
                .setStack(dc.getDefaultTaskDisplayArea().getRootHomeTask())
                .setStack(dc.getDefaultTaskDisplayArea().getRootHomeTask())