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

Commit 44f2180c authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Introduced WindowContainer.hasContentToDisplay

We have lots of "is visible" methods and this change is an attempt
to rename one of the methods to match closer to what is actually does
and differentiate it from other "is visible" methods.

WC.hasContentToDisplay() returns true if the container or one of its
children as some content it can display or wants to display
(e.g. app views or saved surface).

WC.isVisible() returns true if the container or one of its children
is considered visible from the WindowManager perspective which usually
means valid surface and some other internal state are true.

Bug: 30060889
Change-Id: Ifbd6c277eb65a53b8035b6f34fc45196962632c1
parent 74784e8e
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.wm;

import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ANIM;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYERS;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.SHOW_TRANSACTIONS;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
@@ -119,7 +118,7 @@ public class AppWindowAnimator {
            int stackClip) {
        if (WindowManagerService.localLOGV) Slog.v(TAG, "Setting animation in " + mAppToken
                + ": " + anim + " wxh=" + width + "x" + height
                + " isVisible=" + mAppToken.isVisible());
                + " hasContentToDisplay=" + mAppToken.hasContentToDisplay());
        animation = anim;
        animating = false;
        if (!anim.isInitialized()) {
@@ -141,7 +140,7 @@ public class AppWindowAnimator {
        }
        // Start out animation gone if window is gone, or visible if window is visible.
        transformation.clear();
        transformation.setAlpha(mAppToken.isVisible() ? 1 : 0);
        transformation.setAlpha(mAppToken.hasContentToDisplay() ? 1 : 0);
        hasTransformation = true;
        mStackClip = stackClip;

@@ -164,11 +163,11 @@ public class AppWindowAnimator {

    public void setDummyAnimation() {
        if (WindowManagerService.localLOGV) Slog.v(TAG, "Setting dummy animation in " + mAppToken
                + " isVisible=" + mAppToken.isVisible());
                + " hasContentToDisplay=" + mAppToken.hasContentToDisplay());
        animation = sDummyAnimation;
        hasTransformation = true;
        transformation.clear();
        transformation.setAlpha(mAppToken.isVisible() ? 1 : 0);
        transformation.setAlpha(mAppToken.hasContentToDisplay() ? 1 : 0);
    }

    void setNullAnimation() {
+9 −0
Original line number Diff line number Diff line
@@ -358,6 +358,15 @@ class AppWindowToken extends WindowToken {
        return StackId.canReceiveKeys(mTask.mStack.mStackId) || mAlwaysFocusable;
    }

    @Override
    boolean isVisible() {
        if (hidden) {
            // TODO: Should this be checking hiddenRequested instead of hidden?
            return false;
        }
        return super.isVisible();
    }

    @Override
    void removeIfPossible() {
        mIsExiting = false;
+10 −0
Original line number Diff line number Diff line
@@ -579,6 +579,16 @@ class Task implements DimLayer.DimLayerUser {
        return (tokensCount != 0) && mAppTokens.get(tokensCount - 1).showForAllUsers;
    }

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

    boolean isVisible() {
        for (int i = mAppTokens.size() - 1; i >= 0; i--) {
            final AppWindowToken appToken = mAppTokens.get(i);
+3 −6
Original line number Diff line number Diff line
@@ -43,7 +43,6 @@ import android.util.Slog;
import android.util.SparseArray;
import android.view.DisplayInfo;
import android.view.Surface;
import android.view.SurfaceControl;
import android.view.animation.Animation;

import com.android.internal.policy.DividerSnapAlgorithm;
@@ -898,7 +897,7 @@ public class TaskStack implements DimLayer.DimLayerUser,
    void beginImeAdjustAnimation() {
        for (int j = mTasks.size() - 1; j >= 0; j--) {
            final Task task = mTasks.get(j);
            if (task.isVisible()) {
            if (task.hasContentToDisplay()) {
                task.setDragResizing(true, DRAG_RESIZE_MODE_DOCKED_DIVIDER);
                task.setWaitingForDrawnIfResizingChanged();
            }
@@ -1201,12 +1200,10 @@ public class TaskStack implements DimLayer.DimLayerUser,

        for (int i = mTasks.size() - 1; i >= 0; i--) {
            final Task task = mTasks.get(i);
            for (int j = task.mAppTokens.size() - 1; j >= 0; j--) {
                if (!task.mAppTokens.get(j).hidden) {
            if (task.isVisible()) {
                return true;
            }
        }
        }

        return false;
    }
+27 −0
Original line number Diff line number Diff line
@@ -193,6 +193,33 @@ class WindowContainer {
        }
    }

    /**
     * Returns true if the container or one of its children as some content it can display or wants
     * to display (e.g. app views or saved surface).
     *
     * NOTE: While this method will return true if the there is some content to display, it doesn't
     * mean the container is visible. Use {@link #isVisible()} to determine if the container is
     * visible.
     */
    boolean hasContentToDisplay() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowContainer wc = mChildren.get(i);
            if (wc.hasContentToDisplay()) {
                return true;
            }
        }
        return false;
    }

    /**
     * Returns true if the container or one of its children is considered visible from the
     * WindowManager perspective which usually means valid surface and some other internal state
     * are true.
     *
     * NOTE: While this method will return true if the surface is visible, it doesn't mean the
     * client has actually displayed any content. Use {@link #hasContentToDisplay()} to determine if
     * the container has any content to display.
     */
    boolean isVisible() {
        for (int i = mChildren.size() - 1; i >= 0; --i) {
            final WindowContainer wc = mChildren.get(i);
Loading