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

Commit 9f25beee authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Made AppWindowToken.allAppWindows private

Pre-clean-up before switching class to using WindowContainer.

Bug: 30060889
Change-Id: Ic3d47d47b922668eeb70988ce883267b46ca9d72
parent 89142e9c
Loading
Loading
Loading
Loading
+4 −22
Original line number Diff line number Diff line
@@ -157,11 +157,9 @@ public class AppWindowAnimator {
        }

        // Since we are finally starting our animation, we don't need the logic anymore to prevent
        // the app from showing again if we just moved between stacks. See
        // {@link WindowState#notifyMovedInStack}.
        for (int i = mAppToken.allAppWindows.size() - 1; i >= 0; i--) {
            mAppToken.allAppWindows.get(i).resetJustMovedInStack();
        }
        // the app from showing again if we just moved between stacks.
        // See {@link WindowState#notifyMovedInStack}.
        mAppToken.resetJustMovedInStack();
    }

    public void setDummyAnimation() {
@@ -234,23 +232,7 @@ public class AppWindowAnimator {
    }

    void updateLayers() {
        final int windowCount = mAppToken.allAppWindows.size();
        final int adj = animLayerAdjustment;
        thumbnailLayer = -1;
        final WallpaperController wallpaperController = mService.mWallpaperControllerLocked;
        for (int i = 0; i < windowCount; i++) {
            final WindowState w = mAppToken.allAppWindows.get(i);
            final WindowStateAnimator winAnimator = w.mWinAnimator;
            winAnimator.mAnimLayer = w.mLayer + adj;
            if (winAnimator.mAnimLayer > thumbnailLayer) {
                thumbnailLayer = winAnimator.mAnimLayer;
            }
            if (DEBUG_LAYERS) Slog.v(TAG, "Updating layer " + w + ": " + winAnimator.mAnimLayer);
            if (w == mService.mInputMethodTarget && !mService.mInputMethodTargetWaitingAnim) {
                mService.mLayersController.setInputMethodAnimLayerAdjustment(adj);
            }
            wallpaperController.setAnimLayerAdjustment(w, adj);
        }
        thumbnailLayer = mAppToken.adjustAnimLayer(animLayerAdjustment);
    }

    private void stepThumbnailAnimation(long currentTime) {
+537 −3

File changed.

Preview size limit exceeded, changes collapsed.

+38 −65
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Slog;
import android.view.DisplayInfo;
import android.view.Surface;

import android.view.SurfaceControl;
import com.android.server.EventLogTags;

import java.io.PrintWriter;
@@ -178,11 +179,7 @@ class Task implements DimLayer.DimLayerUser {
        resizeLocked(bounds, config, false /* force */);

        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                win.notifyMovedInStack();
            }
            mAppTokens.get(activityNdx).notifyMovedInStack();
        }
    }

@@ -478,11 +475,7 @@ class Task implements DimLayer.DimLayerUser {

    void resetDragResizingChangeReported() {
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                win.resetDragResizingChangeReported();
            }
            mAppTokens.get(activityNdx).resetDragResizingChangeReported();
        }
    }

