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

Commit 1bca3024 authored by Winson Chung's avatar Winson Chung
Browse files

Tweak transition logs to make them a bit easier to follow

- Break out sent TransitionInfo changes into their own line to make them
  easier to parse
- Send the transition id with the TransitionRequestInfo so we can log it
  on both ends
- Print transition ids in the same way "(#id)" in both shell and core
- Add dump method to shell transitions to dump active/pending

Bug: 305873102
Test: logcat | grep WindowManager
Test: dumpsys activity service SystemUIService

Change-Id: Ifecd6d9c022f193184a751f6a2eed8b9405b1049
parent 52d4cfa2
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -402,6 +402,18 @@ public final class TransitionInfo implements Parcelable {


    @Override
    @Override
    public String toString() {
    public String toString() {
        return toString("");
    }

    /**
     * Returns a string representation of this transition info.
     * @hide
     */
    public String toString(@NonNull String prefix) {
        final boolean shouldPrettyPrint = !prefix.isEmpty() && !mChanges.isEmpty();
        final String innerPrefix = shouldPrettyPrint ? prefix + "    " : "";
        final String changesLineStart = shouldPrettyPrint ? "\n" + prefix : "";
        final String perChangeLineStart = shouldPrettyPrint ? "\n" + innerPrefix : "";
        StringBuilder sb = new StringBuilder();
        StringBuilder sb = new StringBuilder();
        sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType))
        sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType))
                .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack)
                .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack)
@@ -413,12 +425,15 @@ public final class TransitionInfo implements Parcelable {
            sb.append(mRoots.get(i).mDisplayId).append("@").append(mRoots.get(i).mOffset);
            sb.append(mRoots.get(i).mDisplayId).append("@").append(mRoots.get(i).mOffset);
        }
        }
        sb.append("] c=[");
        sb.append("] c=[");
        sb.append(perChangeLineStart);
        for (int i = 0; i < mChanges.size(); ++i) {
        for (int i = 0; i < mChanges.size(); ++i) {
            if (i > 0) {
            if (i > 0) {
                sb.append(',');
                sb.append(',');
                sb.append(perChangeLineStart);
            }
            }
            sb.append(mChanges.get(i));
            sb.append(mChanges.get(i));
        }
        }
        sb.append(changesLineStart);
        sb.append("]}");
        sb.append("]}");
        return sb.toString();
        return sb.toString();
    }
    }
+40 −8
Original line number Original line Diff line number Diff line
@@ -62,13 +62,16 @@ public final class TransitionRequestInfo implements Parcelable {
    /** The transition flags known at the time of the request. These may not be complete. */
    /** The transition flags known at the time of the request. These may not be complete. */
    private final int mFlags;
    private final int mFlags;


    /** This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work! */
    private final int mDebugId;

    /** constructor override */
    /** constructor override */
    public TransitionRequestInfo(
    public TransitionRequestInfo(
            @WindowManager.TransitionType int type,
            @WindowManager.TransitionType int type,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable RemoteTransition remoteTransition) {
            @Nullable RemoteTransition remoteTransition) {
        this(type, triggerTask, null /* pipTask */,
        this(type, triggerTask, null /* pipTask */,
                remoteTransition, null /* displayChange */, 0 /* flags */);
                remoteTransition, null /* displayChange */, 0 /* flags */, -1 /* debugId */);
    }
    }


    /** constructor override */
    /** constructor override */
@@ -78,16 +81,29 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable RemoteTransition remoteTransition,
            @Nullable RemoteTransition remoteTransition,
            int flags) {
            int flags) {
        this(type, triggerTask, null /* pipTask */,
        this(type, triggerTask, null /* pipTask */,
                remoteTransition, null /* displayChange */, flags);
                remoteTransition, null /* displayChange */, flags, -1 /* debugId */);
    }

        /** constructor override */
    public TransitionRequestInfo(
            @WindowManager.TransitionType int type,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            int flags) {
        this(type, triggerTask, null /* pipTask */, remoteTransition, displayChange, flags,
                -1 /* debugId */);
    }
    }


    /** constructor override */
    public TransitionRequestInfo(
    public TransitionRequestInfo(
            @WindowManager.TransitionType int type,
            @WindowManager.TransitionType int type,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable ActivityManager.RunningTaskInfo triggerTask,
            @Nullable ActivityManager.RunningTaskInfo pipTask,
            @Nullable RemoteTransition remoteTransition,
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            int flags) {
            int flags) {
        this(type, triggerTask, null /* pipTask */, remoteTransition, displayChange, flags);
        this(type, triggerTask, pipTask, remoteTransition, displayChange, flags, -1 /* debugId */);
    }
    }


    /** @hide */
    /** @hide */
