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

Commit d0811445 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias Committed by Android (Google) Code Review
Browse files

Merge "Add CUJ instrumentation for KQS" into main

parents 501e4ab7 acddb585
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@ import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.content.res.ResourcesCompat;


import com.android.app.animation.Interpolators;
import com.android.app.animation.Interpolators;
import com.android.internal.jank.Cuj;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.anim.AnimatedFloat;
@@ -53,6 +54,7 @@ import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.quickstep.util.DesktopTask;
import com.android.quickstep.util.DesktopTask;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.GroupTask;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;


import java.util.HashMap;
import java.util.HashMap;
import java.util.List;
import java.util.List;
@@ -331,6 +333,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
            @Override
            @Override
            public void onAnimationStart(Animator animation) {
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                super.onAnimationStart(animation);
                InteractionJankMonitorWrapper.begin(
                        KeyboardQuickSwitchView.this, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN);
                setClipToPadding(false);
                setClipToPadding(false);
                setOutlineProvider(new ViewOutlineProvider() {
                setOutlineProvider(new ViewOutlineProvider() {
                    @Override
                    @Override
@@ -365,6 +369,12 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
                requestFocus();
                requestFocus();
            }
            }


            @Override
            public void onAnimationCancel(Animator animation) {
                super.onAnimationCancel(animation);
                InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN);
            }

            @Override
            @Override
            public void onAnimationEnd(Animator animation) {
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                super.onAnimationEnd(animation);
@@ -372,6 +382,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
                setOutlineProvider(outlineProvider);
                setOutlineProvider(outlineProvider);
                invalidateOutline();
                invalidateOutline();
                mOpenAnimation = null;
                mOpenAnimation = null;
                InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN);
            }
            }
        });
        });


+27 −3
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.launcher3.taskbar;
package com.android.launcher3.taskbar;


import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.view.KeyEvent;
import android.view.KeyEvent;
import android.view.animation.AnimationUtils;
import android.view.animation.AnimationUtils;
import android.window.RemoteTransition;
import android.window.RemoteTransition;
@@ -23,6 +24,7 @@ import android.window.RemoteTransition;
import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.internal.jank.Cuj;
import com.android.launcher3.Utilities;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext;
@@ -30,6 +32,7 @@ import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.SlideInRemoteTransition;
import com.android.quickstep.util.SlideInRemoteTransition;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.recents.model.ThumbnailData;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
import com.android.systemui.shared.system.QuickStepContract;
import com.android.systemui.shared.system.QuickStepContract;


import java.io.PrintWriter;
import java.io.PrintWriter;
@@ -93,18 +96,28 @@ public class KeyboardQuickSwitchViewController {


    protected void closeQuickSwitchView(boolean animate) {
    protected void closeQuickSwitchView(boolean animate) {
        if (isCloseAnimationRunning()) {
        if (isCloseAnimationRunning()) {
            // Let currently-running animation finish.
            if (!animate) {
            if (!animate) {
                mCloseAnimation.end();
                mCloseAnimation.end();
            }
            }
            // Let currently-running animation finish.
            return;
            return;
        }
        }
        if (!animate) {
        if (!animate) {
            InteractionJankMonitorWrapper.begin(
                    mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE);
            onCloseComplete();
            onCloseComplete();
            return;
            return;
        }
        }
        mCloseAnimation = mKeyboardQuickSwitchView.getCloseAnimation();
        mCloseAnimation = mKeyboardQuickSwitchView.getCloseAnimation();


        mCloseAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                InteractionJankMonitorWrapper.begin(
                        mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE);
            }
        });
        mCloseAnimation.addListener(AnimatorListeners.forEndCallback(this::onCloseComplete));
        mCloseAnimation.addListener(AnimatorListeners.forEndCallback(this::onCloseComplete));
        mCloseAnimation.start();
        mCloseAnimation.start();
    }
    }
@@ -142,16 +155,26 @@ public class KeyboardQuickSwitchViewController {
            return -1;
            return -1;
        }
        }


        Runnable onStartCallback = () -> InteractionJankMonitorWrapper.begin(
                mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH);
        Runnable onFinishCallback = () -> InteractionJankMonitorWrapper.end(
                Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH);
        TaskbarActivityContext context = mControllers.taskbarActivityContext;
        TaskbarActivityContext context = mControllers.taskbarActivityContext;
        RemoteTransition remoteTransition = new RemoteTransition(new SlideInRemoteTransition(
        RemoteTransition remoteTransition = new RemoteTransition(new SlideInRemoteTransition(
                Utilities.isRtl(mControllers.taskbarActivityContext.getResources()),
                Utilities.isRtl(mControllers.taskbarActivityContext.getResources()),
                context.getDeviceProfile().overviewPageSpacing,
                context.getDeviceProfile().overviewPageSpacing,
                QuickStepContract.getWindowCornerRadius(context),
                QuickStepContract.getWindowCornerRadius(context),
                AnimationUtils.loadInterpolator(
                AnimationUtils.loadInterpolator(
                        context, android.R.interpolator.fast_out_extra_slow_in)),
                        context, android.R.interpolator.fast_out_extra_slow_in),
                onStartCallback,
                onFinishCallback),
                "SlideInTransition");
                "SlideInTransition");
        mControllers.taskbarActivityContext.handleGroupTaskLaunch(
        mControllers.taskbarActivityContext.handleGroupTaskLaunch(
                task, remoteTransition, mOnDesktop);
                task,
                remoteTransition,
                mOnDesktop,
                onStartCallback,
                onFinishCallback);
        return -1;
        return -1;
    }
    }


