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

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

Merge "Clean up use of DisplayContent from WindowState."

parents 047f5a7b b0f3b836
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
@@ -332,7 +333,7 @@ public class AppWindowAnimator {
    }

    // This must be called while inside a transaction.
    boolean stepAnimationLocked(long currentTime, final int displayId) {
    boolean stepAnimationLocked(long currentTime) {
        if (mService.okToDisplay()) {
            // We will run animations as long as the display isn't frozen.

@@ -383,8 +384,7 @@ public class AppWindowAnimator {
            return false;
        }

        mAppToken.setAppLayoutChanges(
                WindowManagerPolicy.FINISH_LAYOUT_REDO_ANIM, "AppWindowToken", displayId);
        mAppToken.setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "AppWindowToken");

        clearAnimation();
        animating = false;
+21 −34
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                final WindowState window = findMainWindow();
                //TODO (multidisplay): Magnification is supported only for the default display.
                if (window != null && accessibilityController != null
                        && window.getDisplayId() == DEFAULT_DISPLAY) {
                        && getDisplayContent().getDisplayId() == DEFAULT_DISPLAY) {
                    accessibilityController.onAppWindowTransitionLocked(window, transit);
                }
                changed = true;
@@ -418,22 +418,15 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
     * surfaces that's eligible, if the app is already stopped.
     */
    private void destroySurfaces(boolean cleanupOnResume) {
        final ArrayList<DisplayContent> displayList = new ArrayList();
        boolean destroyedSomething = false;
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            final WindowState win = mChildren.get(i);
            final boolean destroyed = win.destroySurface(cleanupOnResume, mAppStopped);

            if (destroyed) {
                final DisplayContent displayContent = win.getDisplayContent();
                if (displayContent != null && !displayList.contains(displayContent)) {
                    displayList.add(displayContent);
                }
            }
            destroyedSomething |= win.destroySurface(cleanupOnResume, mAppStopped);
        }
        for (int i = 0; i < displayList.size(); i++) {
            final DisplayContent displayContent = displayList.get(i);
            mService.mLayersController.assignLayersLocked(displayContent.getWindowList());
            displayContent.setLayoutNeeded();
        if (destroyedSomething) {
            final DisplayContent dc = getDisplayContent();
            mService.mLayersController.assignLayersLocked(dc.getWindowList());
            dc.setLayoutNeeded();
        }
    }

@@ -700,7 +693,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
    }

    boolean waitingForReplacement() {
    private boolean waitingForReplacement() {
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            final WindowState candidate = mChildren.get(i);
            if (candidate.waitingForReplacement()) {
@@ -816,17 +809,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
    }

    void setAppLayoutChanges(int changes, String reason, int displayId) {
        final WindowAnimator windowAnimator = mAppAnimator.mAnimator;
        for (int i = mChildren.size() - 1; i >= 0; i--) {
            // Child windows will be on the same display as their parents.
            if (displayId == (mChildren.get(i)).getDisplayId()) {
                windowAnimator.setPendingLayoutChanges(displayId, changes);
    void setAppLayoutChanges(int changes, String reason) {
        if (!mChildren.isEmpty()) {
            final DisplayContent dc = getDisplayContent();
            dc.pendingLayoutChanges |= changes;
            if (DEBUG_LAYOUT_REPEATS) {
                    mService.mWindowPlacerLocked.debugLayoutRepeats(
                            reason, windowAnimator.getPendingLayoutChanges(displayId));
                }
                break;
                mService.mWindowPlacerLocked.debugLayoutRepeats(reason, dc.pendingLayoutChanges);
            }
        }
    }
@@ -931,7 +919,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree

            if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE || DEBUG_STARTING_WINDOW) Slog.v(TAG_WM,
                    "Removing starting window: " + tStartingWindow);
            tStartingWindow.getWindowList().remove(tStartingWindow);
            getDisplayContent().getWindowList().remove(tStartingWindow);
            mService.mWindowsChanged = true;
            if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM,
                    "Removing starting " + tStartingWindow + " from " + fromToken);
@@ -1028,7 +1016,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    }

    @Override
    void checkAppWindowsReadyToShow(int displayId) {
    void checkAppWindowsReadyToShow() {
        if (allDrawn == mAppAnimator.allDrawn) {
            return;
        }
@@ -1047,9 +1035,9 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                    + " numInteresting=" + mNumInterestingWindows + " numDrawn=" + mNumDrawnWindows);
            // This will set mOrientationChangeComplete and cause a pass through layout.
            setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
                    "checkAppWindowsReadyToShow: freezingScreen", displayId);
                    "checkAppWindowsReadyToShow: freezingScreen");
        } else {
            setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow", displayId);
            setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow");

            // We can now show all of the drawn windows!
            if (!mService.mOpeningApps.contains(this)) {
@@ -1170,16 +1158,15 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    }

    @Override
    void stepAppWindowsAnimation(long currentTime, int displayId) {
    void stepAppWindowsAnimation(long currentTime) {
        mAppAnimator.wasAnimating = mAppAnimator.animating;
        if (mAppAnimator.stepAnimationLocked(currentTime, displayId)) {
        if (mAppAnimator.stepAnimationLocked(currentTime)) {
            mAppAnimator.animating = true;
            mService.mAnimator.setAnimating(true);
            mService.mAnimator.mAppWindowAnimating = true;
        } else if (mAppAnimator.wasAnimating) {
            // stopped animating, do one more pass through the layout
            setAppLayoutChanges(
                    FINISH_LAYOUT_REDO_WALLPAPER, "appToken " + this + " done", displayId);
            setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER, "appToken " + this + " done");
            if (DEBUG_ANIM) Slog.v(TAG, "updateWindowsApps...: done animating " + this);
        }
    }
+7 −14
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_WINDOW_MOVEME
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.H.WINDOW_HIDE_TIMEOUT;
import static com.android.server.wm.WindowManagerService.dipToPixel;
import static com.android.server.wm.WindowManagerService.localLOGV;
import static com.android.server.wm.WindowState.RESIZE_HANDLE_WIDTH_IN_DP;
@@ -63,6 +64,7 @@ import android.graphics.Region;
import android.graphics.Region.Op;
import android.hardware.display.DisplayManagerInternal;
import android.os.Debug;
import android.os.Handler;
import android.os.IBinder;
import android.util.DisplayMetrics;
import android.util.Slog;
@@ -305,14 +307,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        }
    }

    void checkAppWindowsReadyToShow() {
        super.checkAppWindowsReadyToShow(mDisplayId);
    }

    void stepAppWindowsAnimation(long currentTime) {
        super.stepAppWindowsAnimation(currentTime, mDisplayId);
    }

    @Override
    boolean fillsParent() {
        return true;
@@ -885,15 +879,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            return;
        }
        final int lostFocusUid = oldFocus.mOwnerUid;
        WindowList windows = getWindowList();
        final WindowList windows = getWindowList();
        final int windowCount = windows.size();
        final Handler handler = mService.mH;
        for (int i = 0; i < windowCount; i++) {
            WindowState window = windows.get(i);
            final WindowState window = windows.get(i);
            if (window.mAttrs.type == TYPE_TOAST && window.mOwnerUid == lostFocusUid) {
                if (!mService.mH.hasMessages(WindowManagerService.H.WINDOW_HIDE_TIMEOUT, window)) {
                    mService.mH.sendMessageDelayed(
                            mService.mH.obtainMessage(
                                    WindowManagerService.H.WINDOW_HIDE_TIMEOUT, window),
                if (!handler.hasMessages(WINDOW_HIDE_TIMEOUT, window)) {
                    handler.sendMessageDelayed(handler.obtainMessage(WINDOW_HIDE_TIMEOUT, window),
                            window.mAttrs.hideTimeoutMilliseconds);
                }
            }
+4 −6
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import static android.view.WindowManager.INPUT_CONSUMER_PIP;
import static android.view.WindowManager.INPUT_CONSUMER_WALLPAPER;
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
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.PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE;
import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
@@ -762,19 +763,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {

                final boolean hasFocus = child == inputFocus;
                final boolean isVisible = child.isVisibleLw();
                if ((privateFlags
                        & WindowManager.LayoutParams.PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS)
                        != 0) {
                if ((privateFlags & PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS) != 0) {
                    disableWallpaperTouchEvents = true;
                }
                final boolean hasWallpaper = wallpaperController.isWallpaperTarget(child)
                        && (privateFlags & WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD) == 0
                        && (privateFlags & PRIVATE_FLAG_KEYGUARD) == 0
                        && !disableWallpaperTouchEvents;
                final boolean onDefaultDisplay = (child.getDisplayId() == Display.DEFAULT_DISPLAY);

                // 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 && onDefaultDisplay) {
                if (inDrag && isVisible && dc.isDefaultDisplay) {
                    mService.mDragState.sendDragStartedIfNeededLw(child);
                }

+6 −6
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;
import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_DOCKED_DIVIDER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_MOVEMENT;
@@ -1429,8 +1430,8 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        return super.checkCompleteDeferredRemoval();
    }

    void stepAppWindowsAnimation(long currentTime, int displayId) {
        super.stepAppWindowsAnimation(currentTime, displayId);
    void stepAppWindowsAnimation(long currentTime) {
        super.stepAppWindowsAnimation(currentTime);

        // TODO: Why aren't we just using the loop above for this? mAppAnimator.animating isn't set
        // below but is set in the loop above. See if it really matters...
@@ -1438,14 +1439,13 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        for (int i = 0; i < exitingCount; i++) {
            final AppWindowAnimator appAnimator = mExitingAppTokens.get(i).mAppAnimator;
            appAnimator.wasAnimating = appAnimator.animating;
            if (appAnimator.stepAnimationLocked(currentTime, displayId)) {
            if (appAnimator.stepAnimationLocked(currentTime)) {
                mService.mAnimator.setAnimating(true);
                mService.mAnimator.mAppWindowAnimating = true;
            } else if (appAnimator.wasAnimating) {
                // stopped animating, do one more pass through the layout
                appAnimator.mAppToken.setAppLayoutChanges(
                        WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER,
                        "exiting appToken " + appAnimator.mAppToken + " done", displayId);
                appAnimator.mAppToken.setAppLayoutChanges(FINISH_LAYOUT_REDO_WALLPAPER,
                        "exiting appToken " + appAnimator.mAppToken + " done");
                if (DEBUG_ANIM) Slog.v(TAG_WM,
                        "updateWindowsApps...: done animating exiting " + appAnimator.mAppToken);
            }
Loading