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

Commit 87a18d9e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't remove all app token windows when window client dies" into nyc-dev

parents d4d1512b e42d0e10
Loading
Loading
Loading
Loading
+15 −7
Original line number Original line Diff line number Diff line
@@ -109,7 +109,6 @@ class AppWindowToken extends WindowToken {
    // Set to true when the token has been removed from the window mgr.
    // Set to true when the token has been removed from the window mgr.
    boolean removed;
    boolean removed;


    boolean appDied;
    // Information about an application starting window if displayed.
    // Information about an application starting window if displayed.
    StartingData startingData;
    StartingData startingData;
    WindowState startingWindow;
    WindowState startingWindow;
@@ -476,6 +475,15 @@ class AppWindowToken extends WindowToken {
        }
        }
    }
    }


    boolean hasWindowsAlive() {
        for (int i = allAppWindows.size() - 1; i >= 0; i--) {
            if (!allAppWindows.get(i).mAppDied) {
                return true;
            }
        }
        return false;
    }

    void setReplacingWindows(boolean animate) {
    void setReplacingWindows(boolean animate) {
        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
        if (DEBUG_ADD_REMOVE) Slog.d(TAG_WM, "Marking app token " + appWindowToken
                + " with replacing windows.");
                + " with replacing windows.");
+3 −3
Original line number Original line Diff line number Diff line
@@ -125,9 +125,9 @@ class Task implements DimLayer.DimLayerUser {
        mHomeTask = homeTask;
        mHomeTask = homeTask;
    }
    }


    private boolean hasAppTokensAlive() {
    private boolean hasWindowsAlive() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            if (!mAppTokens.get(i).appDied) {
            if (mAppTokens.get(i).hasWindowsAlive()) {
                return true;
                return true;
            }
            }
        }
        }
@@ -135,7 +135,7 @@ class Task implements DimLayer.DimLayerUser {
    }
    }


    void removeLocked() {
    void removeLocked() {
        if (hasAppTokensAlive() && mStack.isAnimating()) {
        if (hasWindowsAlive() && mStack.isAnimating()) {
            if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + mTaskId);
            if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + mTaskId);
            mDeferRemoval = true;
            mDeferRemoval = true;
            return;
            return;
+8 −10
Original line number Original line Diff line number Diff line
@@ -2000,11 +2000,6 @@ public class WindowManagerService extends IWindowManager.Stub
                return WindowManagerGlobal.ADD_INVALID_DISPLAY;
                return WindowManagerGlobal.ADD_INVALID_DISPLAY;
            }
            }


            if (atoken != null && atoken.appDied) {
                Slog.d(TAG_WM, "App is now revived: " + atoken);
                atoken.appDied = false;
            }

            mPolicy.adjustWindowParamsLw(win.mAttrs);
            mPolicy.adjustWindowParamsLw(win.mAttrs);
            win.setShowToOwnerOnlyLocked(mPolicy.checkShowToOwnerOnly(attrs));
            win.setShowToOwnerOnlyLocked(mPolicy.checkShowToOwnerOnly(attrs));


@@ -2260,6 +2255,10 @@ public class WindowManagerService extends IWindowManager.Stub
    }
    }


    void removeWindowLocked(WindowState win) {
    void removeWindowLocked(WindowState win) {
        removeWindowLocked(win, false);
    }

    void removeWindowLocked(WindowState win, boolean keepVisibleDeadWindow) {
        win.mWindowRemovalAllowed = true;
        win.mWindowRemovalAllowed = true;
        if (DEBUG_ADD_REMOVE) Slog.v(TAG,
        if (DEBUG_ADD_REMOVE) Slog.v(TAG,
                "removeWindowLocked: " + win + " callers=" + Debug.getCallers(4));
                "removeWindowLocked: " + win + " callers=" + Debug.getCallers(4));
@@ -2317,7 +2316,7 @@ public class WindowManagerService extends IWindowManager.Stub
            // If we are not currently running the exit animation, we need to see about starting one
            // If we are not currently running the exit animation, we need to see about starting one
            wasVisible = win.isWinVisibleLw();
            wasVisible = win.isWinVisibleLw();


            if (win.shouldKeepVisibleDeadAppWindow()) {
            if (keepVisibleDeadWindow) {
                if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                        "Not removing " + win + " because app died while it's visible");
                        "Not removing " + win + " because app died while it's visible");


@@ -4408,12 +4407,11 @@ public class WindowManagerService extends IWindowManager.Stub
            wtoken.waitingToShow = false;
            wtoken.waitingToShow = false;
            wtoken.hiddenRequested = !visible;
            wtoken.hiddenRequested = !visible;


            if (!visible && wtoken.appDied) {
            if (!visible) {
                // This app is dead while it was visible, we kept its dead window on screen.
                // If the app is dead while it was visible, we kept its dead window on screen.
                // Now that the app is going invisible, we can remove it. It will be restarted
                // Now that the app is going invisible, we can remove it. It will be restarted
                // if made visible again.
                // if made visible again.
                wtoken.appDied = false;
                wtoken.removeAllDeadWindows();
                wtoken.removeAllWindows();
            } else if (visible) {
            } else if (visible) {
                if (!mAppTransition.isTransitionSet() && mAppTransition.isReady()) {
                if (!mAppTransition.isTransitionSet() && mAppTransition.isReady()) {
                    // Add the app mOpeningApps if transition is unset but ready. This means
                    // Add the app mOpeningApps if transition is unset but ready. This means
+3 −7
Original line number Original line Diff line number Diff line
@@ -1740,10 +1740,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                    WindowState win = mService.windowForClientLocked(mSession, mClient, false);
                    WindowState win = mService.windowForClientLocked(mSession, mClient, false);
                    Slog.i(TAG, "WIN DEATH: " + win);
                    Slog.i(TAG, "WIN DEATH: " + win);
                    if (win != null) {
                    if (win != null) {
                        if (win.mAppToken != null && !win.mAppToken.clientHidden) {
                        mService.removeWindowLocked(win, shouldKeepVisibleDeadAppWindow());
                            win.mAppToken.appDied = true;
                        }
                        mService.removeWindowLocked(win);
                        if (win.mAttrs.type == TYPE_DOCK_DIVIDER) {
                        if (win.mAttrs.type == TYPE_DOCK_DIVIDER) {
                            // The owner of the docked divider died :( We reset the docked stack,
                            // The owner of the docked divider died :( We reset the docked stack,
                            // just in case they have the divider at an unstable position. Better
                            // just in case they have the divider at an unstable position. Better
@@ -1761,8 +1758,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
                    }
                    }
                }
                }
            } catch (IllegalArgumentException ex) {
            } catch (IllegalArgumentException ex) {
                // This will happen if the window has already been
                // This will happen if the window has already been removed.
                // removed.
            }
            }
        }
        }
    }
    }
@@ -1773,7 +1769,7 @@ final class WindowState implements WindowManagerPolicy.WindowState {
     * interacts with it.
     * interacts with it.
     */
     */
    boolean shouldKeepVisibleDeadAppWindow() {
    boolean shouldKeepVisibleDeadAppWindow() {
        if (!isWinVisibleLw() || mAppToken == null || !mAppToken.appDied) {
        if (!isWinVisibleLw() || mAppToken == null || mAppToken.clientHidden) {
            // Not a visible app window or the app isn't dead.
            // Not a visible app window or the app isn't dead.
            return false;
            return false;
        }
        }