diff options
| author | 2021-11-09 09:32:01 +0000 | |
|---|---|---|
| committer | 2021-11-11 09:15:04 +0000 | |
| commit | 99c2727ebe23973be6daab151726ef221c2ccce7 (patch) | |
| tree | 53c7fdee12a325439ff1dca6008fe0e5d4794406 | |
| parent | 30254e083842c0d71134e2fe60686998db37e8bc (diff) | |
Add CUJ_NOTIFICATION_SHADE_ROW_SWIPE CUJ
Add CUJ_NOTIFICATION_SHADE_ROW_SWIPE for recording during a notification
is being swiped by user.
Bug: 199715431
Test: atest
com.android.systemui.statusbar.notification.stack.NotificationSwipeHelperTest
Change-Id: I5f4f751766906d87c91ff81cba22094deba3caf3
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/SwipeHelper.java | 14 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java | 24 |
2 files changed, 38 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java index 3555e8d8e193..4a0c30ccd798 100644 --- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java @@ -372,6 +372,11 @@ public class SwipeHelper implements Gefingerpoken { } /** + * After dismissChild() and related animation finished, this function will be called. + */ + protected void onDismissChildWithAnimationFinished() {} + + /** * @param view The view to be dismissed * @param velocity The desired pixels/second speed at which the view should move * @param useAccelerateInterpolator Should an accelerating Interpolator be used @@ -436,6 +441,7 @@ public class SwipeHelper implements Gefingerpoken { Animator anim = getViewTranslationAnimator(animView, newPos, updateListener); if (anim == null) { + onDismissChildWithAnimationFinished(); return; } if (useAccelerateInterpolator) { @@ -481,6 +487,7 @@ public class SwipeHelper implements Gefingerpoken { if (!mDisableHwLayers) { animView.setLayerType(View.LAYER_TYPE_NONE, null); } + onDismissChildWithAnimationFinished(); } }); @@ -505,6 +512,11 @@ public class SwipeHelper implements Gefingerpoken { // Do nothing } + /** + * After snapChild() and related animation finished, this function will be called. + */ + protected void onSnapChildWithAnimationFinished() {} + public void snapChild(final View animView, final float targetLeft, float velocity) { final boolean canBeDismissed = mCallback.canChildBeDismissed(animView); AnimatorUpdateListener updateListener = animation -> onTranslationUpdate(animView, @@ -512,6 +524,7 @@ public class SwipeHelper implements Gefingerpoken { Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener); if (anim == null) { + onSnapChildWithAnimationFinished(); return; } anim.addListener(new AnimatorListenerAdapter() { @@ -529,6 +542,7 @@ public class SwipeHelper implements Gefingerpoken { updateSwipeProgressFromOffset(animView, canBeDismissed); resetSwipeState(); } + onSnapChildWithAnimationFinished(); } }); prepareSnapBackAnimation(animView, anim); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java index 664776975b24..eb7410c08733 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSwipeHelper.java @@ -17,6 +17,8 @@ package com.android.systemui.statusbar.notification.stack; +import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_ROW_SWIPE; + import android.animation.Animator; import android.animation.ValueAnimator; import android.content.res.Resources; @@ -28,6 +30,7 @@ import android.view.View; import android.view.ViewConfiguration; import com.android.internal.annotations.VisibleForTesting; +import com.android.internal.jank.InteractionJankMonitor; import com.android.systemui.SwipeHelper; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.FalsingManager; @@ -264,6 +267,22 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc } @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + final boolean previousIsSwiping = isSwiping(); + boolean ret = super.onInterceptTouchEvent(ev); + final View swipedView = getSwipedView(); + if (!previousIsSwiping && swipedView != null) { + InteractionJankMonitor.getInstance().begin(swipedView, + CUJ_NOTIFICATION_SHADE_ROW_SWIPE); + } + return ret; + } + + protected void onDismissChildWithAnimationFinished() { + InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_SHADE_ROW_SWIPE); + } + + @Override public void dismissChild(final View view, float velocity, boolean useAccelerateInterpolator) { superDismissChild(view, velocity, useAccelerateInterpolator); @@ -281,6 +300,11 @@ class NotificationSwipeHelper extends SwipeHelper implements NotificationSwipeAc super.dismissChild(view, velocity, useAccelerateInterpolator); } + @Override + protected void onSnapChildWithAnimationFinished() { + InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_SHADE_ROW_SWIPE); + } + @VisibleForTesting protected void superSnapChild(final View animView, final float targetLeft, float velocity) { super.snapChild(animView, targetLeft, velocity); |