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

Commit e9f5931e authored by Jorge Gil's avatar Jorge Gil
Browse files

Add window decor logs and dump state

To help investigate missing App Headers / decorations.

Flag: EXEMPT adding logs
Bug: 413375299
Bug: 415096258
Test: logcat -s ShellWindowDecoration:*
Test: dumpsys | grep DesktopModeWindowDecorViewModel -A 50
Change-Id: I621589f63870034f5667df9a7c97305a26f2cc1f
parent a4e6d185
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.Indica
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_LEFT_INDICATOR;
import static com.android.wm.shell.desktopmode.DesktopModeVisualIndicator.IndicatorType.TO_SPLIT_RIGHT_INDICATOR;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_WINDOW_DECORATION;
import static com.android.wm.shell.shared.multiinstance.ManageWindowsViewContainer.MANAGE_WINDOWS_MINIMUM_INSTANCES;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_TOP_OR_LEFT;
@@ -1846,9 +1847,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            SurfaceControl taskSurface,
            SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT) {
        ProtoLog.d(WM_SHELL_WINDOW_DECORATION, "%s: createWindowDecoration taskId=%d surface=%s",
                TAG, taskInfo.taskId, taskSurface);
        final DesktopModeWindowDecoration oldDecoration = mWindowDecorByTaskId.get(taskInfo.taskId);
        if (oldDecoration != null) {
            // close the old decoration if it exists to avoid two window decorations being added
            ProtoLog.d(WM_SHELL_WINDOW_DECORATION, "%s: closing old decoration", TAG);
            oldDecoration.close();
        }
        final DesktopModeWindowDecoration windowDecoration =
@@ -1932,12 +1936,16 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
    private void dump(PrintWriter pw, String prefix) {
        final String innerPrefix = prefix + "  ";
        pw.println(prefix + "DesktopModeWindowDecorViewModel");
        pw.println(innerPrefix + "DesktopModeStatus="
                + mDesktopState.canEnterDesktopMode());
        pw.println(innerPrefix + "DesktopModeStatus=" + mDesktopState.canEnterDesktopMode());
        pw.println(innerPrefix + "mTransitionDragActive=" + mTransitionDragActive);
        pw.println(innerPrefix + "mEventReceiversByDisplay=" + mEventReceiversByDisplay);
        pw.println(innerPrefix + "mWindowDecorByTaskId=" + mWindowDecorByTaskId);
        pw.println(innerPrefix + "mExclusionRegion=" + mExclusionRegion);
        for (int i = 0; i < mWindowDecorByTaskId.size(); i++) {
            final DesktopModeWindowDecoration decor = mWindowDecorByTaskId.valueAt(i);
            if (decor != null) {
                decor.dump(pw, innerPrefix);
            }
        }
    }

    private class DesktopModeOnTaskRepositionAnimationListener
+33 −8
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_
import static android.window.DesktopModeFlags.ENABLE_CAPTION_COMPAT_INSET_FORCE_CONSUMPTION_ALWAYS;

import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightId;
import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_WINDOW_DECORATION;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SPLIT_POSITION_BOTTOM_OR_RIGHT;
import static com.android.wm.shell.windowdecor.DragPositioningCallbackUtility.DragEventListener;
import static com.android.wm.shell.windowdecor.DragResizeWindowGeometry.DisabledEdge;
@@ -58,6 +59,7 @@ import android.net.Uri;
import android.os.Handler;
import android.os.Trace;
import android.os.UserHandle;
import android.util.IndentingPrintWriter;
import android.util.Size;
import android.view.Choreographer;
import android.view.Display;
@@ -77,6 +79,7 @@ import android.window.WindowContainerTransaction;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.policy.SystemBarUtils;
import com.android.internal.protolog.ProtoLog;
import com.android.window.flags.Flags;
import com.android.wm.shell.R;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
@@ -123,6 +126,7 @@ import kotlin.jvm.functions.Function1;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.MainCoroutineDispatcher;

import java.io.PrintWriter;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
@@ -442,6 +446,11 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
            boolean applyStartTransactionOnDraw, boolean shouldSetTaskVisibilityPositionAndCrop,
            boolean hasGlobalFocus, @NonNull Region displayExclusionRegion) {
        Trace.beginSection("DesktopModeWindowDecoration#relayout");
        ProtoLog.d(WM_SHELL_WINDOW_DECORATION, "%s: relayout of taskId=%d startT=%s finishT=%s "
                + "applyStartTransactionOnDraw=%b "
                + "shouldSetTaskVisibilityPositionAndCrop=%b hasGlobalFocus=%b taskVisible=%b",
                TAG, taskInfo.taskId, startT.getId(), finishT.getId(), applyStartTransactionOnDraw,
                shouldSetTaskVisibilityPositionAndCrop, hasGlobalFocus, taskInfo.isVisible);

        if (DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_APP_TO_WEB.isTrue()) {
            setCapturedLink(taskInfo.capturedLink, taskInfo.capturedLinkTimestamp);
@@ -1911,14 +1920,30 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
        return !animatingTaskResizeOrReposition && !inImmersiveAndRequesting;
    }

    @Override
    public String toString() {
        return "{"
                + "mPositionInParent=" + mPositionInParent + ", "
                + "taskId=" + mTaskInfo.taskId + ", "
                + "windowingMode=" + windowingModeToString(mTaskInfo.getWindowingMode()) + ", "
                + "isFocused=" + isFocused()
                + "}";
    void dump(@NonNull PrintWriter originalWriter, @NonNull String prefix) {
        final IndentingPrintWriter pw = new IndentingPrintWriter(originalWriter, "  ", prefix);
        pw.println("DesktopModeWindowDecoration (task#" + mTaskInfo.taskId + ")");
        pw.increaseIndent();
        pw.println("mPositionInParent=" + mPositionInParent);
        pw.println("windowingMode=" + windowingModeToString(mTaskInfo.getWindowingMode()));
        pw.println("isFocused=" + isFocused());
        pw.println("taskVisible=" + mTaskInfo.isVisible);
        pw.println("mIsRecentsTransitionRunning=" + mIsRecentsTransitionRunning);
        pw.println("mIsDragging=" + mIsDragging);
        pw.println("mIsAppHeaderMaximizeButtonHovered=" + mIsAppHeaderMaximizeButtonHovered);
        pw.println("mIsMaximizeMenuHovered=" + mIsMaximizeMenuHovered);
        pw.println("mMinimumInstancesFound=" + mMinimumInstancesFound);
        pw.println("mDisabledResizingEdge=" + mDisabledResizingEdge);
        pw.println("mCapturedLink=" + mCapturedLink);
        pw.println("mGenericLink=" + mGenericLink);
        pw.println("mWebUri=" + mWebUri);
        if (mRelayoutParams != null) {
            mRelayoutParams.dump(pw, mContext);
        }
        pw.decreaseIndent();
        if (mResult != null) {
            mResult.dump(pw);
        }
    }

    static class Factory {
+102 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import static android.view.WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.TRANSIT_CHANGE;

import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_WINDOW_DECORATION;

import android.annotation.IdRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager.RunningTaskInfo;
@@ -40,6 +43,7 @@ import android.gui.BoxShadowSettings;
import android.os.Binder;
import android.os.Handler;
import android.os.Trace;
import android.util.IndentingPrintWriter;
import android.view.Display;
import android.view.InsetsSource;
import android.view.InsetsState;
@@ -56,6 +60,7 @@ import android.window.TaskConstants;
import android.window.WindowContainerTransaction;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.ShellTaskOrganizer;
import com.android.wm.shell.common.BoxShadowHelper;
import com.android.wm.shell.common.DisplayController;
@@ -91,6 +96,8 @@ import java.util.function.Supplier;
public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
        implements AutoCloseable {

    private static final String TAG = "WindowDecoration";

    /**
     * The Z-order of the caption surface.
     * <p>
@@ -256,6 +263,9 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
    void relayout(RelayoutParams params, SurfaceControl.Transaction startT,
            SurfaceControl.Transaction finishT, WindowContainerTransaction wct, T rootView,
            RelayoutResult<T> outResult) {
        ProtoLog.v(WM_SHELL_WINDOW_DECORATION,
                "%s: relayout params=%s startT=%s finishT=%s",
                TAG, params.toString(mContext.getResources()), startT.getId(), finishT.getId());
        Trace.beginSection("WindowDecoration#relayout");
        outResult.reset();
        if (params.mRunningTaskInfo != null) {
@@ -947,6 +957,76 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            return (mInputFeatures & WindowManager.LayoutParams.INPUT_FEATURE_SPY) != 0;
        }

        void dump(@NonNull IndentingPrintWriter pw, @NonNull Context context) {
            pw.println("RelayoutParams");
            pw.increaseIndent();
            final Resources resources = context.getResources();
            pw.println("mTaskId=" + (mRunningTaskInfo != null ? mRunningTaskInfo.taskId : null));
            pw.println("mLayoutResId=" + resToString(mLayoutResId, resources));
            pw.println("mCaptionWidthId=" + resToString(mCaptionWidthId, resources));
            pw.println("mOccludingCaptionElements=" + occludingCaptionElementsToString(resources));
            pw.println("mLimitTouchRegionToSystemAreas=" + mLimitTouchRegionToSystemAreas);
            pw.println("mInputFeatures=" + Integer.toHexString(mInputFeatures));
            pw.println("mIsInsetSource=" + mIsInsetSource);
            pw.println("mInsetSourceFlags=" + InsetsSource.flagsToString(mInsetSourceFlags));
            pw.println("mDisplayExclusionRegion=" + mDisplayExclusionRegion);
            pw.println("mShadowRadiusId=" + resToString(mShadowRadiusId, resources));
            pw.println("mCornerRadiusId=" + resToString(mCornerRadiusId, resources));
            pw.println("mBorderSettingsId=" + resToString(mBorderSettingsId, resources));
            pw.println("mCaptionTopPadding=" + mCaptionTopPadding);
            pw.println("mIsCaptionVisible=" + mIsCaptionVisible);
            pw.println("mAsyncViewHost=" + mAsyncViewHost);
            pw.println("mApplyStartTransactionOnDraw=" + mApplyStartTransactionOnDraw);
            pw.println("mSetTaskVisibilityPositionAndCrop=" + mSetTaskVisibilityPositionAndCrop);
            pw.println("mHasGlobalFocus=" + mHasGlobalFocus);
            pw.println("mShouldSetAppBounds=" + mShouldSetAppBounds);
            pw.println("mShouldSetBackground=" + mShouldSetBackground);
        }

        public String toString(@NonNull Resources resources) {
            return "RelayoutParams{"
                    + "mTaskId=" + (mRunningTaskInfo != null ? mRunningTaskInfo.taskId : null) + " "
                    + "mLayoutResId=" + resToString(mLayoutResId, resources) + " "
                    + "mCaptionWidthId=" + resToString(mCaptionWidthId, resources) + " "
                    + "mOccludingCaptionElements="
                    + occludingCaptionElementsToString(resources) + " "
                    + "mLimitTouchRegionToSystemAreas=" + mLimitTouchRegionToSystemAreas + " "
                    + "mInputFeatures=" + Integer.toHexString(mInputFeatures) + " "
                    + "mIsInsetSource=" + mIsInsetSource + " "
                    + "mInsetSourceFlags=" + InsetsSource.flagsToString(mInsetSourceFlags) + " "
                    + "mDisplayExclusionRegion=" + mDisplayExclusionRegion + " "
                    + "mShadowRadiusId=" + resToString(mShadowRadiusId, resources) + " "
                    + "mCornerRadiusId=" + resToString(mCornerRadiusId, resources) + " "
                    + "mBorderSettingsId=" + resToString(mBorderSettingsId, resources) + " "
                    + "mCaptionTopPadding=" + mCaptionTopPadding + " "
                    + "mIsCaptionVisible=" + mIsCaptionVisible + " "
                    + "mAsyncViewHost=" + mAsyncViewHost + " "
                    + "mApplyStartTransactionOnDraw=" + mApplyStartTransactionOnDraw + " "
                    + "mSetTaskVisibilityPositionAndCrop=" + mSetTaskVisibilityPositionAndCrop + " "
                    + "mHasGlobalFocus=" + mHasGlobalFocus + " "
                    + "mShouldSetAppBounds=" + mShouldSetAppBounds + " "
                    + "mShouldSetBackground=" + mShouldSetBackground
                    + "}";
        }

        private static String resToString(@IdRes int resId, @NonNull Resources resources) {
            return resId != 0 ? resources.getResourceName(resId) : "ID_NULL";
        }

        private String occludingCaptionElementsToString(@NonNull Resources resources) {
            final StringBuilder sb = new StringBuilder();
            sb.append("[");
            for (int i = 0; i < mOccludingCaptionElements.size(); i++) {
                final OccludingCaptionElement element = mOccludingCaptionElements.get(i);
                sb.append(element.toString(resources));
                if (i < mOccludingCaptionElements.size() - 1) {
                    sb.append(", ");
                }
            }
            sb.append("]");
            return sb.toString();
        }

        /**
         * Describes elements within the caption bar that could occlude app content, and should be
         * sent as bounding rectangles to the insets system.
@@ -958,6 +1038,13 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
            enum Alignment {
                START, END
            }

            String toString(@NonNull Resources resources) {
                return "OccludingCaptionElement{"
                        + "mWidthResId=" + resToString(mWidthResId, resources) + " "
                        + "mAlignment=" + mAlignment
                        + "}";
            }
        }
    }

@@ -993,6 +1080,21 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
                mShadowRadius = INVALID_SHADOW_RADIUS;
            }
        }

        void dump(@NonNull IndentingPrintWriter pw) {
            pw.println("RelayoutResult");
            pw.increaseIndent();
            pw.println("mCaptionWidth=" + mCaptionWidth);
            pw.println("mCaptionHeight=" + mCaptionHeight);
            pw.println("mCaptionX=" + mCaptionX);
            pw.println("mCaptionY=" + mCaptionY);
            pw.println("mCaptionTopPadding=" + mCaptionTopPadding);
            pw.println("mCustomizableCaptionRegion=" + mCustomizableCaptionRegion);
            pw.println("mWidth=" + mWidth);
            pw.println("mHeight=" + mHeight);
            pw.println("mCornerRadius=" + mCornerRadius);
            pw.println("mShadowRadius=" + mShadowRadius);
        }
    }

    private static class CaptionWindowlessWindowManager extends WindowlessWindowManager {