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

Commit 8fa4522b authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Recents transition fixes

- Make sure to destroy the saved surfaces while we resize a task. The
usual destroying mechanism doesn't work here because we don't add the
windows to WMS.mResizingWindows.
- Make sure not to save the surface when a resize happened after the
window has been marked as gone (exiting). In this case, we resize the
task, so we add the window to mResizingWindows, but then when we don't
layout the window because win.isGoneForLayout() == true, so it would
save a surface that has the wrong size.
- Ensure the configuration of the top task when dismissing the docked
stack. First, this speeds up when the user navigates to it in the
fullscreen stack. Second, it fixes some other weirdness with saving
surfaces.
- Only exclude windows from layout when hidden is requested, so when
transitioning from hidden -> shown, the app immediately gets the
updated size when the task was resized when the window was hidden.

Bug: 27276087
Change-Id: I6faf016724136d984b259d184af58d41684f3425
parent 5060bd89
Loading
Loading
Loading
Loading
+31 −25
Original line number Diff line number Diff line
@@ -17768,11 +17768,13 @@ public final class ActivityManagerService extends ActivityManagerNative
            final long origId = Binder.clearCallingIdentity();
            final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
            if (stack != null) {
                mWindowManager.deferSurfaceLayout();
                try {
                    if (fromStackId == DOCKED_STACK_ID) {
                    // We are moving all tasks from the docked stack to the fullscreen stack, which
                    // is dismissing the docked stack, so resize all other stacks to fullscreen here
                    // already so we don't end up with resize trashing.
                        // We are moving all tasks from the docked stack to the fullscreen stack,
                        // which is dismissing the docked stack, so resize all other stacks to
                        // fullscreen here already so we don't end up with resize trashing.
                        for (int i = FIRST_STATIC_STACK_ID; i <= LAST_STATIC_STACK_ID; i++) {
                            if (StackId.isResizeableByDockedStack(i)) {
                                ActivityStack otherStack = mStackSupervisor.getStack(i);
@@ -17789,7 +17791,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                    if (onTop) {
                        for (int i = 0; i < size; i++) {
                            mStackSupervisor.moveTaskToStackLocked(tasks.get(i).taskId,
                                FULLSCREEN_WORKSPACE_STACK_ID, ON_TOP, !FORCE_FOCUS,
                                    FULLSCREEN_WORKSPACE_STACK_ID, onTop, !FORCE_FOCUS,
                                    "moveTasksToFullscreenStack", ANIMATE);
                        }
                    } else {
@@ -17798,6 +17800,10 @@ public final class ActivityManagerService extends ActivityManagerNative
                                    FULLSCREEN_WORKSPACE_STACK_ID, 0);
                        }
                    }
                } finally {
                    mWindowManager.continueSurfaceLayout();
                }
            }
            Binder.restoreCallingIdentity(origId);
        }
+2 −0
Original line number Diff line number Diff line
@@ -2396,6 +2396,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
        stack.positionTask(task, position);
        // The task might have already been running and its visibility needs to be synchronized with
        // the visibility of the stack / windows.
        stack.ensureActivityConfigurationLocked(task.topRunningActivityLocked(), 0,
                !PRESERVE_WINDOWS);
        stack.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
        resumeFocusedStackTopActivityLocked();
    }
+11 −3
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ class Task implements DimLayer.DimLayerUser {
            mStack.removeTask(this);
        }
        stack.positionTask(this, position, showForAllUsers());
        setBounds(bounds, config);
        resizeLocked(bounds, config, false /* force */);
    }

    boolean removeAppToken(AppWindowToken wtoken) {
@@ -272,7 +272,7 @@ class Task implements DimLayer.DimLayerUser {
    }

    /** Set the task bounds. Passing in null sets the bounds to fullscreen. */
    int setBounds(Rect bounds, Configuration config) {
    private int setBounds(Rect bounds, Configuration config) {
        if (config == null) {
            config = Configuration.EMPTY;
        }
@@ -598,13 +598,21 @@ class Task implements DimLayer.DimLayerUser {
    void resizeWindows() {
        final ArrayList<WindowState> resizingWindows = mService.mResizingWindows;
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            final AppWindowToken atoken = mAppTokens.get(activityNdx);

            // Some windows won't go through the resizing process, if they don't have a surface, so
            // destroy all saved surfaces here.
            atoken.destroySavedSurfaces();
            final ArrayList<WindowState> windows = atoken.allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (win.mHasSurface && !resizingWindows.contains(win)) {
                    if (DEBUG_RESIZE) Slog.d(TAG, "resizeWindows: Resizing " + win);
                    resizingWindows.add(win);
                }
                if (win.isGoneForLayoutLw()) {
                    win.mResizedWhileGone = true;
                }
            }
        }
    }
+3 −0
Original line number Diff line number Diff line
@@ -2758,6 +2758,9 @@ public class WindowManagerService extends IWindowManager.Stub
                winAnimator.mReportSurfaceResized = false;
                result |= WindowManagerGlobal.RELAYOUT_RES_SURFACE_RESIZED;
            }
            if (!win.isGoneForLayoutLw()) {
                win.mResizedWhileGone = false;
            }
            outFrame.set(win.mCompatFrame);
            outOverscanInsets.set(win.mOverscanInsets);
            outContentInsets.set(win.mContentInsets);
+12 −1
Original line number Diff line number Diff line
@@ -448,6 +448,11 @@ final class WindowState implements WindowManagerPolicy.WindowState {

    final private Rect mTmpRect = new Rect();

    /**
     * Whether the window was resized by us while it was gone for layout.
     */
    boolean mResizedWhileGone = false;

    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
           WindowState attachedWindow, int appOp, int seq, WindowManager.LayoutParams a,
           int viewVisibility, final DisplayContent displayContent) {
@@ -1235,7 +1240,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        return mViewVisibility == View.GONE
                || !mRelayoutCalled
                || (atoken == null && mRootToken.hidden)
                || (atoken != null && (atoken.hiddenRequested || atoken.hidden))
                || (atoken != null && atoken.hiddenRequested)
                || mAttachedHidden
                || (mAnimatingExit && !isAnimatingLw())
                || mDestroying;
@@ -1836,6 +1841,12 @@ final class WindowState implements WindowManagerPolicy.WindowState {
            return false;
        }

        if (mResizedWhileGone) {
            // Somebody resized our window while we were gone for layout, which means that the
            // client got an old size, so we have an outdated surface here.
            return false;
        }

        if (DEBUG_DISABLE_SAVING_SURFACES) {
            return false;
        }