Add LAUNCHER_ALL_APPS_SEARCH_BACK jank instrumentation
Bug: 330405993
Test: prefetto trace TBD
Flag: aconfig com.android.launcher3.enable_predictive_back_gesture TEAMFOOD
Change-Id: I1fb2876fb29bc360cbb8dc8c1605215f28383c3c
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index 7875dae..2625919 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -68,10 +68,13 @@
@Override
public void onBackInvoked(Launcher launcher) {
// In predictive back swipe, onBackInvoked() will be called after onBackStarted().
- // Because the 2nd InteractionJankMonitor.begin() will be ignore within timeout, it's safe
- // to call InteractionJankMonitorWrapper.begin here.
- InteractionJankMonitorWrapper.begin(launcher.getAppsView(),
- Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
+ // In 3 button mode, onBackStarted() is not called but onBackInvoked() will be called.
+ // Thus In onBackInvoked(), we should only begin instrumenting if we didn't call
+ // onBackStarted() to start instrumenting CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK.
+ if (!InteractionJankMonitorWrapper.isInstrumenting(Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK)) {
+ InteractionJankMonitorWrapper.begin(
+ launcher.getAppsView(), Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
+ }
super.onBackInvoked(launcher);
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index cfa8967..3273f27 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -680,7 +680,7 @@
@Override
public void onBackCancelled() {
- mStateManager.getState().onBackCancelled(Launcher.this);
+ Launcher.this.onBackCancelled();
}
};
}
@@ -2086,6 +2086,10 @@
mStateManager.getState().onBackInvoked(this);
}
+ protected void onBackCancelled() {
+ mStateManager.getState().onBackCancelled(this);
+ }
+
protected void onScreenOnChanged(boolean isOn) {
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 4b65b73..799b67b 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -85,6 +85,7 @@
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.recyclerview.AllAppsRecyclerViewPool;
import com.android.launcher3.util.ItemInfoMatcher;
+import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
@@ -1366,6 +1367,18 @@
invalidateHeader();
}
+ /**
+ * Set {@link Animator.AnimatorListener} on {@link mAllAppsTransitionController} to observe
+ * animation of backing out of all apps search view to all apps view.
+ */
+ public void setAllAppsSearchBackAnimatorListener(Animator.AnimatorListener listener) {
+ Preconditions.assertNotNull(mAllAppsTransitionController);
+ if (mAllAppsTransitionController == null) {
+ return;
+ }
+ mAllAppsTransitionController.setAllAppsSearchBackAnimationListener(listener);
+ }
+
public void setScrimView(ScrimView scrimView) {
mScrimView = scrimView;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 63f6227..a4d1dc1 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -44,6 +44,7 @@
import android.view.animation.Interpolator;
import androidx.annotation.FloatRange;
+import androidx.annotation.Nullable;
import com.android.app.animation.Interpolators;
import com.android.launcher3.DeviceProfile;
@@ -167,6 +168,8 @@
private final AnimatedFloat mAllAppScale = new AnimatedFloat(this::onScaleProgressChanged);
private final int mNavScrimFlag;
+ @Nullable private Animator.AnimatorListener mAllAppsSearchBackAnimationListener;
+
private boolean mIsVerticalLayout;
// Animation in this class is controlled by a single variable {@link mProgress}.
@@ -312,11 +315,25 @@
}
}
- /** Animate all apps view to 1f scale. */
+ /** Set {@link Animator.AnimatorListener} for scaling all apps scale to 1 animation. */
+ public void setAllAppsSearchBackAnimationListener(Animator.AnimatorListener listener) {
+ mAllAppsSearchBackAnimationListener = listener;
+ }
+
+ /**
+ * Animate all apps view to 1f scale. This is called when backing (exiting) from all apps
+ * search view to all apps view.
+ */
public void animateAllAppsToNoScale() {
- mAllAppScale.animateToValue(1f)
- .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS)
- .start();
+ if (mAllAppScale.isAnimating()) {
+ return;
+ }
+ Animator animator = mAllAppScale.animateToValue(1f)
+ .setDuration(REVERT_SWIPE_ALL_APPS_TO_HOME_ANIMATION_DURATION_MS);
+ if (mAllAppsSearchBackAnimationListener != null) {
+ animator.addListener(mAllAppsSearchBackAnimationListener);
+ }
+ animator.start();
}
/**