@@ -159,6 +182,7 @@ public class KeyboardQuickSwitchViewController {
        mCloseAnimation = null;
        mCloseAnimation = null;
        mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView);
        mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView);
        mControllerCallbacks.onCloseComplete();
        mControllerCallbacks.onCloseComplete();
        InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE);
    }
    }


    protected void onDestroy() {
    protected void onDestroy() {
+26 −4
Original line number Original line Diff line number Diff line
@@ -1215,22 +1215,44 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        }
        }
    }
    }


    public void handleGroupTaskLaunch(
            GroupTask task,
            @Nullable RemoteTransition remoteTransition,
            boolean onDesktop) {
        handleGroupTaskLaunch(task, remoteTransition, onDesktop, null, null);
    }

    /**
    /**
     * Launches the given GroupTask with the following behavior:
     * Launches the given GroupTask with the following behavior:
     * - If the GroupTask is a DesktopTask, launch the tasks in that Desktop.
     * - If the GroupTask is a DesktopTask, launch the tasks in that Desktop.
     * - If {@code onDesktop}, bring the given GroupTask to the front.
     * - If {@code onDesktop}, bring the given GroupTask to the front.
     * - If the GroupTask is a single task, launch it via startActivityFromRecents.
     * - If the GroupTask is a single task, launch it via startActivityFromRecents.
     * - Otherwise, we assume the GroupTask is a Split pair and launch them together.
     * - Otherwise, we assume the GroupTask is a Split pair and launch them together.
     * <p>
     * Given start and/or finish callbacks, they will be run before an after the app launch
     * respectively in cases where we can't use the remote transition, otherwise we will assume that
     * these callbacks are included in the remote transition.
     */
     */
    public void handleGroupTaskLaunch(GroupTask task, @Nullable RemoteTransition remoteTransition,
    public void handleGroupTaskLaunch(
            boolean onDesktop) {
            GroupTask task,
            @Nullable RemoteTransition remoteTransition,
            boolean onDesktop,
            @Nullable Runnable onStartCallback,
            @Nullable Runnable onFinishCallback) {
        if (task instanceof DesktopTask) {
        if (task instanceof DesktopTask) {
            UI_HELPER_EXECUTOR.execute(() ->
            UI_HELPER_EXECUTOR.execute(() ->
                    SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(),
                    SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(),
                            remoteTransition));
                            remoteTransition));
        } else if (onDesktop) {
        } else if (onDesktop) {
            UI_HELPER_EXECUTOR.execute(() ->
            UI_HELPER_EXECUTOR.execute(() -> {
                    SystemUiProxy.INSTANCE.get(this).showDesktopApp(task.task1.key.id));
                if (onStartCallback != null) {
                    onStartCallback.run();
                }
                SystemUiProxy.INSTANCE.get(this).showDesktopApp(task.task1.key.id);
                if (onFinishCallback != null) {
                    onFinishCallback.run();
                }
            });
        } else if (task.task2 == null) {
        } else if (task.task2 == null) {
            UI_HELPER_EXECUTOR.execute(() -> {
            UI_HELPER_EXECUTOR.execute(() -> {
                ActivityOptions activityOptions =
                ActivityOptions activityOptions =
+4 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@ class SlideInRemoteTransition(
    private val pageSpacing: Int,
    private val pageSpacing: Int,
    private val cornerRadius: Float,
    private val cornerRadius: Float,
    private val interpolator: TimeInterpolator,
    private val interpolator: TimeInterpolator,
    private val onStartCallback: Runnable,
    private val onFinishCallback: Runnable,
) : RemoteTransitionStub() {
) : RemoteTransitionStub() {
    private val animationDurationMs = 500L
    private val animationDurationMs = 500L


@@ -68,6 +70,7 @@ class SlideInRemoteTransition(
                startT.setCrop(leash, chg.endAbsBounds).setCornerRadius(leash, cornerRadius)
                startT.setCrop(leash, chg.endAbsBounds).setCornerRadius(leash, cornerRadius)
            }
            }
        }
        }
        onStartCallback.run()
        startT.apply()
        startT.apply()


        anim.addUpdateListener {
        anim.addUpdateListener {
@@ -97,6 +100,7 @@ class SlideInRemoteTransition(
                    val t = Transaction()
                    val t = Transaction()
                    try {
                    try {
                        finishCB.onTransitionFinished(null, t)
                        finishCB.onTransitionFinished(null, t)
                        onFinishCallback.run()
                    } catch (e: RemoteException) {
                    } catch (e: RemoteException) {
                        // Ignore
                        // Ignore
                    }
                    }