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

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

Merge "Switch WindowState to get display content from its window token"

parents 61189b08 360a8bce
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1184,16 +1184,16 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
    }

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

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

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -1122,13 +1122,13 @@ class DisplayContent extends WindowContainer<TaskStack> {
            AppTokenList exitingAppTokens = mChildren.get(stackNdx).mExitingAppTokens;
            int NT = exitingAppTokens.size();
            for (int j = 0; j < NT; j++) {
                i = exitingAppTokens.get(j).rebuildWindowListUnchecked(this, i);
                i = exitingAppTokens.get(j).rebuildWindowListUnchecked(i);
            }
        }

        // And add in the still active app tokens in Z order.
        for (int stackNdx = 0; stackNdx < numStacks; ++stackNdx) {
            i = mChildren.get(stackNdx).rebuildWindowList(this, i);
            i = mChildren.get(stackNdx).rebuildWindowList(i);
        }

        i -= lastBelow;
+2 −3
Original line number Diff line number Diff line
@@ -483,16 +483,15 @@ class WindowContainer<E extends WindowContainer> implements Comparable<WindowCon

    /**
     * Rebuilds the WindowList for the input display content.
     * @param dc The display content to rebuild the window list for.
     * @param addIndex The index in the window list to add the next entry to.
     * @return The next index in the window list to.
     */
    // TODO: Hoping we can get rid of WindowList so this method wouldn't be needed.
    int rebuildWindowList(DisplayContent dc, int addIndex) {
    int rebuildWindowList(int addIndex) {
        final int count = mChildren.size();
        for (int i = 0; i < count; i++) {
            final WindowContainer wc = mChildren.get(i);
            addIndex = wc.rebuildWindowList(dc, addIndex);
            addIndex = wc.rebuildWindowList(addIndex);
        }
        return addIndex;
    }
+4 −3
Original line number Diff line number Diff line
@@ -1257,7 +1257,8 @@ public class WindowManagerService extends IWindowManager.Stub
            // excercise to find the appropriate input method target (used for animations
            // and dialog adjustments), but for purposes of Z ordering we simply wish to
            // place it above the docked divider. Unless it is already above the divider.
            WindowState dockedDivider = w.mDisplayContent.mDividerControllerLocked.getWindow();
            final WindowState dockedDivider =
                    w.getDisplayContent().mDividerControllerLocked.getWindow();
            if (dockedDivider != null && dockedDivider.isVisibleLw()) {
                int dividerIndex = windows.indexOf(dockedDivider);
                if (dividerIndex > 0 && dividerIndex > i) {
@@ -1275,7 +1276,7 @@ public class WindowManagerService extends IWindowManager.Stub
        return -1;
    }

    void addInputMethodWindowToListLocked(WindowState win) {
    private void addInputMethodWindowToListLocked(WindowState win) {
        int pos = findDesiredInputMethodWindowIndexLocked(true);
        if (pos >= 0) {
            if (DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) Slog.v(
@@ -1654,7 +1655,7 @@ public class WindowManagerService extends IWindowManager.Stub
            }

            WindowState win = new WindowState(this, session, client, token, parentWindow,
                    appOp[0], seq, attrs, viewVisibility, displayContent, session.mUid);
                    appOp[0], seq, attrs, viewVisibility, session.mUid);
            if (win.mDeathRecipient == null) {
                // Client has apparently died, so there is no reason to
                // continue.
+52 −69
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION;
import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE;
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
import static android.view.WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW;
import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON;
import static android.view.WindowManager.LayoutParams.FLAG_DIM_BEHIND;
import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD;
@@ -468,10 +469,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    boolean mHasSurface = false;

    private boolean mNotOnAppsDisplay = false;
    // TODO: Get this from WindowToken? Done in ag/1522894
    DisplayContent  mDisplayContent;

    /** When true this window can be displayed on screens owther than mOwnerUid's */
    private boolean mShowToOwnerOnly;

@@ -564,7 +561,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP

    WindowState(WindowManagerService service, Session s, IWindow c, WindowToken token,
           WindowState parentWindow, int appOp, int seq, WindowManager.LayoutParams a,
           int viewVisibility, final DisplayContent displayContent, int ownerId) {
           int viewVisibility, int ownerId) {
        mService = service;
        mSession = s;
        mClient = c;
@@ -588,7 +585,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        };
        mAttrs.copyFrom(a);
        mViewVisibility = viewVisibility;
        mDisplayContent = displayContent;
        mPolicy = mService.mPolicy;
        mContext = mService.mContext;
        DeathRecipient deathRecipient = new DeathRecipient();
@@ -644,16 +640,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
        mIsFloatingLayer = mIsImWindow || mIsWallpaper;

        if (mAppToken != null) {
            final DisplayContent appDisplay = getDisplayContent();
            mNotOnAppsDisplay = displayContent != appDisplay;

            if (mAppToken.showForAllUsers) {
                // Windows for apps that can show for all users should also show when the
                // device is locked.
        if (mAppToken != null && mAppToken.showForAllUsers) {
            // Windows for apps that can show for all users should also show when the device is
            // locked.
            mAttrs.flags |= FLAG_SHOW_WHEN_LOCKED;
        }
        }

        mWinAnimator = new WindowStateAnimator(this);
        mWinAnimator.mAlpha = a.alpha;
@@ -667,7 +658,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        mLayer = 0;
        mInputWindowHandle = new InputWindowHandle(
                mAppToken != null ? mAppToken.mInputApplicationHandle : null, this,
                displayContent.getDisplayId());
                getDisplayContent().getDisplayId());
    }

    void attach() {
@@ -715,6 +706,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        final Task task = getTask();
        final boolean fullscreenTask = !isInMultiWindowMode();
        final boolean windowsAreFloating = task != null && task.isFloating();
        final DisplayContent dc = getDisplayContent();

        // If the task has temp inset bounds set, we have to make sure all its windows uses
        // the temp inset frame. Otherwise different display frames get applied to the main
@@ -780,8 +772,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            layoutXDiff = !mInsetFrame.isEmpty() ? mInsetFrame.left - mContainingFrame.left : 0;
            layoutYDiff = !mInsetFrame.isEmpty() ? mInsetFrame.top - mContainingFrame.top : 0;
            layoutContainingFrame = !mInsetFrame.isEmpty() ? mInsetFrame : mContainingFrame;
            mTmpRect.set(0, 0, mDisplayContent.getDisplayInfo().logicalWidth,
                    mDisplayContent.getDisplayInfo().logicalHeight);
            mTmpRect.set(0, 0, dc.getDisplayInfo().logicalWidth, dc.getDisplayInfo().logicalHeight);
            subtractInsets(mDisplayFrame, layoutContainingFrame, df, mTmpRect);
            if (!layoutInParentFrame()) {
                subtractInsets(mContainingFrame, layoutContainingFrame, pf, mTmpRect);
@@ -853,7 +844,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            mVisibleFrame.set(mContentFrame);
            mStableFrame.set(mContentFrame);
        } else if (mAttrs.type == TYPE_DOCK_DIVIDER) {
            mDisplayContent.getDockedDividerController().positionDockedStackedDivider(mFrame);
            dc.getDockedDividerController().positionDockedStackedDivider(mFrame);
            mContentFrame.set(mFrame);
            if (!mFrame.equals(mLastFrame)) {
                mMovedByResize = true;
@@ -1188,20 +1179,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
    }

    public DisplayContent getDisplayContent() {
        if (mAppToken == null || mNotOnAppsDisplay) {
            return mDisplayContent;
        }
        final TaskStack stack = getStack();
        return stack == null ? mDisplayContent : stack.getDisplayContent();
    DisplayContent getDisplayContent() {
        return mToken.getDisplayContent();
    }

    public DisplayInfo getDisplayInfo() {
    DisplayInfo getDisplayInfo() {
        final DisplayContent displayContent = getDisplayContent();
        return displayContent != null ? displayContent.getDisplayInfo() : null;
    }

    public int getDisplayId() {
    int getDisplayId() {
        final DisplayContent displayContent = getDisplayContent();
        if (displayContent == null) {
            return -1;
@@ -1222,8 +1209,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
        // Some system windows (e.g. "Power off" dialog) don't have a task, but we would still
        // associate them with some stack to enable dimming.
        return mAttrs.type >= WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
                && mDisplayContent != null ? mDisplayContent.getHomeStack() : null;
        final DisplayContent dc = getDisplayContent();
        return mAttrs.type >= FIRST_SYSTEM_WINDOW && dc != null ? dc.getHomeStack() : null;
    }

    /**
@@ -2001,12 +1988,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    void scheduleAnimationIfDimming() {
        if (mDisplayContent == null) {
        final DisplayContent dc = getDisplayContent();
        if (dc == null) {
            return;
        }
        final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
        if (dimLayerUser != null && mDisplayContent.mDimLayerController.isDimming(
                dimLayerUser, mWinAnimator)) {
        if (dimLayerUser != null && dc.mDimLayerController.isDimming(dimLayerUser, mWinAnimator)) {
            // Force an animation pass just to update the mDimLayer layer.
            mService.scheduleAnimationLocked();
        }
@@ -2119,16 +2106,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return;
        }

        final DisplayContent dc = getDisplayContent();
        if (!mAnimatingExit && mAppDied) {
            // If app died visible, apply a dim over the window to indicate that it's inactive
            mDisplayContent.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator);
            dc.mDimLayerController.applyDimAbove(getDimLayerUser(), mWinAnimator);
        } else if ((mAttrs.flags & FLAG_DIM_BEHIND) != 0
                && mDisplayContent != null && !mAnimatingExit && isVisibleUnchecked()) {
            mDisplayContent.mDimLayerController.applyDimBehind(getDimLayerUser(), mWinAnimator);
                && dc != null && !mAnimatingExit && isVisibleUnchecked()) {
            dc.mDimLayerController.applyDimBehind(getDimLayerUser(), mWinAnimator);
        }
    }

    DimLayer.DimLayerUser getDimLayerUser() {
    private DimLayer.DimLayerUser getDimLayerUser() {
        Task task = getTask();
        if (task != null) {
            return task;
@@ -2187,8 +2175,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    void setDisplayLayoutNeeded() {
        if (mDisplayContent != null) {
            mDisplayContent.setLayoutNeeded();
        final DisplayContent dc = getDisplayContent();
        if (dc != null) {
            dc.setLayoutNeeded();
        }
    }

@@ -2909,18 +2898,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    @Override
    public boolean isDimming() {
        final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
        return dimLayerUser != null && mDisplayContent != null &&
                mDisplayContent.mDimLayerController.isDimming(dimLayerUser, mWinAnimator);
        final DisplayContent dc = getDisplayContent();
        return dimLayerUser != null && dc != null
                && dc.mDimLayerController.isDimming(dimLayerUser, mWinAnimator);
    }

    public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
    void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {
        mShowToOwnerOnly = showToOwnerOnly;
    }

    boolean isHiddenFromUserLocked() {
        // Child windows are evaluated based on their parent window.
        final WindowState win = getTopParentWindow();
        if (win.mAttrs.type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW
        if (win.mAttrs.type < FIRST_SYSTEM_WINDOW
                && win.mAppToken != null && win.mAppToken.showForAllUsers) {

            // All window frames that are fullscreen extend above status bar, but some don't extend
@@ -3215,7 +3205,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     * @return Whether we reported "resize while not drag resizing" to the application.
     * @see #isResizedWhileNotDragResizing()
     */
    boolean isResizedWhileNotDragResizingReported() {
    private boolean isResizedWhileNotDragResizingReported() {
        return mResizedWhileNotDragResizingReported;
    }

@@ -3223,7 +3213,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mResizeMode;
    }

    boolean computeDragResizing() {
    private boolean computeDragResizing() {
        final Task task = getTask();
        if (task == null) {
            return false;
@@ -3241,7 +3231,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        // and the bounds we clip this window to might be different. In order to avoid holes, we
        // simulate that we are still resizing so the app fills the hole with the resizing
        // background.
        return (mDisplayContent.mDividerControllerLocked.isResizing()
        return (getDisplayContent().mDividerControllerLocked.isResizing()
                        || mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) &&
                !task.inFreeformWorkspace() && !isGoneForLayoutLw();

@@ -3257,7 +3247,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        if (task != null && task.isDragResizing()) {
            mResizeMode = task.getDragResizeMode();
        } else {
            mResizeMode = mDragResizing && mDisplayContent.mDividerControllerLocked.isResizing()
            mResizeMode = mDragResizing && getDisplayContent().mDividerControllerLocked.isResizing()
                    ? DRAG_RESIZE_MODE_DOCKED_DIVIDER
                    : DRAG_RESIZE_MODE_FREEFORM;
        }
@@ -3277,9 +3267,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                if (stack != null) {
                    pw.print(" stackId="); pw.print(stack.mStackId);
                }
                if (mNotOnAppsDisplay) {
                    pw.print(" mNotOnAppsDisplay="); pw.print(mNotOnAppsDisplay);
                }
                pw.print(" mSession="); pw.print(mSession);
                pw.print(" mClient="); pw.println(mClient.asBinder());
        pw.print(prefix); pw.print("mOwnerUid="); pw.print(mOwnerUid);
@@ -3665,9 +3652,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    void requestUpdateWallpaperIfNeeded() {
        if (mDisplayContent != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
            mDisplayContent.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            mDisplayContent.setLayoutNeeded();
        final DisplayContent dc = getDisplayContent();
        if (dc != null && (mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
            dc.pendingLayoutChanges |= FINISH_LAYOUT_REDO_WALLPAPER;
            dc.setLayoutNeeded();
            mService.mWindowPlacerLocked.requestTraversal();
        }

@@ -3693,12 +3681,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return winY;
    }

    void transferDimToReplacement() {
    private void transferDimToReplacement() {
        final DimLayer.DimLayerUser dimLayerUser = getDimLayerUser();
        if (dimLayerUser != null && mDisplayContent != null) {
            mDisplayContent.mDimLayerController.applyDim(dimLayerUser,
                    mReplacementWindow.mWinAnimator,
                    (mAttrs.flags & FLAG_DIM_BEHIND) != 0 ? true : false);
        final DisplayContent dc = getDisplayContent();
        if (dimLayerUser != null && dc != null) {
            dc.mDimLayerController.applyDim(dimLayerUser,
                    mReplacementWindow.mWinAnimator, (mAttrs.flags & FLAG_DIM_BEHIND) != 0);
        }
    }

@@ -3796,13 +3784,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }

        if (mAttrs.type == TYPE_INPUT_METHOD) {
            mDisplayContent.mDividerControllerLocked.resetImeHideRequested();
            getDisplayContent().mDividerControllerLocked.resetImeHideRequested();
        }

        return true;
    }

    void logPerformShow(String prefix) {
    private void logPerformShow(String prefix) {
        if (DEBUG_VISIBILITY
                || (DEBUG_STARTING_WINDOW && mAttrs.type == TYPE_APPLICATION_STARTING)) {
            Slog.v(TAG, prefix + this
@@ -3812,11 +3800,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    + " during animation: policyVis=" + mPolicyVisibility
                    + " parentHidden=" + isParentWindowHidden()
                    + " tok.hiddenRequested="
                    + (mAppToken != null ? mAppToken.hiddenRequested : false)
                    + " tok.hidden=" + (mAppToken != null ? mAppToken.hidden : false)
                    + (mAppToken != null && mAppToken.hiddenRequested)
                    + " tok.hidden=" + (mAppToken != null && mAppToken.hidden)
                    + " animating=" + mWinAnimator.mAnimating
                    + " tok animating="
                    + (mWinAnimator.mAppAnimator != null ? mWinAnimator.mAppAnimator.animating : false)
                    + (mWinAnimator.mAppAnimator != null && mWinAnimator.mAppAnimator.animating)
                    + " Callers=" + Debug.getCallers(4));
        }
    }
@@ -3874,14 +3862,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    }

    @Override
    int rebuildWindowList(DisplayContent dc, int addIndex) {
        final DisplayContent winDisplayContent = getDisplayContent();
        if (winDisplayContent == dc || winDisplayContent == null) {
            mDisplayContent = dc;
    int rebuildWindowList(int addIndex) {
        return reAddWindow(addIndex);
    }
        return addIndex;
    }

    // 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
Loading