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

Commit d5651d6e authored by Vania Desmonda's avatar Vania Desmonda
Browse files

Add trace start and end for moving PiP across displays.

Bug: 426154331
Test: EXEMPT adding trace markers
Flag: com.android.window.flags.enable_dragging_pip_across_displays
Change-Id: Ia48a3b5890d8feac6b85948487ab314ee3afcfa6
parent 03499bba
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Trace;
import android.util.ArrayMap;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
@@ -153,6 +154,9 @@ public class PipDisplayTransferHandler implements
                final Rect pipBounds = extra.getParcelable(
                        PIP_DESTINATION_BOUNDS, Rect.class);

                Trace.instant(Trace.TRACE_TAG_WINDOW_MANAGER,
                        "PipDisplayTransferHandler#changingPipBounds");

                mPipDisplayLayoutState.setDisplayId(mTargetDisplayId);
                mPipDisplayLayoutState.setDisplayLayout(
                        mDisplayController.getDisplayLayout(mTargetDisplayId));
+3 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.Trace;
import android.view.SurfaceControl;
import android.window.DisplayAreaInfo;
import android.window.WindowContainerToken;
@@ -241,6 +242,8 @@ public class PipScheduler implements PipTransitionState.PipTransitionStateChange
     * @param targetDisplayId the target display ID where the PiP window should be parented to.
     */
    public void scheduleMoveToDisplay(int targetDisplayId, Rect pipBounds) {
        Trace.instant(Trace.TRACE_TAG_WINDOW_MANAGER,
                "PipScheduler#scheduleMoveToDisplay: " + targetDisplayId);
        WindowContainerToken pipTaskToken = mPipTransitionState.getPipTaskToken();
        DisplayAreaInfo displayAreaInfo =
                mPipDesktopState.getRootTaskDisplayAreaOrganizer().getDisplayAreaInfo(
+9 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.SystemProperties;
import android.os.Trace;
import android.provider.DeviceConfig;
import android.util.Size;
import android.view.DisplayCutout;
@@ -74,6 +75,7 @@ import com.android.wm.shell.sysui.ShellInit;

import java.io.PrintWriter;
import java.util.Optional;
import java.util.Random;

/**
 * Manages all the touch handling for PIP on the Phone, including moving, dismissing and expanding
@@ -145,6 +147,9 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
    // Temp vars
    private final Rect mTmpBounds = new Rect();

    // Random int for tracking trace begin and end
    private int mUniqueCookie;

    // Callbacks
    private final Runnable mMoveOnShelVisibilityChanged;

@@ -266,6 +271,8 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
        if (PipFlags.isPip2ExperimentEnabled()) {
            shellInit.addInitCallback(this::onInit, this);
        }

        mUniqueCookie = new Random().nextInt();
    }

    /**
@@ -587,6 +594,7 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha

        switch (ev.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                Trace.beginAsyncSection("PipTouchHandler#onDown", mUniqueCookie);
                mGesture.onDown(mTouchState);
                break;
            }
@@ -602,7 +610,7 @@ public class PipTouchHandler implements PipTransitionState.PipTransitionStateCha
                // Update the movement bounds again if the state has changed since the user started
                // dragging (ie. when the IME shows)
                updateMovementBounds();

                Trace.endAsyncSection("PipTouchHandler#onDown", mUniqueCookie);
                if (mGesture.onUp(mTouchState)) {
                    break;
                }