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

Commit 3fd20fe8 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

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

We previously introduced logic that keeps an apps visible windows on
screen when the app dies. This was to help with the situation where
freeform apps might be killed by the low memory killer and we want
to preserve the space on screen and relaunch the app when the user
interacts with the window again.
However, this doesn't work for windows in the pinned stack since
they an normally not focusable/interactable.
We no longer do this for windows in the pinned stack.

Bug: 24913379
Bug: 26609941
Change-Id: Ie2e7f7d7c7a8c0ef6c1662517f558c385201c433
parent 09a02f1c
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()