@@ -498,15 +491,15 @@ class Task implements DimLayer.DimLayerUser {
     * Adds all of the tasks windows to {@link WindowManagerService#mWaitingForDrawn} if drag
     * resizing state of the window has been changed.
     */
    void addWindowsWaitingForDrawnIfResizingChanged() {
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (win.isDragResizeChanged()) {
                    mService.mWaitingForDrawn.add(win);
    void setWaitingForDrawnIfResizingChanged() {
        for (int i = mAppTokens.size() - 1; i >= 0; --i) {
            mAppTokens.get(i).setWaitingForDrawnIfResizingChanged();
        }
    }

    void detachDisplay() {
        for (int i = mAppTokens.size() - 1; i >= 0; --i) {
            mAppTokens.get(i).detachDisplay();
        }
    }

@@ -546,52 +539,14 @@ class Task implements DimLayer.DimLayerUser {
    }

    void resizeWindows() {
        final ArrayList<WindowState> resizingWindows = mService.mResizingWindows;
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final AppWindowToken atoken = mAppTokens.get(activityNdx);

            // Some windows won't go through the resizing process, if they don't have a surface, so
            // destroy all saved surfaces here.
            atoken.destroySavedSurfaces();
            final ArrayList<WindowState> windows = atoken.allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (win.mHasSurface && !resizingWindows.contains(win)) {
                    if (DEBUG_RESIZE) Slog.d(TAG, "resizeWindows: Resizing " + win);
                    resizingWindows.add(win);

                    // If we are not drag resizing, force recreating of a new surface so updating
                    // the content and positioning that surface will be in sync.
                    //
                    // As we use this flag as a hint to freeze surface boundary updates,
                    // we'd like to only apply this to TYPE_BASE_APPLICATION,
                    // windows of TYPE_APPLICATION like dialogs, could appear
                    // to not be drag resizing while they resize, but we'd
                    // still like to manipulate their frame to update crop, etc...
                    //
                    // Anyway we don't need to synchronize position and content updates for these
                    // windows since they aren't at the base layer and could be moved around anyway.
                    if (!win.computeDragResizing() && win.mAttrs.type == TYPE_BASE_APPLICATION &&
                            !mStack.getBoundsAnimating() && !win.isGoneForLayoutLw() &&
                            !inPinnedWorkspace()) {
                        win.setResizedWhileNotDragResizing(true);
                    }
                }
                if (win.isGoneForLayoutLw()) {
                    win.mResizedWhileGone = true;
                }
            }
            mAppTokens.get(activityNdx).resizeWindows();
        }
    }

    void moveWindows() {
        for (int activityNdx = mAppTokens.size() - 1; activityNdx >= 0; --activityNdx) {
            final ArrayList<WindowState> windows = mAppTokens.get(activityNdx).allAppWindows;
            for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                final WindowState win = windows.get(winNdx);
                if (DEBUG_RESIZE) Slog.d(TAG, "moveWindows: Moving " + win);
                win.mMovedByResize = true;
            }
        for (int i = mAppTokens.size() - 1; i >= 0; --i) {
            mAppTokens.get(i).moveWindows();
        }
    }

@@ -621,13 +576,10 @@ class Task implements DimLayer.DimLayerUser {
    boolean isVisibleForUser() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            final AppWindowToken appToken = mAppTokens.get(i);
            for (int j = appToken.allAppWindows.size() - 1; j >= 0; j--) {
                WindowState window = appToken.allAppWindows.get(j);
                if (!window.isHiddenFromUserLocked()) {
            if (appToken.isVisibleForUser()) {
                return true;
            }
        }
        }
        return false;
    }

@@ -697,6 +649,27 @@ class Task implements DimLayer.DimLayerUser {
        return mStack.getDisplayContent().getDisplayInfo();
    }

    void forceWindowsScaleable(boolean force) {
        SurfaceControl.openTransaction();
        try {
            for (int i = mAppTokens.size() - 1; i >= 0; i--) {
                mAppTokens.get(i).forceWindowsScaleableInTransaction(force);
            }
        } finally {
            SurfaceControl.closeTransaction();
        }
    }

    boolean isAnimating() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            final AppWindowToken aToken = mAppTokens.get(i);
            if (aToken.isAnimating()) {
                return true;
            }
        }
        return false;
    }

    @Override
    public String toString() {
        return "{taskId=" + mTaskId + " appTokens=" + mAppTokens + " mdr=" + mDeferRemoval + "}";
+8 −47
Original line number Diff line number Diff line
@@ -477,17 +477,11 @@ public class TaskStack implements DimLayer.DimLayerUser,

    boolean isAnimating() {
        for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
            final ArrayList<AppWindowToken> activities = mTasks.get(taskNdx).mAppTokens;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ArrayList<WindowState> windows = activities.get(activityNdx).allAppWindows;
                for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                    final WindowStateAnimator winAnimator = windows.get(winNdx).mWinAnimator;
                    if (winAnimator.isAnimationSet() || winAnimator.mWin.mAnimatingExit) {
            final Task task = mTasks.get(taskNdx);
            if (task.isAnimating()) {
                return true;
            }
        }
            }
        }
        return false;
    }

@@ -532,12 +526,11 @@ public class TaskStack implements DimLayer.DimLayerUser,
        }

        if (StackId.windowsAreScaleable(mStackId)) {
            // We force windows out of SCALING_MODE_FREEZE
            // so that we can continue to animate them
            // We force windows out of SCALING_MODE_FREEZE so that we can continue to animate them
            // while a resize is pending.
            forceWindowsScaleable(task, true);
            task.forceWindowsScaleable(true);
        } else {
            forceWindowsScaleable(task, false);
            task.forceWindowsScaleable(false);
        }
        EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, task.mTaskId, toTop ? 1 : 0, position);
    }
