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

Commit a35c28a2 authored by Devarshi Bhatt's avatar Devarshi Bhatt
Browse files

Remove InteractionJankMonitorUtils and usages.



Replace usages of the wrapper class in WindowManager code with the
original InteractionJankMonitor class in frameworks.

Test: atest affected classes
Bug: 348339127
Flag: NONE replace API usages

Change-Id: I354b3370d4618486d16818f41a51020cddfec936
Signed-off-by: default avatarDevarshi Bhatt <devarshimb@google.com>
parent 97e569a3
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import android.window.IOnBackInvokedCallback;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.Cuj.CujType;
import com.android.wm.shell.common.InteractionJankMonitorUtils;
import com.android.internal.jank.InteractionJankMonitor;

/**
 * Used to register the animation callback and runner, it will trigger result if gesture was finish
@@ -86,20 +86,21 @@ public class BackAnimationRunner {
     */
    void startAnimation(RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers,
            RemoteAnimationTarget[] nonApps, Runnable finishedCallback) {
        InteractionJankMonitor interactionJankMonitor = InteractionJankMonitor.getInstance();
        final IRemoteAnimationFinishedCallback callback =
                new IRemoteAnimationFinishedCallback.Stub() {
                    @Override
                    public void onAnimationFinished() {
                        if (shouldMonitorCUJ(apps)) {
                            InteractionJankMonitorUtils.endTracing(mCujType);
                            interactionJankMonitor.end(mCujType);
                        }
                        finishedCallback.run();
                    }
                };
        mWaitingAnimation = false;
        if (shouldMonitorCUJ(apps)) {
            InteractionJankMonitorUtils.beginTracing(
                    mCujType, mContext, apps[0].leash, /* tag */ null);
            interactionJankMonitor.begin(
                    apps[0].leash, mContext, mCujType);
        }
        try {
            getRunner().onAnimationStart(TRANSIT_OLD_UNSET, apps, wallpapers,
+0 −84
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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.Cuj.CujType;
import com.android.internal.jank.InteractionJankMonitor;

/** Utils class for simplfy InteractionJank trancing call */
public class InteractionJankMonitorUtils {

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

    /**
     * Begin a trace session.
     *
     * @param cujType the specific {@link 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(@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.
     *
     * @param cujType the specific {@link CujType}.
     */
    public static void endTracing(@CujType int cujType) {
        InteractionJankMonitor.getInstance().end(cujType);
    }

    /**
     * Cancel the trace session.
     *
     * @param cujType the specific {@link CujType}.
     */
    public static void cancelTracing(@CujType int cujType) {
        InteractionJankMonitor.getInstance().cancel(cujType);
    }
}
+11 −10
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.window.WindowContainerTransaction;
import androidx.annotation.Nullable;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.protolog.ProtoLog;
import com.android.wm.shell.R;
import com.android.wm.shell.ShellTaskOrganizer;
@@ -67,7 +68,6 @@ import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.InteractionJankMonitorUtils;
import com.android.wm.shell.common.split.SplitScreenConstants.PersistentSnapPosition;
import com.android.wm.shell.common.split.SplitScreenConstants.SnapPosition;
import com.android.wm.shell.common.split.SplitScreenConstants.SplitPosition;
@@ -131,6 +131,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange

    private final boolean mDimNonImeSide;
    private final boolean mAllowLeftRightSplitInPortrait;
    private final InteractionJankMonitor mInteractionJankMonitor;
    private boolean mIsLeftRightSplit;
    private ValueAnimator mDividerFlingAnimator;

@@ -163,6 +164,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange

        mRootBounds.set(configuration.windowConfiguration.getBounds());
        mDividerSnapAlgorithm = getSnapAlgorithm(mContext, mRootBounds);
        mInteractionJankMonitor = InteractionJankMonitor.getInstance();
        resetDividerPosition();
        updateInvisibleRect();
    }
@@ -569,12 +571,11 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
    }

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

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

    void onDoubleTappedDivider() {
@@ -638,7 +639,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
            if (flingFinishedCallback != null) {
                flingFinishedCallback.run();
            }
            InteractionJankMonitorUtils.endTracing(
            mInteractionJankMonitor.end(
                    CUJ_SPLIT_SCREEN_RESIZE);
            return;
        }
@@ -661,7 +662,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                if (flingFinishedCallback != null) {
                    flingFinishedCallback.run();
                }
                InteractionJankMonitorUtils.endTracing(
                mInteractionJankMonitor.end(
                        CUJ_SPLIT_SCREEN_RESIZE);
                mDividerFlingAnimator = null;
            }
@@ -707,8 +708,8 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                InteractionJankMonitorUtils.beginTracing(CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER,
                        mContext, getDividerLeash(), null /*tag*/);
                mInteractionJankMonitor.begin(getDividerLeash(),
                        mContext, CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER);
            }

            @Override
@@ -716,12 +717,12 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
                mDividerPosition = dividerPos;
                updateBounds(mDividerPosition);
                finishCallback.accept(insets);
                InteractionJankMonitorUtils.endTracing(CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER);
                mInteractionJankMonitor.end(CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                InteractionJankMonitorUtils.cancelTracing(CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER);
                mInteractionJankMonitor.cancel(CUJ_SPLIT_SCREEN_DOUBLE_TAP_DIVIDER);
            }
        });
        set.start();
