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

Commit 641160b7 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by android-build-merger
Browse files

Merge "Remove snapshot when screen gets rotated in mean time" into oc-dev

am: 0823c9ff

Change-Id: Idb18d226c2d7d427fcbb61ff2218d5fd034cb63e
parents e5e4365b 0823c9ff
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -394,6 +394,10 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                    startingWindow.mPolicyVisibility = false;
                    startingWindow.mPolicyVisibility = false;
                    startingWindow.mPolicyVisibilityAfterAnim = false;
                    startingWindow.mPolicyVisibilityAfterAnim = false;
                }
                }

                // We are becoming visible, so better freeze the screen with the windows that are
                // getting visible so we also wait for them.
                forAllWindows(mService::makeWindowFreezingScreenIfNeededLocked, true);
            }
            }


            if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
            if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setVisibility: " + this
+17 −2
Original line number Original line Diff line number Diff line
@@ -125,6 +125,7 @@ class TaskSnapshotSurface implements StartingSurface {
    private final Paint mBackgroundPaint = new Paint();
    private final Paint mBackgroundPaint = new Paint();
    private final int mStatusBarColor;
    private final int mStatusBarColor;
    @VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter;
    @VisibleForTesting final SystemBarBackgroundPainter mSystemBarBackgroundPainter;
    private final int mOrientationOnCreation;


    static TaskSnapshotSurface create(WindowManagerService service, AppWindowToken token,
    static TaskSnapshotSurface create(WindowManagerService service, AppWindowToken token,
            TaskSnapshot snapshot) {
            TaskSnapshot snapshot) {
@@ -146,6 +147,7 @@ class TaskSnapshotSurface implements StartingSurface {
        final int sysUiVis;
        final int sysUiVis;
        final int windowFlags;
        final int windowFlags;
        final int windowPrivateFlags;
        final int windowPrivateFlags;
        final int currentOrientation;
        synchronized (service.mWindowMap) {
        synchronized (service.mWindowMap) {
            final WindowState mainWindow = token.findMainWindow();
            final WindowState mainWindow = token.findMainWindow();
            if (mainWindow == null) {
            if (mainWindow == null) {
@@ -183,6 +185,7 @@ class TaskSnapshotSurface implements StartingSurface {
            } else {
            } else {
                taskBounds = null;
                taskBounds = null;
            }
            }
            currentOrientation = mainWindow.getConfiguration().orientation;
        }
        }
        try {
        try {
            final int res = session.addToDisplay(window, window.mSeq, layoutParams,
            final int res = session.addToDisplay(window, window.mSeq, layoutParams,
@@ -197,7 +200,8 @@ class TaskSnapshotSurface implements StartingSurface {
        }
        }
        final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
        final TaskSnapshotSurface snapshotSurface = new TaskSnapshotSurface(service, window,
                surface, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor,
                surface, snapshot, layoutParams.getTitle(), backgroundColor, statusBarColor,
                navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds);
                navigationBarColor, sysUiVis, windowFlags, windowPrivateFlags, taskBounds,
                currentOrientation);
        window.setOuter(snapshotSurface);
        window.setOuter(snapshotSurface);
        try {
        try {
            session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, tmpFrame,
            session.relayout(window, window.mSeq, layoutParams, -1, -1, View.VISIBLE, 0, tmpFrame,
@@ -215,7 +219,7 @@ class TaskSnapshotSurface implements StartingSurface {
    TaskSnapshotSurface(WindowManagerService service, Window window, Surface surface,
    TaskSnapshotSurface(WindowManagerService service, Window window, Surface surface,
            TaskSnapshot snapshot, CharSequence title, int backgroundColor, int statusBarColor,
            TaskSnapshot snapshot, CharSequence title, int backgroundColor, int statusBarColor,
            int navigationBarColor, int sysUiVis, int windowFlags, int windowPrivateFlags,
            int navigationBarColor, int sysUiVis, int windowFlags, int windowPrivateFlags,
            Rect taskBounds) {
            Rect taskBounds, int currentOrientation) {
        mService = service;
        mService = service;
        mHandler = new Handler(mService.mH.getLooper());
        mHandler = new Handler(mService.mH.getLooper());
        mSession = WindowManagerGlobal.getWindowSession();
        mSession = WindowManagerGlobal.getWindowSession();
@@ -228,6 +232,7 @@ class TaskSnapshotSurface implements StartingSurface {
        mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags,
        mSystemBarBackgroundPainter = new SystemBarBackgroundPainter(windowFlags,
                windowPrivateFlags, sysUiVis, statusBarColor, navigationBarColor);
                windowPrivateFlags, sysUiVis, statusBarColor, navigationBarColor);
        mStatusBarColor = statusBarColor;
        mStatusBarColor = statusBarColor;
        mOrientationOnCreation = currentOrientation;
    }
    }


    @Override
    @Override
@@ -394,6 +399,7 @@ class TaskSnapshotSurface implements StartingSurface {
    static class Window extends BaseIWindow {
    static class Window extends BaseIWindow {


        private TaskSnapshotSurface mOuter;
        private TaskSnapshotSurface mOuter;

        public void setOuter(TaskSnapshotSurface outer) {
        public void setOuter(TaskSnapshotSurface outer) {
            mOuter = outer;
            mOuter = outer;
        }
        }
@@ -403,6 +409,15 @@ class TaskSnapshotSurface implements StartingSurface {
                Rect stableInsets, Rect outsets, boolean reportDraw,
                Rect stableInsets, Rect outsets, boolean reportDraw,
                MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
                MergedConfiguration mergedConfiguration, Rect backDropFrame, boolean forceLayout,
                boolean alwaysConsumeNavBar, int displayId) {
                boolean alwaysConsumeNavBar, int displayId) {
            if (mergedConfiguration != null && mOuter != null
                    && mOuter.mOrientationOnCreation
                            != mergedConfiguration.getMergedConfiguration().orientation) {

                // The orientation of the screen is changing. We better remove the snapshot ASAP as
                // we are going to wait on the new window in any case to unfreeze the screen, and
                // the starting window is not needed anymore.
                sHandler.post(mOuter::remove);
            }
            if (reportDraw) {
            if (reportDraw) {
                sHandler.obtainMessage(MSG_REPORT_DRAW, mOuter).sendToTarget();
                sHandler.obtainMessage(MSG_REPORT_DRAW, mOuter).sendToTarget();
            }
            }
+21 −19
Original line number Original line Diff line number Diff line
@@ -1524,7 +1524,10 @@ class WindowStateAnimator {
    void prepareSurfaceLocked(final boolean recoveringMemory) {
    void prepareSurfaceLocked(final boolean recoveringMemory) {
        final WindowState w = mWin;
        final WindowState w = mWin;
        if (!hasSurface()) {
        if (!hasSurface()) {
            if (w.mOrientationChanging) {

            // There is no need to wait for an animation change if our window is gone for layout
            // already as we'll never be visible.
            if (w.mOrientationChanging && w.isGoneForLayoutLw()) {
                if (DEBUG_ORIENTATION) {
                if (DEBUG_ORIENTATION) {
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                    Slog.v(TAG, "Orientation change skips hidden " + w);
                }
                }
@@ -1557,13 +1560,11 @@ class WindowStateAnimator {
            hide("prepareSurfaceLocked");
            hide("prepareSurfaceLocked");
            mWallpaperControllerLocked.hideWallpapers(w);
            mWallpaperControllerLocked.hideWallpapers(w);


            // If we are waiting for this window to handle an
            // If we are waiting for this window to handle an orientation change. If this window is
            // orientation change, well, it is hidden, so
            // really hidden (gone for layout), there is no point in still waiting for it.
            // doesn't really matter.  Note that this does
            // Note that this does introduce a potential glitch if the window becomes unhidden
            // introduce a potential glitch if the window
            // before it has drawn for the new orientation.
            // becomes unhidden before it has drawn for the
            if (w.mOrientationChanging && w.isGoneForLayoutLw()) {
            // new orientation.
            if (w.mOrientationChanging) {
                w.mOrientationChanging = false;
                w.mOrientationChanging = false;
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                if (DEBUG_ORIENTATION) Slog.v(TAG,
                        "Orientation change skips hidden " + w);
                        "Orientation change skips hidden " + w);
@@ -1630,7 +1631,6 @@ class WindowStateAnimator {
            displayed = true;
            displayed = true;
        }
        }


        if (displayed) {
        if (w.mOrientationChanging) {
        if (w.mOrientationChanging) {
            if (!w.isDrawnLw()) {
            if (!w.isDrawnLw()) {
                mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE;
                mAnimator.mBulkUpdateParams &= ~SET_ORIENTATION_CHANGE_COMPLETE;
@@ -1642,6 +1642,8 @@ class WindowStateAnimator {
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
                if (DEBUG_ORIENTATION) Slog.v(TAG, "Orientation change complete in " + w);
            }
            }
        }
        }

        if (displayed) {
            w.mToken.hasVisible = true;
            w.mToken.hasVisible = true;
        }
        }
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -62,7 +62,8 @@ public class TaskSnapshotSurfaceTest extends WindowTestsBase {
        final TaskSnapshot snapshot = new TaskSnapshot(buffer,
        final TaskSnapshot snapshot = new TaskSnapshot(buffer,
                ORIENTATION_PORTRAIT, contentInsets, false, 1.0f);
                ORIENTATION_PORTRAIT, contentInsets, false, 1.0f);
        mSurface = new TaskSnapshotSurface(sWm, new Window(), new Surface(), snapshot, "Test",
        mSurface = new TaskSnapshotSurface(sWm, new Window(), new Surface(), snapshot, "Test",
                Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds);
                Color.WHITE, Color.RED, Color.BLUE, sysuiVis, windowFlags, 0, taskBounds,
                ORIENTATION_PORTRAIT);
    }
    }


    private void setupSurface(int width, int height) {
    private void setupSurface(int width, int height) {