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

Commit 33ff9fb4 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Do not set mAnimatingExit on invisible window" into tm-qpr-dev am: 5dd3c9d4

parents 8f817cc2 5dd3c9d4
Loading
Loading
Loading
Loading
+26 −25
Original line number Original line Diff line number Diff line
@@ -2627,27 +2627,32 @@ public class WindowManagerService extends IWindowManager.Stub
            transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
            transit = WindowManagerPolicy.TRANSIT_PREVIEW_DONE;
        }
        }


        if (win.isWinVisibleLw() && win.mDisplayContent.okToAnimate()) {
            String reason = null;
            String reason = null;
        if (win.isWinVisibleLw() && winAnimator.applyAnimationLocked(transit, false)) {
            if (winAnimator.applyAnimationLocked(transit, false)) {
                reason = "applyAnimation";
                reason = "applyAnimation";
                focusMayChange = true;
                focusMayChange = true;
                win.mAnimatingExit = true;
                win.mAnimatingExit = true;
        } else if (win.mDisplayContent.okToAnimate() && win.isExitAnimationRunningSelfOrParent()) {
            } else if (win.isExitAnimationRunningSelfOrParent()) {
            // Currently in a hide animation... turn this into
                reason = "animating";
            // an exit.
                win.mAnimatingExit = true;
                win.mAnimatingExit = true;
        } else if (win.mDisplayContent.okToAnimate()
            } else if (win.mDisplayContent.mWallpaperController.isWallpaperTarget(win)
                && win.mDisplayContent.mWallpaperController.isWallpaperTarget(win)
                    && win.mAttrs.type != TYPE_NOTIFICATION_SHADE) {
                    && win.mAttrs.type != TYPE_NOTIFICATION_SHADE) {
                reason = "isWallpaperTarget";
                reason = "isWallpaperTarget";
            // If the wallpaper is currently behind this app window, we need to change both of them
                // If the wallpaper is currently behind this app window, they should be updated
            // inside of a transaction to avoid artifacts.
                // in a transaction to avoid artifacts.
            // For NotificationShade, sysui is in charge of running window animation and it updates
                // For NotificationShade, sysui is in charge of running window animation and it
            // the client view visibility only after both NotificationShade and the wallpaper are
                // updates the client view visibility only after both NotificationShade and the
            // hidden. So we don't need to care about exit animation, but can destroy its surface
                // wallpaper are hidden. So the exit animation is not needed and can destroy its
            // immediately.
                // surface immediately.
                win.mAnimatingExit = true;
                win.mAnimatingExit = true;
        } else {
            }
            if (reason != null) {
                ProtoLog.d(WM_DEBUG_ANIM,
                        "Set animatingExit: reason=startExitingAnimation/%s win=%s", reason, win);
            }
        }
        if (!win.mAnimatingExit) {
            boolean stopped = win.mActivityRecord == null || win.mActivityRecord.mAppStopped;
            boolean stopped = win.mActivityRecord == null || win.mActivityRecord.mAppStopped;
            // We set mDestroying=true so ActivityRecord#notifyAppStopped in-to destroy surfaces
            // We set mDestroying=true so ActivityRecord#notifyAppStopped in-to destroy surfaces
            // will later actually destroy the surface if we do not do so here. Normally we leave
            // will later actually destroy the surface if we do not do so here. Normally we leave
@@ -2655,10 +2660,6 @@ public class WindowManagerService extends IWindowManager.Stub
            win.mDestroying = true;
            win.mDestroying = true;
            win.destroySurface(false, stopped);
            win.destroySurface(false, stopped);
        }
        }
        if (reason != null) {
            ProtoLog.d(WM_DEBUG_ANIM, "Set animatingExit: reason=startExitingAnimation/%s win=%s",
                    reason, win);
        }
        if (mAccessibilityController.hasCallbacks()) {
        if (mAccessibilityController.hasCallbacks()) {
            mAccessibilityController.onWindowTransition(win, transit);
            mAccessibilityController.onWindowTransition(win, transit);
        }
        }
+32 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
@@ -43,6 +44,7 @@ import static com.android.server.wm.LetterboxConfiguration.LETTERBOX_BACKGROUND_
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertThat;


import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -55,16 +57,20 @@ import static org.mockito.Mockito.when;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.Binder;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserHandle;
import android.platform.test.annotations.Presubmit;
import android.platform.test.annotations.Presubmit;
import android.util.MergedConfiguration;
import android.view.IWindowSessionCallback;
import android.view.IWindowSessionCallback;
import android.view.InsetsSourceControl;
import android.view.InsetsSourceControl;
import android.view.InsetsState;
import android.view.InsetsState;
import android.view.InsetsVisibilities;
import android.view.InsetsVisibilities;
import android.view.SurfaceControl;
import android.view.View;
import android.view.View;
import android.view.WindowManager;
import android.view.WindowManager;
import android.window.ClientWindowFrames;
import android.window.WindowContainerToken;
import android.window.WindowContainerToken;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
@@ -173,6 +179,32 @@ public class WindowManagerServiceTests extends WindowTestsBase {
        verify(mWm.mAtmService.mTaskSupervisor).wakeUp(anyString());
        verify(mWm.mAtmService.mTaskSupervisor).wakeUp(anyString());
    }
    }


    @Test
    public void testRelayoutExitingWindow() {
        final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, "appWin");
        final WindowSurfaceController surfaceController = mock(WindowSurfaceController.class);
        doReturn(true).when(surfaceController).hasSurface();
        spyOn(win);
        doReturn(true).when(win).isExitAnimationRunningSelfOrParent();
        win.mWinAnimator.mSurfaceController = surfaceController;
        win.mViewVisibility = View.VISIBLE;
        win.mHasSurface = true;
        win.mActivityRecord.mAppStopped = true;
        win.mActivityRecord.mVisibleRequested = false;
        win.mActivityRecord.setVisible(false);
        mWm.mWindowMap.put(win.mClient.asBinder(), win);
        final int w = 100;
        final int h = 200;
        mWm.relayoutWindow(win.mSession, win.mClient, win.mAttrs, w, h, View.GONE, 0,
                new ClientWindowFrames(), new MergedConfiguration(), new SurfaceControl(),
                new InsetsState(), new InsetsSourceControl[0], new Bundle());
        // Because the window is already invisible, it doesn't need to apply exiting animation
        // and WMS#tryStartExitingAnimation() will destroy the surface directly.
        assertFalse(win.mAnimatingExit);
        assertFalse(win.mHasSurface);
        assertNull(win.mWinAnimator.mSurfaceController);
    }

    @Test
    @Test
    public void testMoveWindowTokenToDisplay_NullToken_DoNothing() {
    public void testMoveWindowTokenToDisplay_NullToken_DoNothing() {
        mWm.moveWindowTokenToDisplay(null, mDisplayContent.getDisplayId());
        mWm.moveWindowTokenToDisplay(null, mDisplayContent.getDisplayId());