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

Commit 4f677e9d authored by Tony Huang's avatar Tony Huang Committed by Android (Google) Code Review
Browse files

Merge "Add jank monitor trace for divider dragging" into tm-qpr-dev

parents 45c099a4 08da44e1
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -18,7 +18,9 @@ package com.android.wm.shell.common;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.text.TextUtils;
import android.view.SurfaceControl;
import android.view.View;

import com.android.internal.jank.InteractionJankMonitor;
@@ -43,6 +45,24 @@ public class InteractionJankMonitorUtils {
        InteractionJankMonitor.getInstance().begin(builder);
    }

    /**
     * Begin a trace session.
     *
     * @param cujType the specific {@link InteractionJankMonitor.CujType}.
     * @param context the context
     * @param surface the surface to trace
     * @param tag the tag to distinguish different flow of same type CUJ.
     */
    public static void beginTracing(@InteractionJankMonitor.CujType int cujType,
            @NonNull Context context, @NonNull SurfaceControl surface, @Nullable String tag) {
        final InteractionJankMonitor.Configuration.Builder builder =
                InteractionJankMonitor.Configuration.Builder.withSurface(cujType, context, surface);
        if (!TextUtils.isEmpty(tag)) {
            builder.setTag(tag);
        }
        InteractionJankMonitor.getInstance().begin(builder);
    }

    /**
     * End a trace session.
     *
+5 −1
Original line number Diff line number Diff line
@@ -286,6 +286,7 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
                setTouching();
                mStartPos = touchPos;
                mMoving = false;
                mSplitLayout.onStartDragging();
                break;
            case MotionEvent.ACTION_MOVE:
                mVelocityTracker.addMovement(event);
@@ -301,7 +302,10 @@ public class DividerView extends FrameLayout implements View.OnTouchListener {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                releaseTouching();
                if (!mMoving) break;
                if (!mMoving) {
                    mSplitLayout.onDraggingCancelled();
                    break;
                }

                mVelocityTracker.addMovement(event);
                mVelocityTracker.computeCurrentVelocity(1000 /* units */);
+13 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_RIGHT;
import static android.view.WindowManager.DOCKED_TOP;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLIT_SCREEN_RESIZE;
import static com.android.internal.policy.DividerSnapAlgorithm.SnapTarget.FLAG_DISMISS_END;
import static com.android.internal.policy.DividerSnapAlgorithm.SnapTarget.FLAG_DISMISS_START;
import static com.android.wm.shell.animation.Interpolators.DIM_INTERPOLATOR;
@@ -55,7 +56,6 @@ import android.window.WindowContainerTransaction;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.policy.DividerSnapAlgorithm;
import com.android.internal.policy.DockedDividerUtils;
import com.android.wm.shell.R;
@@ -407,6 +407,15 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        }
    }

    void onStartDragging() {
        InteractionJankMonitorUtils.beginTracing(CUJ_SPLIT_SCREEN_RESIZE, mContext,
                getDividerLeash(), null /* tag */);
    }

    void onDraggingCancelled() {
        InteractionJankMonitorUtils.cancelTracing(CUJ_SPLIT_SCREEN_RESIZE);
    }

    void onDoubleTappedDivider() {
        mSplitLayoutHandler.onDoubleTappedDivider();
    }
@@ -438,10 +447,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        if (from == to) {
            // No animation run, still callback to stop resizing.
            mSplitLayoutHandler.onLayoutSizeChanged(this);
            InteractionJankMonitorUtils.endTracing(
                    CUJ_SPLIT_SCREEN_RESIZE);
            return;
        }
        InteractionJankMonitorUtils.beginTracing(InteractionJankMonitor.CUJ_SPLIT_SCREEN_RESIZE,
                mSplitWindowManager.getDividerView(), "Divider fling");
        ValueAnimator animator = ValueAnimator
                .ofInt(from, to)
                .setDuration(250);
@@ -455,7 +464,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                    flingFinishedCallback.run();
                }
                InteractionJankMonitorUtils.endTracing(
                        InteractionJankMonitor.CUJ_SPLIT_SCREEN_RESIZE);
                        CUJ_SPLIT_SCREEN_RESIZE);
            }

            @Override