Loading services/core/java/com/android/server/wm/AppWindowToken.java +106 −179 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/wm/InputMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { WindowState windowState = (WindowState) inputWindowHandle.windowState; if (windowState != null) { Slog.i(TAG_WM, "WINDOW DIED " + windowState); mService.removeWindowLocked(windowState); windowState.removeIfPossible(); } } } Loading services/core/java/com/android/server/wm/WindowManagerService.java +8 −12 Original line number Diff line number Diff line Loading @@ -1269,12 +1269,12 @@ public class WindowManagerService extends IWindowManager.Stub moveInputMethodDialogsLocked(pos + 1); return; } win.mToken.addWindowToList(win); win.mToken.addWindow(win); moveInputMethodDialogsLocked(pos); } private void reAddWindowToListInOrderLocked(WindowState win) { win.mToken.addWindowToList(win); win.mToken.addWindow(win); // This is a hack to get all of the child windows added as well at the right position. Child // windows should be rare and this case should be rare, so it shouldn't be that big a deal. WindowList windows = win.getWindowList(); Loading @@ -1283,7 +1283,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG_WM, "ReAdd removing from " + wpos + ": " + win); windows.remove(wpos); mWindowsChanged = true; win.reAddWindowLocked(wpos); win.reAddWindow(wpos); } } Loading Loading @@ -1325,7 +1325,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, "Adding " + N + " dialogs at pos=" + pos); for (int i=0; i<N; i++) { WindowState win = dialogs.get(i); pos = win.reAddWindowLocked(pos); pos = win.reAddWindow(pos); } if (DEBUG_INPUT_METHOD) { Slog.v(TAG_WM, "Final window list:"); Loading Loading @@ -1404,7 +1404,7 @@ public class WindowManagerService extends IWindowManager.Stub Slog.v(TAG_WM, "List after removing with new pos " + imPos + ":"); logWindowList(windows, " "); } imWin.reAddWindowLocked(imPos); imWin.reAddWindow(imPos); if (DEBUG_INPUT_METHOD) { Slog.v(TAG_WM, "List after moving IM to " + imPos + ":"); logWindowList(windows, " "); Loading Loading @@ -1679,11 +1679,11 @@ public class WindowManagerService extends IWindowManager.Stub imMayMove = false; } else if (type == TYPE_INPUT_METHOD_DIALOG) { mInputMethodDialogs.add(win); win.mToken.addWindowToList(win); win.mToken.addWindow(win); moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked(true)); imMayMove = false; } else { win.mToken.addWindowToList(win); win.mToken.addWindow(win); if (type == TYPE_WALLPAPER) { mWallpaperControllerLocked.clearLastWallpaperTimeoutTime(); displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; Loading Loading @@ -1878,14 +1878,10 @@ public class WindowManagerService extends IWindowManager.Stub if (win == null) { return; } removeWindowLocked(win); win.removeIfPossible(); } } void removeWindowLocked(WindowState win) { win.removeIfPossible(false /*keepVisibleDeadWindow*/); } /** * Performs some centralized bookkeeping clean-up on the window that is being removed. * NOTE: Should only be called from {@link WindowState#remove()} Loading services/core/java/com/android/server/wm/WindowState.java +6 −2 Original line number Diff line number Diff line Loading @@ -1486,6 +1486,10 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS mService.postWindowRemoveCleanupLocked(this); } void removeIfPossible() { removeIfPossible(false /*keepVisibleDeadWindow*/); } void removeIfPossible(boolean keepVisibleDeadWindow) { mWindowRemovalAllowed = true; if (DEBUG_ADD_REMOVE) Slog.v(TAG, Loading Loading @@ -1949,7 +1953,7 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS } } else if (mHasSurface) { Slog.e(TAG, "!!! LEAK !!! Window removed but surface still valid."); mService.removeWindowLocked(WindowState.this); WindowState.this.removeIfPossible(); } } } catch (IllegalArgumentException ex) { Loading Loading @@ -3213,7 +3217,7 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS // TODO: come-up with a better name for this method that represents what it does. // Or, it is probably not going to matter anyways if we are successful in getting rid of // the WindowList concept. int reAddWindowLocked(int index) { int reAddWindow(int index) { final WindowList windows = getWindowList(); // Adding child windows relies on child windows being ordered by mSubLayer using // {@link #sWindowSubLayerComparator}. Loading services/core/java/com/android/server/wm/WindowToken.java +16 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import android.annotation.CallSuper; import android.os.Bundle; import android.os.Debug; import android.os.IBinder; Loading Loading @@ -95,10 +96,16 @@ class WindowToken { } void removeAllWindows() { for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { for (int winNdx = windows.size() - 1; winNdx >= 0; // WindowState#removeIfPossible() at bottom of loop may remove multiple entries from // allAppWindows if the window to be removed has child windows. It also may not // remove any windows from allAppWindows at all if win is exiting and currently // animating away. This ensures that winNdx is monotonically decreasing and never // beyond allAppWindows bounds. winNdx = Math.min(winNdx - 1, windows.size() - 1)) { WindowState win = windows.get(winNdx); if (DEBUG_WINDOW_MOVEMENT) Slog.w(TAG_WM, "removeAllWindows: removing win=" + win); win.mService.removeWindowLocked(win); win.removeIfPossible(); } windows.clear(); } Loading Loading @@ -157,6 +164,9 @@ class WindowToken { if (animLayer > highestAnimLayer) { highestAnimLayer = animLayer; } if (w == mService.mInputMethodTarget && !mService.mInputMethodTargetWaitingAnim) { mService.mLayersController.setInputMethodAnimLayerAdjustment(adj); } } return highestAnimLayer; } Loading Loading @@ -258,8 +268,7 @@ class WindowToken { } } // TODO: Rename to addWindow when conflict with AppWindowToken is resolved. The call below. void addWindowToList(final WindowState win) { void addWindow(final WindowState win) { if (DEBUG_FOCUS) Slog.d(TAG_WM, "addWindow: win=" + win + " Callers=" + Debug.getCallers(5)); if (!win.isChildWindow()) { Loading @@ -276,11 +285,6 @@ class WindowToken { } else { addChildWindow(win); } final AppWindowToken appToken = win.mAppToken; if (appToken != null) { appToken.addWindow(win); } } private int addAppWindow(final WindowState win) { Loading Loading @@ -452,7 +456,7 @@ class WindowToken { for (int i = 0; i < count; i++) { final WindowState win = windows.get(i); if (win.isChildWindow()) { // The WindowState.reAddWindowLocked below already takes care of re-adding the // The WindowState.reAddWindow below already takes care of re-adding the // child windows for any parent window in this token. This is a side effect of // ensuring child windows are in the same WindowToken as their parent window. // Loading @@ -464,7 +468,7 @@ class WindowToken { final DisplayContent winDisplayContent = win.getDisplayContent(); if (winDisplayContent == displayContent || winDisplayContent == null) { win.mDisplayContent = displayContent; index = win.reAddWindowLocked(index); index = win.reAddWindow(index); } } return index; Loading Loading @@ -496,6 +500,7 @@ class WindowToken { return null; } @CallSuper void removeWindow(WindowState win) { windows.remove(win); } Loading Loading
services/core/java/com/android/server/wm/AppWindowToken.java +106 −179 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/wm/InputMonitor.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { WindowState windowState = (WindowState) inputWindowHandle.windowState; if (windowState != null) { Slog.i(TAG_WM, "WINDOW DIED " + windowState); mService.removeWindowLocked(windowState); windowState.removeIfPossible(); } } } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +8 −12 Original line number Diff line number Diff line Loading @@ -1269,12 +1269,12 @@ public class WindowManagerService extends IWindowManager.Stub moveInputMethodDialogsLocked(pos + 1); return; } win.mToken.addWindowToList(win); win.mToken.addWindow(win); moveInputMethodDialogsLocked(pos); } private void reAddWindowToListInOrderLocked(WindowState win) { win.mToken.addWindowToList(win); win.mToken.addWindow(win); // This is a hack to get all of the child windows added as well at the right position. Child // windows should be rare and this case should be rare, so it shouldn't be that big a deal. WindowList windows = win.getWindowList(); Loading @@ -1283,7 +1283,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_WINDOW_MOVEMENT) Slog.v(TAG_WM, "ReAdd removing from " + wpos + ": " + win); windows.remove(wpos); mWindowsChanged = true; win.reAddWindowLocked(wpos); win.reAddWindow(wpos); } } Loading Loading @@ -1325,7 +1325,7 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_INPUT_METHOD) Slog.v(TAG_WM, "Adding " + N + " dialogs at pos=" + pos); for (int i=0; i<N; i++) { WindowState win = dialogs.get(i); pos = win.reAddWindowLocked(pos); pos = win.reAddWindow(pos); } if (DEBUG_INPUT_METHOD) { Slog.v(TAG_WM, "Final window list:"); Loading Loading @@ -1404,7 +1404,7 @@ public class WindowManagerService extends IWindowManager.Stub Slog.v(TAG_WM, "List after removing with new pos " + imPos + ":"); logWindowList(windows, " "); } imWin.reAddWindowLocked(imPos); imWin.reAddWindow(imPos); if (DEBUG_INPUT_METHOD) { Slog.v(TAG_WM, "List after moving IM to " + imPos + ":"); logWindowList(windows, " "); Loading Loading @@ -1679,11 +1679,11 @@ public class WindowManagerService extends IWindowManager.Stub imMayMove = false; } else if (type == TYPE_INPUT_METHOD_DIALOG) { mInputMethodDialogs.add(win); win.mToken.addWindowToList(win); win.mToken.addWindow(win); moveInputMethodDialogsLocked(findDesiredInputMethodWindowIndexLocked(true)); imMayMove = false; } else { win.mToken.addWindowToList(win); win.mToken.addWindow(win); if (type == TYPE_WALLPAPER) { mWallpaperControllerLocked.clearLastWallpaperTimeoutTime(); displayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER; Loading Loading @@ -1878,14 +1878,10 @@ public class WindowManagerService extends IWindowManager.Stub if (win == null) { return; } removeWindowLocked(win); win.removeIfPossible(); } } void removeWindowLocked(WindowState win) { win.removeIfPossible(false /*keepVisibleDeadWindow*/); } /** * Performs some centralized bookkeeping clean-up on the window that is being removed. * NOTE: Should only be called from {@link WindowState#remove()} Loading
services/core/java/com/android/server/wm/WindowState.java +6 −2 Original line number Diff line number Diff line Loading @@ -1486,6 +1486,10 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS mService.postWindowRemoveCleanupLocked(this); } void removeIfPossible() { removeIfPossible(false /*keepVisibleDeadWindow*/); } void removeIfPossible(boolean keepVisibleDeadWindow) { mWindowRemovalAllowed = true; if (DEBUG_ADD_REMOVE) Slog.v(TAG, Loading Loading @@ -1949,7 +1953,7 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS } } else if (mHasSurface) { Slog.e(TAG, "!!! LEAK !!! Window removed but surface still valid."); mService.removeWindowLocked(WindowState.this); WindowState.this.removeIfPossible(); } } } catch (IllegalArgumentException ex) { Loading Loading @@ -3213,7 +3217,7 @@ class WindowState extends WindowContainer implements WindowManagerPolicy.WindowS // TODO: come-up with a better name for this method that represents what it does. // Or, it is probably not going to matter anyways if we are successful in getting rid of // the WindowList concept. int reAddWindowLocked(int index) { int reAddWindow(int index) { final WindowList windows = getWindowList(); // Adding child windows relies on child windows being ordered by mSubLayer using // {@link #sWindowSubLayerComparator}. Loading
services/core/java/com/android/server/wm/WindowToken.java +16 −11 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.wm; import android.annotation.CallSuper; import android.os.Bundle; import android.os.Debug; import android.os.IBinder; Loading Loading @@ -95,10 +96,16 @@ class WindowToken { } void removeAllWindows() { for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) { for (int winNdx = windows.size() - 1; winNdx >= 0; // WindowState#removeIfPossible() at bottom of loop may remove multiple entries from // allAppWindows if the window to be removed has child windows. It also may not // remove any windows from allAppWindows at all if win is exiting and currently // animating away. This ensures that winNdx is monotonically decreasing and never // beyond allAppWindows bounds. winNdx = Math.min(winNdx - 1, windows.size() - 1)) { WindowState win = windows.get(winNdx); if (DEBUG_WINDOW_MOVEMENT) Slog.w(TAG_WM, "removeAllWindows: removing win=" + win); win.mService.removeWindowLocked(win); win.removeIfPossible(); } windows.clear(); } Loading Loading @@ -157,6 +164,9 @@ class WindowToken { if (animLayer > highestAnimLayer) { highestAnimLayer = animLayer; } if (w == mService.mInputMethodTarget && !mService.mInputMethodTargetWaitingAnim) { mService.mLayersController.setInputMethodAnimLayerAdjustment(adj); } } return highestAnimLayer; } Loading Loading @@ -258,8 +268,7 @@ class WindowToken { } } // TODO: Rename to addWindow when conflict with AppWindowToken is resolved. The call below. void addWindowToList(final WindowState win) { void addWindow(final WindowState win) { if (DEBUG_FOCUS) Slog.d(TAG_WM, "addWindow: win=" + win + " Callers=" + Debug.getCallers(5)); if (!win.isChildWindow()) { Loading @@ -276,11 +285,6 @@ class WindowToken { } else { addChildWindow(win); } final AppWindowToken appToken = win.mAppToken; if (appToken != null) { appToken.addWindow(win); } } private int addAppWindow(final WindowState win) { Loading Loading @@ -452,7 +456,7 @@ class WindowToken { for (int i = 0; i < count; i++) { final WindowState win = windows.get(i); if (win.isChildWindow()) { // The WindowState.reAddWindowLocked below already takes care of re-adding the // The WindowState.reAddWindow below already takes care of re-adding the // child windows for any parent window in this token. This is a side effect of // ensuring child windows are in the same WindowToken as their parent window. // Loading @@ -464,7 +468,7 @@ class WindowToken { final DisplayContent winDisplayContent = win.getDisplayContent(); if (winDisplayContent == displayContent || winDisplayContent == null) { win.mDisplayContent = displayContent; index = win.reAddWindowLocked(index); index = win.reAddWindow(index); } } return index; Loading Loading @@ -496,6 +500,7 @@ class WindowToken { return null; } @CallSuper void removeWindow(WindowState win) { windows.remove(win); } Loading