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

Commit 610a6f2a authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

[PiP2] Add Enter PiP jank cuj tag

Add the enter PiP jank CUJ tag and make sure
it's begin() and end() calls are emitted at
the start and finish of enter animation which match
PipTransitionState's ENTERING_PIP and ENTERED_PIP updates

Bug: 352738878
Flag: com.android.wm.shell.enable_pip2
Test: atest PipInteractionHandlerTest
Test: check perfetto traces for jank cuj tags
Change-Id: Ia1c6284199bcd60fd3c9823ecb29d8060c243b3d
parent ce48679b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ import java.lang.annotation.RetentionPolicy;
public class PipInteractionHandler {
    @IntDef(prefix = {"INTERACTION_"}, value = {
            INTERACTION_EXIT_PIP,
            INTERACTION_EXIT_PIP_TO_SPLIT
            INTERACTION_EXIT_PIP_TO_SPLIT,
            INTERACTION_ENTER_PIP
    })

    @Retention(RetentionPolicy.SOURCE)
@@ -42,6 +43,7 @@ public class PipInteractionHandler {

    public static final int INTERACTION_EXIT_PIP = 0;
    public static final int INTERACTION_EXIT_PIP_TO_SPLIT = 1;
    public static final int INTERACTION_ENTER_PIP = 2;

    private final Context mContext;
    private final Handler mHandler;
@@ -82,6 +84,7 @@ public class PipInteractionHandler {
        return switch (interaction) {
            case INTERACTION_EXIT_PIP -> "EXIT_PIP";
            case INTERACTION_EXIT_PIP_TO_SPLIT -> "EXIT_PIP_TO_SPLIT";
            case INTERACTION_ENTER_PIP -> "ENTER_PIP";
            default -> "";
        };
    }
+5 −0
Original line number Diff line number Diff line
@@ -1178,6 +1178,11 @@ public class PipTransition extends PipTransitionController implements

                Preconditions.checkState(hasValidTokenAndLeash,
                        "Unexpected bundle for " + mPipTransitionState);
                mPipInteractionHandler.begin(mPipTransitionState.getPinnedTaskLeash(),
                        PipInteractionHandler.INTERACTION_ENTER_PIP);
                break;
            case PipTransitionState.ENTERED_PIP:
                mPipInteractionHandler.end();
                break;
            case PipTransitionState.EXITED_PIP:
                mPipTransitionState.setPinnedTaskLeash(null);
+10 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.wm.shell.pip2.phone;

import static com.android.internal.jank.Cuj.CUJ_PIP_TRANSITION;
import static com.android.wm.shell.pip2.phone.PipInteractionHandler.INTERACTION_ENTER_PIP;
import static com.android.wm.shell.pip2.phone.PipInteractionHandler.INTERACTION_EXIT_PIP;
import static com.android.wm.shell.pip2.phone.PipInteractionHandler.INTERACTION_EXIT_PIP_TO_SPLIT;

@@ -86,6 +87,15 @@ public class PipInteractionHandlerTest {
                eq(PipInteractionHandler.pipInteractionToString(INTERACTION_EXIT_PIP_TO_SPLIT)));
    }

    @Test
    public void begin_enter_startsTracking() {
        mPipInteractionHandler.begin(mTestLeash, INTERACTION_ENTER_PIP);

        verify(mMockInteractionJankMonitor, times(1)).begin(eq(mTestLeash),
                eq(mMockContext), eq(mMockHandler), eq(CUJ_PIP_TRANSITION),
                eq(PipInteractionHandler.pipInteractionToString(INTERACTION_ENTER_PIP)));
    }

    @Test
    public void end_stopsTracking() {
        mPipInteractionHandler.end();