@@ -773,21 +766,8 @@ public class TaskStack implements DimLayer.DimLayerUser,
    void detachDisplay() {
        EventLog.writeEvent(EventLogTags.WM_STACK_REMOVED, mStackId);

        boolean doAnotherLayoutPass = false;
        for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) {
            final AppTokenList appWindowTokens = mTasks.get(taskNdx).mAppTokens;
            for (int appNdx = appWindowTokens.size() - 1; appNdx >= 0; --appNdx) {
                final WindowList appWindows = appWindowTokens.get(appNdx).allAppWindows;
                for (int winNdx = appWindows.size() - 1; winNdx >= 0; --winNdx) {
                    // We are in the middle of changing the state of displays/stacks/tasks. We need
                    // to finish that, before we let layout interfere with it.
                    mService.removeWindowLocked(appWindows.get(winNdx));
                    doAnotherLayoutPass = true;
                }
            }
        }
        if (doAnotherLayoutPass) {
            mService.mWindowPlacerLocked.requestTraversal();
            mTasks.get(taskNdx).detachDisplay();
        }

        close();
@@ -922,7 +902,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
            final Task task = mTasks.get(j);
            if (task.isVisibleForUser()) {
                task.setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER);
                task.addWindowsWaitingForDrawnIfResizingChanged();
                task.setWaitingForDrawnIfResizingChanged();
            }
        }
    }
@@ -1290,25 +1270,6 @@ public class TaskStack implements DimLayer.DimLayerUser,
        return true;
    }

    void forceWindowsScaleable(Task task, boolean force) {
        SurfaceControl.openTransaction();
        try {
            final ArrayList<AppWindowToken> activities = task.mAppTokens;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ArrayList<WindowState> windows = activities.get(activityNdx).allAppWindows;
                for (int winNdx = windows.size() - 1; winNdx >= 0; --winNdx) {
                    final WindowStateAnimator winAnimator = windows.get(winNdx).mWinAnimator;
                    if (winAnimator == null || !winAnimator.hasSurface()) {
                        continue;
                    }
                    winAnimator.mSurfaceController.forceScaleableInTransaction(force);
                }
            }
        } finally {
            SurfaceControl.closeTransaction();
        }
    }

    @Override  // AnimatesBounds
    public void onAnimationStart() {
        synchronized (mService.mWindowMap) {
+11 −19
Original line number Diff line number Diff line
@@ -624,7 +624,7 @@ public class WindowAnimator {
                        // windows shown...  what to do, what to do?
                        if (appAnimator.freezingScreen) {
                            appAnimator.showAllWindowsLocked();
                            mService.unsetAppFreezingScreenLocked(wtoken, false, true);
                            wtoken.stopFreezingScreen(false, true);
                            if (DEBUG_ORIENTATION) Slog.i(TAG,
                                    "Setting mOrientationChangeComplete=true because wtoken "
                                    + wtoken + " numInteresting=" + wtoken.numInterestingWindows
@@ -800,21 +800,23 @@ public class WindowAnimator {
    }

    private void removeReplacedWindowsLocked() {
        if (SHOW_TRANSACTIONS) Slog.i(
                TAG, ">>> OPEN TRANSACTION removeReplacedWindows");
        if (SHOW_TRANSACTIONS) Slog.i(TAG, ">>> OPEN TRANSACTION removeReplacedWindows");
        SurfaceControl.openTransaction();
        try {
            for (int i = mService.mDisplayContents.size() - 1; i >= 0; i--) {
                DisplayContent display = mService.mDisplayContents.valueAt(i);
                final WindowList windows = mService.getWindowListLocked(display.getDisplayId());
                for (int j = windows.size() - 1; j >= 0; j--) {
                    windows.get(j).maybeRemoveReplacedWindow();
                    final WindowState win = windows.get(j);
                    final AppWindowToken aToken = win.mAppToken;
                    if (aToken != null) {
                        aToken.removeReplacedWindowIfNeeded(win);
                    }
                }
            }
        } finally {
            SurfaceControl.closeTransaction();
            if (SHOW_TRANSACTIONS) Slog.i(
                    TAG, "<<< CLOSE TRANSACTION removeReplacedWindows");
            if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION removeReplacedWindows");
        }
        mRemoveReplacedWindows = false;
    }
@@ -903,19 +905,9 @@ public class WindowAnimator {
        }
    }

    void setAppLayoutChanges(final AppWindowAnimator appAnimator, final int changes, String reason,
            final int displayId) {
        WindowList windows = appAnimator.mAppToken.allAppWindows;
        for (int i = windows.size() - 1; i >= 0; i--) {
            if (displayId == windows.get(i).getDisplayId()) {
                setPendingLayoutChanges(displayId, changes);
                if (DEBUG_LAYOUT_REPEATS) {
                    mWindowPlacerLocked.debugLayoutRepeats(reason,
                            getPendingLayoutChanges(displayId));
                }
                break;
            }
        }
    void setAppLayoutChanges(
            AppWindowAnimator appAnimator, int changes, String reason, int displayId) {
        appAnimator.mAppToken.setAppLayoutChanges(changes, reason, displayId);
    }

    private DisplayContentsAnimator getDisplayContentsAnimatorLocked(int displayId) {
Loading