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

Commit 2ced3d53 authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Don't keep visible windows in pinned stack on screen when app dies"

parents 844ccc5a 3fd20fe8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -608,6 +608,14 @@ public class ActivityManager {
        public static boolean resizeStackWithLaunchBounds(int stackId) {
            return stackId == PINNED_STACK_ID;
        }

        /**
         * Returns true if any visible windows belonging to apps in this stack should be kept on
         * screen when the app is killed due to something like the low memory killer.
         */
        public static boolean keepVisibleDeadAppWindowOnScreen(int stackId) {
            return stackId != PINNED_STACK_ID;
        }
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -2193,7 +2193,7 @@ public class WindowManagerService extends IWindowManager.Stub
            // need to see about starting one.
            wasVisible = win.isWinVisibleLw();

            if (wasVisible && appToken != null && appToken.appDied) {
            if (win.shouldKeepVisibleDeadAppWindow()) {
                if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                        "Not removing " + win + " because app died while it's visible");

+21 −0
Original line number Diff line number Diff line
@@ -1615,6 +1615,27 @@ final class WindowState implements WindowManagerPolicy.WindowState {
        }
    }

    /**
     * Returns true if this window is visible and belongs to a dead app and shouldn't be removed,
     * because we want to preserve its location on screen to be re-activated later when the user
     * interacts with it.
     */
    boolean shouldKeepVisibleDeadAppWindow() {
        if (!isWinVisibleLw() || mAppToken == null || !mAppToken.appDied) {
            // Not a visible app window or the app isn't dead.
            return false;
        }

        if (mAttrs.type == TYPE_APPLICATION_STARTING) {
            // We don't keep starting windows since they were added by the window manager before
            // the app even launched.
            return false;
        }

        final TaskStack stack = getStack();
        return stack != null && StackId.keepVisibleDeadAppWindowOnScreen(stack.mStackId);
    }

    /** @return true if this window desires key events. */
    boolean canReceiveKeys() {
        return isVisibleOrAdding()