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

Commit 6213caa4 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Revert "Revert "WindowList be gone!""

This reverts commit ffa5a9de.

Bug: 33098800
Bug: 33098294
Test: Existing tests pass.
Change-Id: I5803a010c5a224dd1cf452a4a7beb3a4c0a043f4
parent 3cf4b56a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -411,7 +411,7 @@ public class AppWindowAnimator {
        }
        if (mService.mInputMethodTarget != null
                && mService.mInputMethodTarget.mAppToken == mAppToken) {
            mAppToken.getDisplayContent().moveInputMethodWindowsIfNeeded(true);
            mAppToken.getDisplayContent().computeImeTarget(true /* updateImeTarget */);
        }

        if (DEBUG_ANIM) Slog.v(TAG, "Animation done in " + mAppToken
+27 −16
Original line number Diff line number Diff line
@@ -1003,10 +1003,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            tStartingWindow.mToken = this;
            tStartingWindow.mAppToken = this;

            if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
                    "Removing starting window: " + tStartingWindow);
            getDisplayContent().removeFromWindowList(tStartingWindow);
            if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
            if (DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
                    "Removing starting " + tStartingWindow + " from " + fromToken);
            fromToken.removeChild(tStartingWindow);
            fromToken.postWindowRemoveStartingWindowCleanup(tStartingWindow);