+6 −4
Original line number Diff line number Diff line
@@ -222,7 +222,8 @@ public abstract class WMShellModule {
            SyncTransactionQueue syncQueue,
            Transitions transitions,
            Optional<DesktopTasksController> desktopTasksController,
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer) {
            RootTaskDisplayAreaOrganizer rootTaskDisplayAreaOrganizer,
            InteractionJankMonitor interactionJankMonitor) {
        if (DesktopModeStatus.canEnterDesktopMode(context)) {
            return new DesktopModeWindowDecorViewModel(
                    context,
@@ -239,7 +240,8 @@ public abstract class WMShellModule {
                    syncQueue,
                    transitions,
                    desktopTasksController,
                    rootTaskDisplayAreaOrganizer);
                    rootTaskDisplayAreaOrganizer,
                    interactionJankMonitor);
        }
        return new CaptionWindowDecorViewModel(
                context,
@@ -577,8 +579,8 @@ public abstract class WMShellModule {
    @WMSingleton
    @Provides
    static ToggleResizeDesktopTaskTransitionHandler provideToggleResizeDesktopTaskTransitionHandler(
            Transitions transitions) {
        return new ToggleResizeDesktopTaskTransitionHandler(transitions);
            Transitions transitions, InteractionJankMonitor interactionJankMonitor) {
        return new ToggleResizeDesktopTaskTransitionHandler(transitions, interactionJankMonitor);
    }

    @WMSingleton
+7 −5
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import androidx.core.animation.addListener
import com.android.internal.jank.Cuj
import com.android.wm.shell.common.InteractionJankMonitorUtils
import com.android.internal.jank.InteractionJankMonitor
import com.android.wm.shell.transition.Transitions
import com.android.wm.shell.transition.Transitions.TRANSIT_DESKTOP_MODE_TOGGLE_RESIZE
import com.android.wm.shell.windowdecor.OnTaskResizeAnimationListener
@@ -37,7 +37,8 @@ import java.util.function.Supplier
/** Handles the animation of quick resizing of desktop tasks. */
class ToggleResizeDesktopTaskTransitionHandler(
    private val transitions: Transitions,
    private val transactionSupplier: Supplier<SurfaceControl.Transaction>
    private val transactionSupplier: Supplier<SurfaceControl.Transaction>,
    private val interactionJankMonitor: InteractionJankMonitor
) : Transitions.TransitionHandler {

    private val rectEvaluator = RectEvaluator(Rect())
@@ -46,8 +47,9 @@ class ToggleResizeDesktopTaskTransitionHandler(
    private var boundsAnimator: Animator? = null

    constructor(
        transitions: Transitions
    ) : this(transitions, Supplier { SurfaceControl.Transaction() })
        transitions: Transitions,
        interactionJankMonitor: InteractionJankMonitor
    ) : this(transitions, Supplier { SurfaceControl.Transaction() }, interactionJankMonitor)

    /** Starts a quick resize transition. */
    fun startTransition(wct: WindowContainerTransaction) {
@@ -105,7 +107,7 @@ class ToggleResizeDesktopTaskTransitionHandler(
                            onTaskResizeAnimationListener.onAnimationEnd(taskId)
                            finishCallback.onTransitionFinished(null)
                            boundsAnimator = null
                            InteractionJankMonitorUtils.endTracing(
                            interactionJankMonitor.end(
                                Cuj.CUJ_DESKTOP_MODE_MAXIMIZE_WINDOW)
                        }
                    )
Loading