@@ -270,7 +286,7 @@ public final class TransitionRequestInfo implements Parcelable {
        };
        };


        @DataClass.Generated(
        @DataClass.Generated(
                time = 1695667226050L,
                time = 1697564781403L,
                codegenVersion = "1.0.23",
                codegenVersion = "1.0.23",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
                inputSignatures = "private final  int mDisplayId\nprivate @android.annotation.Nullable android.graphics.Rect mStartAbsBounds\nprivate @android.annotation.Nullable android.graphics.Rect mEndAbsBounds\nprivate  int mStartRotation\nprivate  int mEndRotation\nprivate  boolean mPhysicalDisplayChanged\nclass DisplayChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
                inputSignatures = "private final  int mDisplayId\nprivate @android.annotation.Nullable android.graphics.Rect mStartAbsBounds\nprivate @android.annotation.Nullable android.graphics.Rect mEndAbsBounds\nprivate  int mStartRotation\nprivate  int mEndRotation\nprivate  boolean mPhysicalDisplayChanged\nclass DisplayChange extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genBuilder=false, genConstructor=false)")
@@ -318,6 +334,8 @@ public final class TransitionRequestInfo implements Parcelable {
     *   (if size is changing).
     *   (if size is changing).
     * @param flags
     * @param flags
     *   The transition flags known at the time of the request. These may not be complete.
     *   The transition flags known at the time of the request. These may not be complete.
     * @param debugId
     *   This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work!
     */
     */
    @DataClass.Generated.Member
    @DataClass.Generated.Member
    public TransitionRequestInfo(
    public TransitionRequestInfo(
@@ -326,7 +344,8 @@ public final class TransitionRequestInfo implements Parcelable {
            @Nullable ActivityManager.RunningTaskInfo pipTask,
            @Nullable ActivityManager.RunningTaskInfo pipTask,
            @Nullable RemoteTransition remoteTransition,
            @Nullable RemoteTransition remoteTransition,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            @Nullable TransitionRequestInfo.DisplayChange displayChange,
            int flags) {
            int flags,
            int debugId) {
        this.mType = type;
        this.mType = type;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
                WindowManager.TransitionType.class, null, mType);
                WindowManager.TransitionType.class, null, mType);
@@ -335,6 +354,7 @@ public final class TransitionRequestInfo implements Parcelable {
        this.mRemoteTransition = remoteTransition;
        this.mRemoteTransition = remoteTransition;
        this.mDisplayChange = displayChange;
        this.mDisplayChange = displayChange;
        this.mFlags = flags;
        this.mFlags = flags;
        this.mDebugId = debugId;


        // onConstructed(); // You can define this method to get a callback
        // onConstructed(); // You can define this method to get a callback
    }
    }
@@ -391,6 +411,14 @@ public final class TransitionRequestInfo implements Parcelable {
        return mFlags;
        return mFlags;
    }
    }


    /**
     * This is only a BEST-EFFORT id used for log correlation. DO NOT USE for any real work!
     */
    @DataClass.Generated.Member
    public int getDebugId() {
        return mDebugId;
    }

    /**
    /**
     * If non-null, the task containing the activity whose lifecycle change (start or
     * If non-null, the task containing the activity whose lifecycle change (start or
     * finish) has caused this transition to occur.
     * finish) has caused this transition to occur.
@@ -443,7 +471,8 @@ public final class TransitionRequestInfo implements Parcelable {
                "pipTask = " + mPipTask + ", " +
                "pipTask = " + mPipTask + ", " +
                "remoteTransition = " + mRemoteTransition + ", " +
                "remoteTransition = " + mRemoteTransition + ", " +
                "displayChange = " + mDisplayChange + ", " +
                "displayChange = " + mDisplayChange + ", " +
                "flags = " + mFlags +
                "flags = " + mFlags + ", " +
                "debugId = " + mDebugId +
        " }";
        " }";
    }
    }


@@ -465,6 +494,7 @@ public final class TransitionRequestInfo implements Parcelable {
        if (mRemoteTransition != null) dest.writeTypedObject(mRemoteTransition, flags);
        if (mRemoteTransition != null) dest.writeTypedObject(mRemoteTransition, flags);
        if (mDisplayChange != null) dest.writeTypedObject(mDisplayChange, flags);
        if (mDisplayChange != null) dest.writeTypedObject(mDisplayChange, flags);
        dest.writeInt(mFlags);
        dest.writeInt(mFlags);
        dest.writeInt(mDebugId);
    }
    }


    @Override
    @Override
@@ -485,6 +515,7 @@ public final class TransitionRequestInfo implements Parcelable {
        RemoteTransition remoteTransition = (flg & 0x8) == 0 ? null : (RemoteTransition) in.readTypedObject(RemoteTransition.CREATOR);
        RemoteTransition remoteTransition = (flg & 0x8) == 0 ? null : (RemoteTransition) in.readTypedObject(RemoteTransition.CREATOR);
        TransitionRequestInfo.DisplayChange displayChange = (flg & 0x10) == 0 ? null : (TransitionRequestInfo.DisplayChange) in.readTypedObject(TransitionRequestInfo.DisplayChange.CREATOR);
        TransitionRequestInfo.DisplayChange displayChange = (flg & 0x10) == 0 ? null : (TransitionRequestInfo.DisplayChange) in.readTypedObject(TransitionRequestInfo.DisplayChange.CREATOR);
        int flags = in.readInt();
        int flags = in.readInt();
        int debugId = in.readInt();


        this.mType = type;
        this.mType = type;
        com.android.internal.util.AnnotationValidations.validate(
        com.android.internal.util.AnnotationValidations.validate(
@@ -494,6 +525,7 @@ public final class TransitionRequestInfo implements Parcelable {
        this.mRemoteTransition = remoteTransition;
        this.mRemoteTransition = remoteTransition;
        this.mDisplayChange = displayChange;
        this.mDisplayChange = displayChange;
        this.mFlags = flags;
        this.mFlags = flags;
        this.mDebugId = debugId;


        // onConstructed(); // You can define this method to get a callback
        // onConstructed(); // You can define this method to get a callback
    }
    }
@@ -513,10 +545,10 @@ public final class TransitionRequestInfo implements Parcelable {
    };
    };


    @DataClass.Generated(
    @DataClass.Generated(
            time = 1695667226088L,
            time = 1697564781438L,
            codegenVersion = "1.0.23",
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
            sourceFile = "frameworks/base/core/java/android/window/TransitionRequestInfo.java",
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mPipTask\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.DisplayChange mDisplayChange\nprivate final  int mFlags\n  java.lang.String typeToString()\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
            inputSignatures = "private final @android.view.WindowManager.TransitionType int mType\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mTriggerTask\nprivate @android.annotation.Nullable android.app.ActivityManager.RunningTaskInfo mPipTask\nprivate @android.annotation.Nullable android.window.RemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.window.TransitionRequestInfo.DisplayChange mDisplayChange\nprivate final  int mFlags\nprivate final  int mDebugId\n  java.lang.String typeToString()\nclass TransitionRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
    @Deprecated
    @Deprecated
    private void __metadata() {}
    private void __metadata() {}


+3 −3
Original line number Original line Diff line number Diff line
@@ -605,6 +605,7 @@ public abstract class WMShellBaseModule {
    @Provides
    @Provides
    static Transitions provideTransitions(Context context,
    static Transitions provideTransitions(Context context,
            ShellInit shellInit,
            ShellInit shellInit,
            ShellCommandHandler shellCommandHandler,
            ShellController shellController,
            ShellController shellController,
            ShellTaskOrganizer organizer,
            ShellTaskOrganizer organizer,
            TransactionPool pool,
            TransactionPool pool,
@@ -612,14 +613,13 @@ public abstract class WMShellBaseModule {
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread Handler mainHandler,
            @ShellMainThread Handler mainHandler,
            @ShellAnimationThread ShellExecutor animExecutor,
            @ShellAnimationThread ShellExecutor animExecutor,
            ShellCommandHandler shellCommandHandler,
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer) {
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer) {
        if (!context.getResources().getBoolean(R.bool.config_registerShellTransitionsOnInit)) {
        if (!context.getResources().getBoolean(R.bool.config_registerShellTransitionsOnInit)) {
            // TODO(b/238217847): Force override shell init if registration is disabled
            // TODO(b/238217847): Force override shell init if registration is disabled
            shellInit = new ShellInit(mainExecutor);
            shellInit = new ShellInit(mainExecutor);
        }
        }
        return new Transitions(context, shellInit, shellController, organizer, pool,
        return new Transitions(context, shellInit, shellCommandHandler, shellController, organizer,
                displayController, mainExecutor, mainHandler, animExecutor, shellCommandHandler,
                pool, displayController, mainExecutor, mainHandler, animExecutor,
                rootTaskDisplayAreaOrganizer);
                rootTaskDisplayAreaOrganizer);
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        if (mTransition != transition) return false;
        if (mTransition != transition) return false;
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Using registered One-shot remote"
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Using registered One-shot remote"
                + " transition %s for #%d.", mRemote, info.getDebugId());
                + " transition %s for (#%d).", mRemote, info.getDebugId());


        final IBinder.DeathRecipient remoteDied = () -> {
        final IBinder.DeathRecipient remoteDied = () -> {
            Log.e(Transitions.TAG, "Remote transition died, finishing");
            Log.e(Transitions.TAG, "Remote transition died, finishing");
+2 −2
Original line number Original line Diff line number Diff line
@@ -126,7 +126,7 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
                }
                }
            }
            }
        }
        }
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Delegate animation for #%d to %s",
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, " Delegate animation for (#%d) to %s",
                info.getDebugId(), pendingRemote);
                info.getDebugId(), pendingRemote);


        if (pendingRemote == null) return false;
        if (pendingRemote == null) return false;
@@ -241,7 +241,7 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler {
        if (remote == null) return null;
        if (remote == null) return null;
        mRequestedRemotes.put(transition, remote);
        mRequestedRemotes.put(transition, remote);
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "RemoteTransition directly requested"
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "RemoteTransition directly requested"
                + " for %s: %s", transition, remote);
                + " for (#%d) %s: %s", request.getDebugId(), transition, remote);
        return new WindowContainerTransaction();
        return new WindowContainerTransaction();
    }
    }


Loading