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

Commit 3c98926b authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Add a timeout for removing starting windows." into klp-dev

parents f079a6d0 68cc241e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    static final boolean DEBUG_USER_LEAVING = localLOGV || false;
    static final boolean DEBUG_VISBILITY = localLOGV || false;
    static final boolean DEBUG_PSS = localLOGV || false;
    static final boolean DEBUG_LOCKSCREEN = localLOGV || true;
    static final boolean DEBUG_LOCKSCREEN = localLOGV || false;
    static final boolean VALIDATE_TOKENS = true;
    static final boolean SHOW_ACTIVITY_START_TIME = true;
+41 −11
Original line number Diff line number Diff line
@@ -255,6 +255,9 @@ public class WindowManagerService extends IWindowManager.Stub
    /** Amount of time (in milliseconds) to delay before declaring a window freeze timeout. */
    static final int WINDOW_FREEZE_TIMEOUT_DURATION = 2000;

    /** Amount of time (in milliseconds) to delay before declaring a starting window leaked. */
    static final int STARTING_WINDOW_TIMEOUT_DURATION = 10000;

    /**
     * If true, the window manager will do its own custom freezing and general
     * management of the screen during rotation.
@@ -2256,6 +2259,8 @@ public class WindowManagerService extends IWindowManager.Stub
                token.appWindowToken.startingWindow = win;
                if (DEBUG_STARTING_WINDOW) Slog.v (TAG, "addWindow: " + token.appWindowToken
                        + " startingWindow=" + win);
                Message m = mH.obtainMessage(H.REMOVE_STARTING_TIMEOUT, token.appWindowToken);
                mH.sendMessageDelayed(m, STARTING_WINDOW_TIMEOUT_DURATION);
            }

            boolean imMayMove = true;
@@ -2356,6 +2361,10 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    public void removeWindowLocked(Session session, WindowState win) {
        if (win.mAttrs.type == TYPE_APPLICATION_STARTING) {
            if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "Starting window removed " + win);
            removeStartingWindowTimeout(win.mAppToken);
        }

        if (localLOGV || DEBUG_FOCUS || DEBUG_FOCUS_LIGHT && win==mCurrentFocus) Slog.v(
            TAG, "Remove " + win + " client="
@@ -2498,6 +2507,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (atoken != null) {
            if (atoken.startingWindow == win) {
                if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Nulling startingWindow " + win);
                removeStartingWindowTimeout(atoken);
                atoken.startingWindow = null;
            } else if (atoken.allAppWindows.size() == 0 && atoken.startingData != null) {
                // If this is the last window and we had requested a starting
@@ -2507,12 +2517,7 @@ public class WindowManagerService extends IWindowManager.Stub
            } else if (atoken.allAppWindows.size() == 1 && atoken.startingView != null) {
                // If this is the last window except for a starting transition
                // window, we need to get rid of the starting transition.
                if (DEBUG_STARTING_WINDOW) {
                    Slog.v(TAG, "Schedule remove starting " + token
                            + ": no more real windows");
                }
                Message m = mH.obtainMessage(H.REMOVE_STARTING, atoken);
                mH.sendMessage(m);
                scheduleRemoveStartingWindow(atoken);
            }
        }

@@ -3964,6 +3969,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) {
                            Slog.v(TAG, "Removing starting window: " + startingWindow);
                        }
                        removeStartingWindowTimeout(ttoken);
                        startingWindow.getWindowList().remove(startingWindow);
                        mWindowsChanged = true;
                        if (DEBUG_ADD_REMOVE) Slog.v(TAG,
@@ -4527,14 +4533,29 @@ public class WindowManagerService extends IWindowManager.Stub
        }
        Binder.restoreCallingIdentity(origId);

        if (startingToken != null) {
            if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Schedule remove starting "
                    + startingToken + ": app token removed");
            Message m = mH.obtainMessage(H.REMOVE_STARTING, startingToken);
            mH.sendMessage(m);
        // Will only remove if startingToken non null.
        scheduleRemoveStartingWindow(startingToken);
    }

    void removeStartingWindowTimeout(AppWindowToken wtoken) {
        if (wtoken != null) {
            if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) +
                    ": Remove starting window timeout " + wtoken + (wtoken != null ?
                    " startingWindow=" + wtoken.startingWindow : ""));
            mH.removeMessages(H.REMOVE_STARTING_TIMEOUT, wtoken);
        }
    }

    void scheduleRemoveStartingWindow(AppWindowToken wtoken) {
        if (wtoken != null && wtoken.startingWindow != null) {
            if (DEBUG_STARTING_WINDOW) Slog.v(TAG, Debug.getCallers(1) +
                    ": Schedule remove starting " + wtoken + (wtoken != null ?
                    " startingWindow=" + wtoken.startingWindow : ""));
            removeStartingWindowTimeout(wtoken);
            Message m = mH.obtainMessage(H.REMOVE_STARTING, wtoken);
            mH.sendMessage(m);
        }
    }
    private boolean tmpRemoveAppWindowsLocked(WindowToken token) {
        final int NW = token.windows.size();
        if (NW > 0) {
@@ -7053,6 +7074,8 @@ public class WindowManagerService extends IWindowManager.Stub
        public static final int TAP_OUTSIDE_STACK = 31;
        public static final int NOTIFY_ACTIVITY_DRAWN = 32;

        public static final int REMOVE_STARTING_TIMEOUT = 33;

        @Override
        public void handleMessage(Message msg) {
            if (DEBUG_WINDOW_TRACE) {
@@ -7151,6 +7174,7 @@ public class WindowManagerService extends IWindowManager.Stub
                                            "Aborted starting " + wtoken
                                            + ": removed=" + wtoken.removed
                                            + " startingData=" + wtoken.startingData);
                                    removeStartingWindowTimeout(wtoken);
                                    wtoken.startingWindow = null;
                                    wtoken.startingData = null;
                                    abort = true;
@@ -7175,6 +7199,11 @@ public class WindowManagerService extends IWindowManager.Stub
                    }
                } break;

                case REMOVE_STARTING_TIMEOUT: {
                    final AppWindowToken wtoken = (AppWindowToken)msg.obj;
                    Slog.e(TAG, "Starting window " + wtoken + " timed out");
                    // Fall through.
                }
                case REMOVE_STARTING: {
                    final AppWindowToken wtoken = (AppWindowToken)msg.obj;
                    IBinder token = null;
@@ -9676,6 +9705,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    winAnimator.mSurfaceShown = false;
                    winAnimator.mSurfaceControl = null;
                    winAnimator.mWin.mHasSurface = false;
                    scheduleRemoveStartingWindow(winAnimator.mWin.mAppToken);
                }

                try {