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

Commit 597811e8 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "Improve transition logging" into udc-dev

parents d6e2ea0a 7355478f
Loading
Loading
Loading
Loading
+40 −5
Original line number Diff line number Diff line
@@ -38,9 +38,18 @@ public class RemoteTransition implements Parcelable {
    /** The application thread that will be running the remote transition. */
    private @Nullable IApplicationThread mAppThread;

    /** A name for this that can be used for debugging. */
    private @Nullable String mDebugName;

    /** Constructs with no app thread (animation runs in shell). */
    public RemoteTransition(@NonNull IRemoteTransition remoteTransition) {
        this(remoteTransition, null /* appThread */);
        this(remoteTransition, null /* appThread */, null /* debugName */);
    }

    /** Constructs with no app thread (animation runs in shell). */
    public RemoteTransition(@NonNull IRemoteTransition remoteTransition,
            @Nullable String debugName) {
        this(remoteTransition, null /* appThread */, debugName);
    }

    /** Get the IBinder associated with the underlying IRemoteTransition. */
@@ -70,15 +79,19 @@ public class RemoteTransition implements Parcelable {
     *   The actual remote-transition interface used to run the transition animation.
     * @param appThread
     *   The application thread that will be running the remote transition.
     * @param debugName
     *   A name for this that can be used for debugging.
     */
    @DataClass.Generated.Member
    public RemoteTransition(
            @NonNull IRemoteTransition remoteTransition,
            @Nullable IApplicationThread appThread) {
            @Nullable IApplicationThread appThread,
            @Nullable String debugName) {
        this.mRemoteTransition = remoteTransition;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mRemoteTransition);
        this.mAppThread = appThread;
        this.mDebugName = debugName;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -99,6 +112,14 @@ public class RemoteTransition implements Parcelable {
        return mAppThread;
    }

    /**
     * A name for this that can be used for debugging.
     */
    @DataClass.Generated.Member
    public @Nullable String getDebugName() {
        return mDebugName;
    }

    /**
     * The actual remote-transition interface used to run the transition animation.
     */
@@ -119,6 +140,15 @@ public class RemoteTransition implements Parcelable {
        return this;
    }

    /**
     * A name for this that can be used for debugging.
     */
    @DataClass.Generated.Member
    public @NonNull RemoteTransition setDebugName(@NonNull String value) {
        mDebugName = value;
        return this;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
@@ -127,7 +157,8 @@ public class RemoteTransition implements Parcelable {

        return "RemoteTransition { " +
                "remoteTransition = " + mRemoteTransition + ", " +
                "appThread = " + mAppThread +
                "appThread = " + mAppThread + ", " +
                "debugName = " + mDebugName +
        " }";
    }

@@ -139,9 +170,11 @@ public class RemoteTransition implements Parcelable {

        byte flg = 0;
        if (mAppThread != null) flg |= 0x2;
        if (mDebugName != null) flg |= 0x4;
        dest.writeByte(flg);
        dest.writeStrongInterface(mRemoteTransition);
        if (mAppThread != null) dest.writeStrongInterface(mAppThread);
        if (mDebugName != null) dest.writeString(mDebugName);
    }

    @Override
@@ -158,11 +191,13 @@ public class RemoteTransition implements Parcelable {
        byte flg = in.readByte();
        IRemoteTransition remoteTransition = IRemoteTransition.Stub.asInterface(in.readStrongBinder());
        IApplicationThread appThread = (flg & 0x2) == 0 ? null : IApplicationThread.Stub.asInterface(in.readStrongBinder());
        String debugName = (flg & 0x4) == 0 ? null : in.readString();

        this.mRemoteTransition = remoteTransition;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mRemoteTransition);
        this.mAppThread = appThread;
        this.mDebugName = debugName;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -182,10 +217,10 @@ public class RemoteTransition implements Parcelable {
    };

    @DataClass.Generated(
            time = 1630690027011L,
            time = 1678926409863L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/window/RemoteTransition.java",
            inputSignatures = "private @android.annotation.NonNull android.window.IRemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.app.IApplicationThread mAppThread\npublic @android.annotation.Nullable android.os.IBinder asBinder()\nclass RemoteTransition extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
            inputSignatures = "private @android.annotation.NonNull android.window.IRemoteTransition mRemoteTransition\nprivate @android.annotation.Nullable android.app.IApplicationThread mAppThread\nprivate @android.annotation.Nullable java.lang.String mDebugName\npublic @android.annotation.Nullable android.os.IBinder asBinder()\nclass RemoteTransition extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genSetters=true, genAidl=true)")
    @Deprecated
    private void __metadata() {}

+21 −2
Original line number Diff line number Diff line
@@ -194,6 +194,9 @@ public final class TransitionInfo implements Parcelable {

    private AnimationOptions mOptions;

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

    /** @hide */
    public TransitionInfo(@TransitionType int type, @TransitionFlags int flags) {
        mType = type;
@@ -206,6 +209,7 @@ public final class TransitionInfo implements Parcelable {
        in.readTypedList(mChanges, Change.CREATOR);
        in.readTypedList(mRoots, Root.CREATOR);
        mOptions = in.readTypedObject(AnimationOptions.CREATOR);
        mDebugId = in.readInt();
    }

    @Override
@@ -216,6 +220,7 @@ public final class TransitionInfo implements Parcelable {
        dest.writeTypedList(mChanges);
        dest.writeTypedList(mRoots, flags);
        dest.writeTypedObject(mOptions, flags);
        dest.writeInt(mDebugId);
    }

    @NonNull
@@ -351,11 +356,24 @@ public final class TransitionInfo implements Parcelable {
        return (mFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0;
    }

    /**
     * Set an arbitrary "debug" id for this info. This id will not be used for any "real work",
     * it is just for debugging and logging.
     */
    public void setDebugId(int id) {
        mDebugId = id;
    }

    /** Get the "debug" id of this info. Do NOT use this for real work, only use for debugging. */
    public int getDebugId() {
        return mDebugId;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{t=").append(transitTypeToString(mType)).append(" f=0x")
                .append(Integer.toHexString(mFlags)).append(" r=[");
        sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType))
                .append(" f=0x").append(Integer.toHexString(mFlags)).append(" r=[");
        for (int i = 0; i < mRoots.size(); ++i) {
            if (i > 0) {
                sb.append(',');
@@ -514,6 +532,7 @@ public final class TransitionInfo implements Parcelable {
     */
    public TransitionInfo localRemoteCopy() {
        final TransitionInfo out = new TransitionInfo(mType, mFlags);
        out.mDebugId = mDebugId;
        for (int i = 0; i < mChanges.size(); ++i) {
            out.mChanges.add(mChanges.get(i).localRemoteCopy());
        }
+82 −34
Original line number Diff line number Diff line
@@ -1586,61 +1586,109 @@ public final class WindowContainerTransaction implements Parcelable {
            return mShortcutInfo;
        }

        /** Gets a string representation of a hierarchy-op type. */
        public static String hopToString(int type) {
            switch (type) {
                case HIERARCHY_OP_TYPE_REPARENT: return "reparent";
                case HIERARCHY_OP_TYPE_REORDER: return "reorder";
                case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT: return "ChildrenTasksReparent";
                case HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT: return "SetLaunchRoot";
                case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "SetAdjacentRoot";
                case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "LaunchTask";
                case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "SetAdjacentFlagRoot";
                case HIERARCHY_OP_TYPE_PENDING_INTENT: return "PendingIntent";
                case HIERARCHY_OP_TYPE_START_SHORTCUT: return "StartShortcut";
                case HIERARCHY_OP_TYPE_ADD_INSETS_FRAME_PROVIDER: return "addInsetsFrameProvider";
                case HIERARCHY_OP_TYPE_REMOVE_INSETS_FRAME_PROVIDER:
                    return "removeInsetsFrameProvider";
                case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: return "setAlwaysOnTop";
                case HIERARCHY_OP_TYPE_REMOVE_TASK: return "RemoveTask";
                case HIERARCHY_OP_TYPE_FINISH_ACTIVITY: return "finishActivity";
                case HIERARCHY_OP_TYPE_CLEAR_ADJACENT_ROOTS: return "ClearAdjacentRoot";
                case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH:
                    return "setReparentLeafTaskIfRelaunch";
                case HIERARCHY_OP_TYPE_ADD_TASK_FRAGMENT_OPERATION:
                    return "addTaskFragmentOperation";
                default: return "HOP(" + type + ")";
            }
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder();
            sb.append("{").append(hopToString(mType)).append(": ");
            switch (mType) {
                case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT:
                    return "{ChildrenTasksReparent: from=" + mContainer + " to=" + mReparent
                            + " mToTop=" + mToTop + " mReparentTopOnly=" + mReparentTopOnly
                            + " mWindowingMode=" + Arrays.toString(mWindowingModes)
                            + " mActivityType=" + Arrays.toString(mActivityTypes) + "}";
                    sb.append("from=").append(mContainer).append(" to=").append(mReparent)
                            .append(" mToTop=").append(mToTop)
                            .append(" mReparentTopOnly=").append(mReparentTopOnly)
                            .append(" mWindowingMode=").append(Arrays.toString(mWindowingModes))
                            .append(" mActivityType=").append(Arrays.toString(mActivityTypes));
                    break;
                case HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT:
                    return "{SetLaunchRoot: container=" + mContainer
                            + " mWindowingMode=" + Arrays.toString(mWindowingModes)
                            + " mActivityType=" + Arrays.toString(mActivityTypes) + "}";
                    sb.append("container=").append(mContainer)
                            .append(" mWindowingMode=").append(Arrays.toString(mWindowingModes))
                            .append(" mActivityType=").append(Arrays.toString(mActivityTypes));
                    break;
                case HIERARCHY_OP_TYPE_REPARENT:
                    return "{reparent: " + mContainer + " to " + (mToTop ? "top of " : "bottom of ")
                            + mReparent + "}";
                    sb.append(mContainer).append(" to ").append(mToTop ? "top of " : "bottom of ")
                            .append(mReparent);
                    break;
                case HIERARCHY_OP_TYPE_REORDER:
                    return "{reorder: " + mContainer + " to " + (mToTop ? "top" : "bottom") + "}";
                    sb.append(mContainer).append(" to ").append(mToTop ? "top" : "bottom");
                    break;
                case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS:
                    return "{SetAdjacentRoot: container=" + mContainer
                            + " adjacentRoot=" + mReparent + "}";
                    sb.append("container=").append(mContainer)
                            .append(" adjacentRoot=").append(mReparent);
                    break;
                case HIERARCHY_OP_TYPE_LAUNCH_TASK:
                    return "{LaunchTask: " + mLaunchOptions + "}";
                    sb.append(mLaunchOptions);
                    break;
                case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT:
                    return "{SetAdjacentFlagRoot: container=" + mContainer + " clearRoot=" + mToTop
                            + "}";
                    sb.append("container=").append(mContainer).append(" clearRoot=").append(mToTop);
                    break;
                case HIERARCHY_OP_TYPE_START_SHORTCUT:
                    return "{StartShortcut: options=" + mLaunchOptions + " info=" + mShortcutInfo
                            + "}";
                    sb.append("options=").append(mLaunchOptions)
                            .append(" info=").append(mShortcutInfo);
                    break;
                case HIERARCHY_OP_TYPE_PENDING_INTENT:
                    sb.append("options=").append(mLaunchOptions);
                    break;
                case HIERARCHY_OP_TYPE_ADD_INSETS_FRAME_PROVIDER:
                    return "{addRectInsetsProvider: container=" + mContainer
                            + " provider=" + mInsetsFrameProvider + "}";
                case HIERARCHY_OP_TYPE_REMOVE_INSETS_FRAME_PROVIDER:
                    return "{removeLocalInsetsProvider: container=" + mContainer
                            + " provider=" + mInsetsFrameProvider + "}";
                    sb.append("container=").append(mContainer)
                            .append(" provider=").append(mInsetsFrameProvider);
                    break;
                case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP:
                    return "{setAlwaysOnTop: container=" + mContainer
                            + " alwaysOnTop=" + mAlwaysOnTop + "}";
                    sb.append("container=").append(mContainer)
                            .append(" alwaysOnTop=").append(mAlwaysOnTop);
                    break;
                case HIERARCHY_OP_TYPE_REMOVE_TASK:
                    return "{RemoveTask: task=" + mContainer + "}";
                    sb.append("task=").append(mContainer);
                    break;
                case HIERARCHY_OP_TYPE_FINISH_ACTIVITY:
                    return "{finishActivity: activity=" + mContainer + "}";
                    sb.append("activity=").append(mContainer);
                    break;
                case HIERARCHY_OP_TYPE_CLEAR_ADJACENT_ROOTS:
                    return "{ClearAdjacentRoot: container=" + mContainer + "}";
                    sb.append("container=").append(mContainer);
                    break;
                case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH:
                    return "{setReparentLeafTaskIfRelaunch: container= " + mContainer
                            + " reparentLeafTaskIfRelaunch= " + mReparentLeafTaskIfRelaunch + "}";
                    sb.append("container= ").append(mContainer)
                            .append(" reparentLeafTaskIfRelaunch= ")
                            .append(mReparentLeafTaskIfRelaunch);
                    break;
                case HIERARCHY_OP_TYPE_ADD_TASK_FRAGMENT_OPERATION:
                    return "{addTaskFragmentOperation: fragmentToken= " + mContainer
                            + " operation= " + mTaskFragmentOperation + "}";
                    sb.append("fragmentToken= ").append(mContainer)
                            .append(" operation= ").append(mTaskFragmentOperation);
                    break;
                default:
                    return "{mType=" + mType + " container=" + mContainer + " reparent=" + mReparent
                            + " mToTop=" + mToTop
                            + " mWindowingMode=" + Arrays.toString(mWindowingModes)
                            + " mActivityType=" + Arrays.toString(mActivityTypes) + "}";
                    sb.append("container=").append(mContainer)
                            .append(" reparent=").append(mReparent)
                            .append(" mToTop=").append(mToTop)
                            .append(" mWindowingMode=").append(Arrays.toString(mWindowingModes))
                            .append(" mActivityType=").append(Arrays.toString(mActivityTypes));
            }
            return sb.append("}").toString();
        }

        @Override
+1 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ public class DefaultMixedHandler implements Transitions.TransitionHandler,
    private TransitionInfo subCopy(@NonNull TransitionInfo info,
            @WindowManager.TransitionType int newType, boolean withChanges) {
        final TransitionInfo out = new TransitionInfo(newType, withChanges ? info.getFlags() : 0);
        out.setDebugId(info.getDebugId());
        if (withChanges) {
            for (int i = 0; i < info.getChanges().size(); ++i) {
                out.getChanges().add(info.getChanges().get(i));
+7 −4
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        if (mTransition != transition) return false;
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Using registered One-shot remote"
                + " transition %s for %s.", mRemote, transition);
                + " transition %s for #%d.", mRemote, info.getDebugId());

        final IBinder.DeathRecipient remoteDied = () -> {
            Log.e(Transitions.TAG, "Remote transition died, finishing");
@@ -113,9 +113,6 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
    public void mergeAnimation(@NonNull IBinder transition, @NonNull TransitionInfo info,
            @NonNull SurfaceControl.Transaction t, @NonNull IBinder mergeTarget,
            @NonNull Transitions.TransitionFinishCallback finishCallback) {
        ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "Using registered One-shot remote"
                + " transition %s for %s.", mRemote, transition);

        IRemoteTransitionFinishedCallback cb = new IRemoteTransitionFinishedCallback.Stub() {
            @Override
            public void onTransitionFinished(WindowContainerTransaction wct,
@@ -154,4 +151,10 @@ public class OneShotRemoteHandler implements Transitions.TransitionHandler {
                + " for %s: %s", transition, remote);
        return new WindowContainerTransaction();
    }

    @Override
    public String toString() {
        return "OneShotRemoteHandler:" + mRemote.getDebugName() + ":"
                + mRemote.getRemoteTransition();
    }
}
Loading