diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index d3835978c0..2b8fdd102f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -31,13 +31,15 @@ import android.animation.AnimatorSet; import android.annotation.Nullable; import android.content.SharedPreferences; import android.util.Log; +import android.view.View; import android.view.ViewConfiguration; -import android.view.WindowInsets; +import androidx.annotation.NonNull; + +import com.android.internal.jank.InteractionJankMonitor; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorListeners; -import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.AnimatedFloat; @@ -45,6 +47,8 @@ import com.android.quickstep.SystemUiProxy; import com.android.systemui.shared.system.WindowManagerWrapper; import java.io.PrintWriter; +import java.util.Arrays; +import java.util.Optional; import java.util.StringJoiner; import java.util.function.IntPredicate; @@ -54,6 +58,8 @@ import java.util.function.IntPredicate; */ public class TaskbarStashController implements TaskbarControllers.LoggableTaskbarController { + private static final String TAG = "TaskbarStashController"; + public static final int FLAG_IN_APP = 1 << 0; public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning @@ -403,6 +409,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba mAnimator.cancel(); } mAnimator = new AnimatorSet(); + addJankMonitorListener(mAnimator, /* appearing= */ !mIsStashed); if (!supportsVisualStashing()) { // Just hide/show the icons and background instead of stashing into a handle. @@ -498,6 +505,28 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba }); } + private void addJankMonitorListener(AnimatorSet animator, boolean expanding) { + Optional optionalView = + Arrays.stream(mControllers.taskbarViewController.getIconViews()).findFirst(); + if (optionalView.isEmpty()) { + Log.wtf(TAG, "No views to start Interaction jank monitor with.", new Exception()); + return; + } + View v = optionalView.get(); + int action = expanding ? InteractionJankMonitor.CUJ_TASKBAR_EXPAND : + InteractionJankMonitor.CUJ_TASKBAR_COLLAPSE; + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(@NonNull Animator animation) { + InteractionJankMonitor.getInstance().begin(v, action); + } + + @Override + public void onAnimationEnd(@NonNull Animator animation) { + InteractionJankMonitor.getInstance().end(action); + } + }); + } /** * Creates and starts a partial stash animation, hinting at the new state that will trigger when * long press is detected.