From a929c7ab756ac5b95fe27e1d22e1e11858d18b64 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 10 Jul 2024 14:30:51 +0000 Subject: [PATCH] Revert^2 "Add CUJ instrumentation for KQS" 0947d9f6187d8cb789a669d245eecbc9f4e0e292 Change-Id: Ifc6f2ae8f447939f274fb6167cc74c0cd2e89652 --- .../taskbar/KeyboardQuickSwitchView.java | 11 +++++++ .../KeyboardQuickSwitchViewController.java | 30 +++++++++++++++++-- .../taskbar/TaskbarActivityContext.java | 30 ++++++++++++++++--- .../quickstep/util/SlideInRemoteTransition.kt | 4 +++ 4 files changed, 68 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java index 5d47212114..0ba5de14dd 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java @@ -46,6 +46,7 @@ import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.res.ResourcesCompat; import com.android.app.animation.Interpolators; +import com.android.internal.jank.Cuj; import com.android.launcher3.R; import com.android.launcher3.Utilities; 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.quickstep.util.DesktopTask; import com.android.quickstep.util.GroupTask; +import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import java.util.HashMap; import java.util.List; @@ -331,6 +333,8 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); + InteractionJankMonitorWrapper.begin( + KeyboardQuickSwitchView.this, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN); setClipToPadding(false); setOutlineProvider(new ViewOutlineProvider() { @Override @@ -365,6 +369,12 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { requestFocus(); } + @Override + public void onAnimationCancel(Animator animation) { + super.onAnimationCancel(animation); + InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN); + } + @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); @@ -372,6 +382,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout { setOutlineProvider(outlineProvider); invalidateOutline(); mOpenAnimation = null; + InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_OPEN); } }); diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index 73819b32c8..d411ba6745 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -16,6 +16,7 @@ package com.android.launcher3.taskbar; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.view.KeyEvent; import android.view.animation.AnimationUtils; import android.window.RemoteTransition; @@ -23,6 +24,7 @@ import android.window.RemoteTransition; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.android.internal.jank.Cuj; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorListeners; 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.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; +import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; import java.io.PrintWriter; @@ -93,18 +96,28 @@ public class KeyboardQuickSwitchViewController { protected void closeQuickSwitchView(boolean animate) { if (isCloseAnimationRunning()) { - // Let currently-running animation finish. if (!animate) { mCloseAnimation.end(); } + // Let currently-running animation finish. return; } if (!animate) { + InteractionJankMonitorWrapper.begin( + mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE); onCloseComplete(); return; } 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.start(); } @@ -142,16 +155,26 @@ public class KeyboardQuickSwitchViewController { 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; RemoteTransition remoteTransition = new RemoteTransition(new SlideInRemoteTransition( Utilities.isRtl(mControllers.taskbarActivityContext.getResources()), context.getDeviceProfile().overviewPageSpacing, QuickStepContract.getWindowCornerRadius(context), AnimationUtils.loadInterpolator( - context, android.R.interpolator.fast_out_extra_slow_in)), + context, android.R.interpolator.fast_out_extra_slow_in), + onStartCallback, + onFinishCallback), "SlideInTransition"); mControllers.taskbarActivityContext.handleGroupTaskLaunch( - task, remoteTransition, mOnDesktop); + task, + remoteTransition, + mOnDesktop, + onStartCallback, + onFinishCallback); return -1; } @@ -159,6 +182,7 @@ public class KeyboardQuickSwitchViewController { mCloseAnimation = null; mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView); mControllerCallbacks.onCloseComplete(); + InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_CLOSE); } protected void onDestroy() { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 21a826870e..f7f2a671e5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -1213,22 +1213,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: * - If the GroupTask is a DesktopTask, launch the tasks in that Desktop. * - If {@code onDesktop}, bring the given GroupTask to the front. * - If the GroupTask is a single task, launch it via startActivityFromRecents. * - Otherwise, we assume the GroupTask is a Split pair and launch them together. + *

+ * 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, - boolean onDesktop) { + public void handleGroupTaskLaunch( + GroupTask task, + @Nullable RemoteTransition remoteTransition, + boolean onDesktop, + @Nullable Runnable onStartCallback, + @Nullable Runnable onFinishCallback) { if (task instanceof DesktopTask) { UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(), remoteTransition)); } else if (onDesktop) { - UI_HELPER_EXECUTOR.execute(() -> - SystemUiProxy.INSTANCE.get(this).showDesktopApp(task.task1.key.id)); + UI_HELPER_EXECUTOR.execute(() -> { + if (onStartCallback != null) { + onStartCallback.run(); + } + SystemUiProxy.INSTANCE.get(this).showDesktopApp(task.task1.key.id); + if (onFinishCallback != null) { + onFinishCallback.run(); + } + }); } else if (task.task2 == null) { UI_HELPER_EXECUTOR.execute(() -> { ActivityOptions activityOptions = diff --git a/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt b/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt index dbeedd33f7..ece958395f 100644 --- a/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt +++ b/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt @@ -36,6 +36,8 @@ class SlideInRemoteTransition( private val pageSpacing: Int, private val cornerRadius: Float, private val interpolator: TimeInterpolator, + private val onStartCallback: Runnable, + private val onFinishCallback: Runnable, ) : RemoteTransitionStub() { private val animationDurationMs = 500L @@ -68,6 +70,7 @@ class SlideInRemoteTransition( startT.setCrop(leash, chg.endAbsBounds).setCornerRadius(leash, cornerRadius) } } + onStartCallback.run() startT.apply() anim.addUpdateListener { @@ -97,6 +100,7 @@ class SlideInRemoteTransition( val t = Transaction() try { finishCB.onTransitionFinished(null, t) + onFinishCallback.run() } catch (e: RemoteException) { // Ignore }