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

Commit 99c2727e authored by Milton Wu's avatar Milton Wu
Browse files

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
parent 30254e08
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -371,6 +371,11 @@ public class SwipeHelper implements Gefingerpoken {
        return mIsSwiping || mLongPressSent || mMenuRowIntercepting;
    }

    /**
     * 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
@@ -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);
+24 −0
Original line number Diff line number Diff line
@@ -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;
@@ -263,6 +266,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) {
@@ -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);