@@ -1261,18 +1258,6 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
    }

    int rebuildWindowListUnchecked(int addIndex) {
        return super.rebuildWindowList(addIndex);
    }

    @Override
    int rebuildWindowList(int addIndex) {
        if (mIsExiting && !waitingForReplacement()) {
            return addIndex;
        }
        return rebuildWindowListUnchecked(addIndex);
    }

    @Override
    boolean forAllWindows(ToBooleanFunction<WindowState> callback, boolean traverseTopToBottom) {
        // For legacy reasons we process the TaskStack.mExitingAppTokens first in DisplayContent
@@ -1334,6 +1319,32 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        mLastContainsShowWhenLockedWindow = containsShowWhenLocked;
    }

    WindowState getImeTargetBelowWindow(WindowState w) {
        final int index = mChildren.indexOf(w);
        if (index > 0) {
            final WindowState target = mChildren.get(index - 1);
            if (target.canBeImeTarget()) {
                return target;
            }
        }
        return null;
    }

    WindowState getHighestAnimLayerWindow(WindowState currentTarget) {
        WindowState candidate = null;
        for (int i = mChildren.indexOf(currentTarget); i >= 0; i--) {
            final WindowState w = mChildren.get(i);
            if (w.mRemoved) {
                continue;
            }
            if (candidate == null || w.mWinAnimator.mAnimLayer >
                    candidate.mWinAnimator.mAnimLayer) {
                candidate = w;
            }
        }
        return candidate;
    }

    @Override
    void dump(PrintWriter pw, String prefix) {
        super.dump(pw, prefix);
+501 −1253

File changed.

Preview size limit exceeded, changes collapsed.

+93 −7
Original line number Diff line number Diff line
@@ -16,10 +16,15 @@

package com.android.server.wm;

import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION;
import static android.view.WindowManager.INPUT_CONSUMER_PIP;
import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DRAG;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT;
@@ -70,6 +75,10 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
    // Array of window handles to provide to the input dispatcher.
    private InputWindowHandle[] mInputWindowHandles;
    private int mInputWindowHandleCount;
    private boolean mAddInputConsumerHandle;
    private boolean mAddPipInputConsumerHandle;
    private boolean mAddWallpaperInputConsumerHandle;
    private boolean mDisableWallpaperTouchEvents;

    // Set to true when the first input device configuration change notification
    // is received to indicate that the input devices are ready.
@@ -323,12 +332,12 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        }
    }

    public void setUpdateInputWindowsNeededLw() {
    void setUpdateInputWindowsNeededLw() {
        mUpdateInputWindowsNeeded = true;
    }

    /* Updates the cached window information provided to the input dispatcher. */
    public void updateInputWindowsLw(boolean force) {
    void updateInputWindowsLw(boolean force) {
        if (!force && !mUpdateInputWindowsNeeded) {
            return;
        }
@@ -372,15 +381,92 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
        }

        // Add all windows on the default display.
        mService.mRoot.updateInputWindows(this, mInputFocus, inDrag);
        updateInputWindows(inDrag);

        // Send windows to native code.
        mService.mInputManager.setInputWindows(mInputWindowHandles);
        if (false) Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw");
    }

    private void updateInputWindows(boolean inDrag) {

        // Clear the list in preparation for the next round.
        clearInputWindowHandlesLw();

        if (false) Slog.d(TAG_WM, "<<<<<<< EXITED updateInputWindowsLw");
        // TODO: multi-display
        final InputConsumerImpl navInputConsumer =
                getInputConsumer(INPUT_CONSUMER_NAVIGATION, DEFAULT_DISPLAY);
        final InputConsumerImpl pipInputConsumer =
                getInputConsumer(INPUT_CONSUMER_PIP, DEFAULT_DISPLAY);
        final InputConsumerImpl wallpaperInputConsumer =
                getInputConsumer(INPUT_CONSUMER_WALLPAPER, DEFAULT_DISPLAY);
        mAddInputConsumerHandle = navInputConsumer != null;
        mAddPipInputConsumerHandle = pipInputConsumer != null;
        mAddWallpaperInputConsumerHandle = wallpaperInputConsumer != null;
        final Rect pipTouchableBounds = mAddPipInputConsumerHandle ? new Rect() : null;
        mDisableWallpaperTouchEvents = false;

        final WallpaperController wallpaperController = mService.mRoot.mWallpaperController;
        mService.mRoot.forAllWindows(w -> {
            final InputChannel inputChannel = w.mInputChannel;
            final InputWindowHandle inputWindowHandle = w.mInputWindowHandle;
            if (inputChannel == null || inputWindowHandle == null || w.mRemoved
                    || w.isAdjustedForMinimizedDock()) {
                // Skip this window because it cannot possibly receive input.
                return;
            }

            if (mAddPipInputConsumerHandle
                    && w.getStackId() == PINNED_STACK_ID
                    && inputWindowHandle.layer <= pipInputConsumer.mWindowHandle.layer) {
                // Update the bounds of the Pip input consumer to match the Pinned stack
                w.getStack().getBounds(pipTouchableBounds);
                pipInputConsumer.mWindowHandle.touchableRegion.set(pipTouchableBounds);
                addInputWindowHandle(pipInputConsumer.mWindowHandle);
                mAddPipInputConsumerHandle = false;
            }

            if (mAddInputConsumerHandle
                    && inputWindowHandle.layer <= navInputConsumer.mWindowHandle.layer) {
                addInputWindowHandle(navInputConsumer.mWindowHandle);
                mAddInputConsumerHandle = false;
            }

            if (mAddWallpaperInputConsumerHandle) {
                if (w.mAttrs.type == TYPE_WALLPAPER && w.isVisibleLw()) {
                    // Add the wallpaper input consumer above the first visible wallpaper.
                    addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
                    mAddWallpaperInputConsumerHandle = false;
                }
            }

            final int flags = w.mAttrs.flags;
            final int privateFlags = w.mAttrs.privateFlags;
            final int type = w.mAttrs.type;

            final boolean hasFocus = w == mInputFocus;
            final boolean isVisible = w.isVisibleLw();
            if ((privateFlags & PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) {
                mDisableWallpaperTouchEvents = true;
            }
            final boolean hasWallpaper = wallpaperController.isWallpaperTarget(w)
                    && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0
                    && !mDisableWallpaperTouchEvents;

            // If there's a drag in progress and 'child' is a potential drop target,
            // make sure it's been told about the drag
            if (inDrag && isVisible && w.getDisplayContent().isDefaultDisplay) {
                mService.mDragState.sendDragStartedIfNeededLw(w);
            }

            addInputWindowHandle(
                    inputWindowHandle, w, flags, type, isVisible, hasFocus, hasWallpaper);
        }, true /* traverseTopToBottom */);

        if (mAddWallpaperInputConsumerHandle) {
            // No visible wallpaper found, add the wallpaper input consumer at the end.
            addInputWindowHandle(wallpaperInputConsumer.mWindowHandle);
        }

        // Send windows to native code.
        mService.mInputManager.setInputWindows(mInputWindowHandles);
    }

    /* Notifies that the input device configuration has changed. */
+3 −20
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        return false;
    }

    void getWindowsByName(WindowList output, String name) {
    void getWindowsByName(ArrayList<WindowState> output, String name) {
        int objectId = 0;
        // See if this is an object ID.
        try {
@@ -231,7 +231,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        getWindowsByName(output, name, objectId);
    }

    private void getWindowsByName(WindowList output, String name, int objectId) {
    private void getWindowsByName(ArrayList<WindowState> output, String name, int objectId) {
        forAllWindows((w) -> {
            if (name != null) {
                if (w.mAttrs.getTitle().toString().contains(name)) {
@@ -276,15 +276,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        return null;
    }

    // TODO: Users would have their own window containers under the display container?
    void switchUser() {
        final int count = mChildren.size();
        for (int i = 0; i < count; ++i) {
            final DisplayContent dc = mChildren.get(i);
            dc.switchUser();
        }
    }

    /**
     * Set new display override config and return array of ids of stacks that were changed during
     * update. If called for the default display, global configuration will also be updated.
@@ -429,14 +420,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
        return hasChanges;
    }

    void updateInputWindows(InputMonitor inputMonitor, WindowState inputFocus, boolean inDrag) {
        final int count = mChildren.size();
        for (int i = 0; i < count; ++i) {
            final DisplayContent dc = mChildren.get(i);
            dc.updateInputWindows(inputMonitor, inputFocus, inDrag);
        }
    }

    boolean reclaimSomeSurfaceMemory(WindowStateAnimator winAnimator, String operation,
            boolean secure) {
        final WindowSurfaceController surfaceController = winAnimator.mSurfaceController;
@@ -662,7 +645,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
                WindowState win = mService.mDestroySurface.get(i);
                win.mDestroying = false;
                if (mService.mInputMethodWindow == win) {
                    mService.mInputMethodWindow = null;
                    mService.setInputMethodWindowLocked(null);
                }
                if (win.getDisplayContent().mWallpaperController.isWallpaperTarget(win)) {
                    wallpaperDestroyed = true;
Loading